[Feature][R306][task-view-153][SDK] Creating an R305 compilation project
Only Configure: Yes
Affected branch: master
Affected module: wifi
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I1c7f147b5e26d8ff25f8f18a4d188a7857a5f822
diff --git a/lynq/R305/allbins/zx297520v3/prj_cpe/nv/psPriData_nvrw_0x00002000.bin b/lynq/R305/allbins/zx297520v3/prj_cpe/nv/psPriData_nvrw_0x00002000.bin
new file mode 100755
index 0000000..1a91a19
--- /dev/null
+++ b/lynq/R305/allbins/zx297520v3/prj_cpe/nv/psPriData_nvrw_0x00002000.bin
Binary files differ
diff --git a/lynq/R305/allbins/zx297520v3/prj_cpe/nv_min/phyLteaAmtUser_nvrwo_0x00007800.bin b/lynq/R305/allbins/zx297520v3/prj_cpe/nv_min/phyLteaAmtUser_nvrwo_0x00007800.bin
new file mode 100755
index 0000000..8fb7d75
--- /dev/null
+++ b/lynq/R305/allbins/zx297520v3/prj_cpe/nv_min/phyLteaAmtUser_nvrwo_0x00007800.bin
Binary files differ
diff --git a/lynq/R305/allbins/zx297520v3/prj_cpe/nv_min/phycom_nvrwo_0x0002BC00.bin b/lynq/R305/allbins/zx297520v3/prj_cpe/nv_min/phycom_nvrwo_0x0002BC00.bin
new file mode 100755
index 0000000..8045334
--- /dev/null
+++ b/lynq/R305/allbins/zx297520v3/prj_cpe/nv_min/phycom_nvrwo_0x0002BC00.bin
Binary files differ
diff --git a/lynq/R305/allbins/zx297520v3/prj_evb/nv/merge_lte/phyLteaAmtUser_nvrwo_0x00007800.bin b/lynq/R305/allbins/zx297520v3/prj_evb/nv/merge_lte/phyLteaAmtUser_nvrwo_0x00007800.bin
new file mode 100755
index 0000000..8fb7d75
--- /dev/null
+++ b/lynq/R305/allbins/zx297520v3/prj_evb/nv/merge_lte/phyLteaAmtUser_nvrwo_0x00007800.bin
Binary files differ
diff --git a/lynq/R305/allbins/zx297520v3/prj_evb/nv/merge_lte/phycom_nvrwo_0x0002BC00.bin b/lynq/R305/allbins/zx297520v3/prj_evb/nv/merge_lte/phycom_nvrwo_0x0002BC00.bin
new file mode 100755
index 0000000..8045334
--- /dev/null
+++ b/lynq/R305/allbins/zx297520v3/prj_evb/nv/merge_lte/phycom_nvrwo_0x0002BC00.bin
Binary files differ
diff --git a/lynq/R305/allbins/zx297520v3/prj_evb/nv/phyLteAmtCali_nvro_0x00008000.bin b/lynq/R305/allbins/zx297520v3/prj_evb/nv/phyLteAmtCali_nvro_0x00008000.bin
new file mode 100755
index 0000000..8fb000e
--- /dev/null
+++ b/lynq/R305/allbins/zx297520v3/prj_evb/nv/phyLteAmtCali_nvro_0x00008000.bin
Binary files differ
diff --git a/lynq/R305/ap/app/cwmp/netcwmp/cwmp.conf b/lynq/R305/ap/app/cwmp/netcwmp/cwmp.conf
new file mode 100755
index 0000000..89aae65
--- /dev/null
+++ b/lynq/R305/ap/app/cwmp/netcwmp/cwmp.conf
@@ -0,0 +1,57 @@
+[cwmp]
+enable=1;
+soap_env=SOAP-ENV
+soap_enc=SOAP-ENC
+acs_auth=1
+cpe_auth=1
+event_filename=/cache/cwmpevent.bin
+
+
+acs_url=http://192.168.0.100:7547/ACS
+#acs_url=http://192.168.28.246:9999/
+ca_file=/cache/ca.pem
+ca_password=
+
+
+cpe_manufacture=zxic
+cpe_oui=FEDCBA
+cpe_sn=744AA4E7b050
+cpe_name=000000
+cpe_pc=OT2800
+cpe_specver=V1.0
+cpe_hwver=V1.0
+cpe_version=V3.3.3.3
+cpe_username=cpe
+cpe_password=cpe
+acs_username=cpe
+acs_password=cpe
+
+
+
+[cwmpd]
+httpd_port=7547
+http_timeout=-1
+
+[file]
+download_root=/cache
+download_img_path=/cache/download.img
+download_cfg_path=/cache/download.cfg
+download_unknown_path=/cache/download.tmp
+upload_cfg_path=/cache/cwmp.cfg
+upload_log_path=/cache/cwmp.log
+
+
+[periodic]
+enable=1
+interval=60
+
+[test]
+parameterkey=123456
+stun_enable=0
+stun_serveraddress=192.168.0.100
+stun_serverport=8080
+stun_username=stun
+stun_password=
+stun_maximumkeepaliveperiod=100
+stun_minimumkeepaliveperiod=10
+natdetected=0
\ No newline at end of file
diff --git a/lynq/R305/ap/app/cwmp/netcwmp/cwmpd/src/agent.c b/lynq/R305/ap/app/cwmp/netcwmp/cwmpd/src/agent.c
new file mode 100755
index 0000000..fc3a2a7
--- /dev/null
+++ b/lynq/R305/ap/app/cwmp/netcwmp/cwmpd/src/agent.c
@@ -0,0 +1,1225 @@
+/************************************************************************
+ * *
+ * Netcwmp/Opencwmp Project *
+ * A software client for enabling TR-069 in embedded devices (CPE). *
+ * *
+ * Copyright (C) 2013-2014 netcwmp.netcwmp group *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, *
+ * Boston, MA 02111-1307 USA *
+ * *
+ * Copyright 2013-2014 Mr.x(Mr.x) <netcwmp@gmail.com> *
+ * *
+ ***********************************************************************/
+#include "cwmp/periodic.h"
+
+#include "cwmp_module.h"
+#include "cwmp_agent.h"
+#include <cwmp/session.h>
+//#include "modules/data_model.h"
+
+#include "soft_timer.h"
+
+
+#define CWMP_TRUE 1
+
+#define MAX_SESSION_RETRY 3
+
+enum
+{
+ CWMP_ST_START = 0,
+ CWMP_ST_INFORM,
+ CWMP_ST_SEND,
+ CWMP_ST_RESEMD,
+ CWMP_ST_RECV,
+ CWMP_ST_ANSLYSE,
+ CWMP_ST_RETRY,
+ CWMP_ST_END,
+ CWMP_ST_EXIT
+};
+
+#define SECHEDULE_INFORM_TIMER (31)
+
+schedule_inform_info_st g_si;
+
+int get_session_status()
+{
+ return g_si.cwmp->session_running;
+}
+
+void *schedule_inform_timeout(void *arg)
+{
+ FUNCTION_TRACE();
+ int i = 0;
+
+ schedule_inform_info_st *psi = (schedule_inform_info_st *)arg;
+
+ cwmp_log_info("push begin");
+
+ psi->timer_running = 2;
+
+// while(1)
+// {
+// if(SESSION_NO_RUNNING == get_session_status())
+// {
+ psi->cwmp->new_request = CWMP_YES;
+ cwmp_event_set_value(psi->cwmp, INFORM_SCHEDULED, 1, psi->commandKey, 0, 0, 0);
+ cwmp_log_info("commandkey is:%s", psi->commandKey);
+ psi->timer_running = 0;
+
+ cwmp_log_info("push ok");
+
+ return NULL;
+// }
+// else
+// {
+// cwmp_log_info("there is session running");
+// psi->timer_running = 0;
+// g_si.delaytime += 1;
+// if(CWMP_OK != schedule_inform_create_timer(&g_si))
+// {
+// ;
+// }
+// }
+// }
+
+ return NULL;
+}
+
+
+int schedule_inform_create_timer(schedule_inform_info_st* psi)
+{
+ FUNCTION_TRACE();
+
+ if(2 == g_si.timer_running){
+ cwmp_log_info("there is other schedule inform running!");
+ return CWMP_OK;
+ }
+ else if(1 == g_si.timer_running)
+ {
+ // if exist one schedule inform timer, update
+ cwmp_log_info("there is other schedule inform active!");
+ DeleteSoftTimer(SECHEDULE_INFORM_TIMER);
+ }
+ else
+ {
+ cwmp_log_info("update schedule inform info, create timer");
+ }
+
+ TRstrncpy(g_si.commandKey, psi->commandKey, COMMAND_KEY_LEN);
+ g_si.delaytime = psi->delaytime;
+ g_si.cwmp = psi->cwmp;
+
+
+ cwmp_log_info("begin to create timer!");
+
+ long result = CreateSoftTimer(SECHEDULE_INFORM_TIMER, TIMER_FLAG_ONCE, psi->delaytime*1000, schedule_inform_timeout, &g_si);
+ g_si.timer_running = 1;
+ cwmp_log_info("end to create timer!");
+
+ cwmp_log_info("commandkey is:%s, delaytime:%d", psi->commandKey, psi->delaytime);
+
+ return CWMP_OK;
+}
+
+
+
+int cwmp_agent_retry_session(cwmp_session_t * session)
+{
+
+ int sec = 0;
+ int count = 1;
+
+ srand(time(NULL));
+ switch (session->retry_count)
+ {
+ case 0:
+ {
+ count = 5; //5~10
+ break;
+ }
+ case 1:
+ {
+ count = 10; //5~15
+ break;
+ }
+ case 2:
+ {
+ count = 20; //5~25
+ break;
+ }
+ default:
+ {
+ count = 30; //5~35
+ break;
+ }
+ }
+
+ sec = 5 + rand()% count;
+
+ while (sec>0)
+ {
+ sleep(1);
+ sec--;
+ }
+
+ if (session->retry_count > MAX_SESSION_RETRY)
+ {
+ session->retry_count = 0;
+ return CWMP_TIMEOUT;
+ }
+ else
+ {
+ session->retry_count ++;
+ return CWMP_OK;
+ }
+
+}
+
+
+int cwmp_agent_create_datetimes(datatime_t *nowtime)
+{
+ struct tm *t;
+ time_t tn;
+
+
+ //FUNCTION_TRACE();
+ tn = time(NULL);
+#ifdef WIN32
+ cwmp_log_debug("inform datatime");
+ //localtime_s(&t, &tn);
+ t = MALLOC(sizeof(struct tm));
+ memset(t, 0, sizeof(struct tm));
+#else
+ t = localtime(&tn);
+#endif
+
+ if(NULL != t)
+ {
+ nowtime->year = t->tm_year + 1900;
+ nowtime->month = t->tm_mon + 1;
+ nowtime->day = t->tm_mday;
+ nowtime->hour = t->tm_hour;
+ nowtime->min = t->tm_min;
+ nowtime->sec = t->tm_sec;
+ }
+ else
+ {
+ cwmp_log_error("localtime return null");
+ }
+
+ return CWMP_OK;
+}
+
+//È¡µÃactive eventÒÔ¼°count
+int cwmp_agent_get_active_event(cwmp_t *cwmp, cwmp_session_t * session, event_list_t **pevent_list)
+{
+ event_list_t * el;
+ event_code_t * ev;
+ int i=0;
+ FUNCTION_TRACE();
+
+ el = cwmp_create_event_list(session->env, INFORM_MAX);
+ if(NULL == el)
+ {
+ cwmp_log_error("el cwmp_create_event_list return NULL");
+ return CWMP_ERROR;
+ }
+
+ event_code_t ** pec = cwmp->el->events;
+
+ int elsize = cwmp->el->count;
+ for(i=0; i<elsize; i++)
+ {
+
+ if(pec[i] && pec[i]->ref > 0)
+ {
+
+ event_code_t * ec = pec[i];
+ ev = cwmp_create_event_code(session->env);
+ if(NULL == ev)
+ {
+ cwmp_log_error("ev cwmp_create_event_code return null");
+ return CWMP_ERROR;
+ }
+
+ ev->event = ec->event;
+ ev->code = ec->code;
+
+ if (pec[i]->event == INFORM_MREBOOT || pec[i]->event == INFORM_BOOTSTRAP)
+ {
+ strncpy(ev->command_key , ec->command_key, COMMAND_KEY_LEN);
+ }
+
+
+ el->events[el->count++] = ev;
+ ev = NULL;
+
+ }
+ }
+ if (el->count == 0)
+ {
+ ev = cwmp_create_event_code(session->env);
+ if(NULL == ev)
+ {
+ cwmp_log_error("ev cwmp_create_event_code return null");
+ return CWMP_ERROR;
+ }
+
+ ev->event = INFORM_BOOT;
+ ev->code = CWMP_INFORM_EVENT_CODE_1;
+ el->events[el->count++] = ev;
+ }
+
+ *pevent_list = el;
+
+ return CWMP_OK;
+}
+
+int cwmp_agent_send_request(cwmp_session_t * session)
+{
+ FUNCTION_TRACE();
+ return cwmp_session_send_request(session);
+}
+
+int cwmp_agent_recv_response(cwmp_session_t * session)
+{
+ return cwmp_session_recv_response(session);
+}
+
+void cwmp_agent_start_session(cwmp_t * cwmp)
+{
+ int rv;
+ cwmp_session_t * session;
+ int session_close = CWMP_NO;
+ xmldoc_t * newdoc;
+ FUNCTION_TRACE();
+ event_list_t *evtlist;
+
+ while (TRUE)
+ {
+ if (cwmp->new_request == CWMP_NO)
+ {
+ cwmp_log_debug("No new request from ACS\n");
+ sleep(2);
+ //cwmp->new_request = CWMP_YES;
+ continue;
+ }
+
+ cwmp_log_debug("New request from ACS\n");
+
+ cwmp_clean_periodic_inform(cwmp);
+
+ cwmp->new_request = CWMP_NO;
+ session = cwmp_session_create(cwmp);
+ if(NULL == session)
+ {
+ cwmp_log_error("session cwmp_session_create return NULL");
+ cwmp->new_request = CWMP_YES;
+ continue;
+ }
+
+ session_close = CWMP_NO;
+ session->timeout = cwmp_conf_get_int("cwmpd:http_timeout");
+ //cwmp_session_set_timeout(cwmp_conf_get_int("cwmpd:http_timeout"));
+ cwmp_log_debug("session timeout is %d", session->timeout);
+
+ cwmp_session_open(session);
+
+ while (!session_close)
+ {
+ //cwmp_log_debug("session status: %d", session->status);
+ switch (session->status)
+ {
+ case CWMP_ST_START:
+ //create a new connection to acs
+ cwmp_log_debug("session stutus: New START\n");
+
+ if (cwmp_session_connect(session, cwmp->acs_url) != CWMP_OK)
+ {
+ cwmp_log_error("connect to acs: %s failed.\n", cwmp->acs_url);
+ session->status = CWMP_ST_RETRY;
+ }
+ else
+ {
+ session->status = CWMP_ST_INFORM;
+ }
+ break;
+ case CWMP_ST_INFORM:
+ evtlist = NULL;
+ cwmp_log_debug("session stutus: INFORM\n");
+ cwmp_agent_get_active_event(cwmp, session, & evtlist);
+ if(evtlist != NULL)
+ {
+ cwmp_event_clear_active(cwmp);
+ }
+ else
+ {
+ cwmp_log_debug("evtlist is null");
+ session->status = CWMP_ST_EXIT;
+ break;
+ }
+
+ cwmp_log_debug("session stutus: INFORM2\n");
+ if (cwmp->acs_auth)
+ {
+ cwmp_session_set_auth(session, cwmp->acs_user, cwmp->acs_pwd );
+ }
+
+ cwmp_log_debug("session stutus: INFORM3\n");
+ newdoc = cwmp_session_create_inform_message(session, evtlist, session->envpool);
+
+ if(NULL != newdoc)
+ {
+ cwmp_write_doc_to_chunk(newdoc, session->writers, session->envpool);
+ session->last_method = CWMP_INFORM_METHOD;
+ session->status = CWMP_ST_SEND;
+ }
+ else
+ {
+ cwmp_log_error("newdoc is null");
+ session->last_method = CWMP_INFORM_METHOD;
+ session->status = CWMP_ST_EXIT;
+ }
+
+ break;
+
+ case CWMP_ST_SEND:
+
+ cwmp_log_debug("session stutus: SEND");
+ cwmp_log_debug("session data request length: %d", cwmp_chunk_length(session->writers));
+ session->newdata = CWMP_NO;
+
+ rv = cwmp_agent_send_request(session);
+
+ if (rv == CWMP_OK)
+ {
+ cwmp_log_debug("session data sended OK, rv=%d", rv);
+ session->status = CWMP_ST_RECV;
+ }
+ else
+ {
+ cwmp_log_debug("session data sended faild! rv=%d", rv);
+ session->status = CWMP_ST_EXIT;
+ /*
+ if (rv == CWMP_COULDNOT_CONNECT)
+ {
+ session->status = CWMP_ST_RETRY;
+ }
+ else
+ {
+ session->status = CWMP_ST_EXIT;
+ }
+ */
+ }
+
+ break;
+ case CWMP_ST_RECV:
+ cwmp_log_debug("session stutus: RECV");
+ cwmp_chunk_clear(session->readers);
+
+ rv = cwmp_agent_recv_response(session);
+
+ if (rv == CWMP_OK)
+ {
+ session->status = CWMP_ST_ANSLYSE;
+ }
+ else
+ {
+ session->status = CWMP_ST_END;
+ }
+ break;
+
+ case CWMP_ST_ANSLYSE:
+ cwmp_log_debug("session stutus: ANSLYSE");
+ rv = cwmp_agent_analyse_session(session);
+ if (rv == CWMP_OK)
+ {
+ session->status = CWMP_ST_SEND;
+ }
+ else
+ {
+ session->status = CWMP_ST_END;
+ }
+ break;
+ case CWMP_ST_RETRY:
+ cwmp_log_debug("session stutus: RETRY");
+ if (cwmp_agent_retry_session(session) == CWMP_TIMEOUT)
+ {
+ cwmp_log_debug("session retry timeover, go out");
+ session->status = CWMP_ST_EXIT;
+ }
+ else
+ {
+ session->status = CWMP_ST_START;
+ }
+ break;
+ case CWMP_ST_END:
+ //close connection of ACS
+ cwmp_log_debug("session stutus: END");
+ //run task from queue
+
+ if (session->newdata == CWMP_YES)
+ {
+ session->status = CWMP_ST_SEND;
+ }
+ else
+ {
+ session->status = CWMP_ST_EXIT;
+ }
+ break;
+
+ case CWMP_ST_EXIT:
+ cwmp_log_debug("session stutus: EXIT");
+ cwmp_session_close(session);
+ if (session->reconnect == CWMP_YES)
+ {
+ session->reconnect = CWMP_NO;
+ session->status = CWMP_ST_START;
+ break;
+ }
+ session_close = CWMP_YES;
+ break;
+
+
+ default:
+ cwmp_log_debug("Unknown session stutus");
+ break;
+ }//end switch
+ }//end while(!session_close)
+
+ cwmp_log_debug("session stutus: EXIT");
+ cwmp_session_free(session);
+ session = NULL;
+
+ cwmp->session_running = SESSION_NO_RUNNING;
+
+ int newtaskres = cwmp_agent_run_tasks(cwmp);
+ if(newtaskres == CWMP_YES)
+ {
+ cwmp->new_request = CWMP_YES;
+ }
+
+ cwmp_reset_periodic_inform(cwmp);
+
+ }//end while(TRUE)
+}
+
+void to_upper_case_substring(char *str, const char *substring)
+{
+ int i = 0;
+ char *found = strstr(str, substring);
+ int sub_len = strlen(substring);
+
+ while (found != NULL)
+ {
+ for (i = 0; i < sub_len; ++i)
+ {
+ found[i] = toupper((unsigned char)found[i]);
+ }
+ found = strstr(found + sub_len, substring);
+ }
+}
+
+int cwmp_agent_analyse_session(cwmp_session_t * session)
+{
+ pool_t * doctmppool = NULL;
+ char * xmlbuf;
+ char cwmp_id[10] = {0};
+ cwmp_uint32_t len;
+ xmldoc_t * doc;
+ char * method;
+ xmldoc_t * newdoc = NULL;
+ int rc = CWMP_OK;
+
+ static char * xml_fault = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\" xmlns=\"urn:dslforum-org:cwmp-1-0\"><SOAP-ENV:Body SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" id=\"_0\"><SOAP-ENV:Fault>Error Message</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>";
+
+ cwmp_uint32_t msglength = 0;
+
+ FUNCTION_TRACE();
+ if(NULL == session)
+ {
+ cwmp_log_error("session is null");
+ return CWMP_ERROR;
+ }
+
+ cwmp_t * cwmp = session->cwmp;
+ if(NULL == cwmp)
+ {
+ cwmp_log_error("cwmp is null");
+ return CWMP_ERROR;
+ }
+
+ msglength = cwmp_chunk_length(session->readers);
+ if (msglength<= 0)
+ {
+ session->newdata = CWMP_NO;
+ cwmp_log_debug("analyse receive length is 0");
+ goto eventcheck;
+// return CWMP_ERROR;
+ }
+
+ doctmppool = pool_create(POOL_DEFAULT_SIZE);
+ if(NULL == doctmppool)
+ {
+ cwmp_log_error("doctmppool is null");
+ return CWMP_ERROR;
+ }
+
+ xmlbuf = pool_palloc(doctmppool, msglength+32);
+ if(NULL == xmlbuf)
+ {
+ cwmp_log_error("xmlbuf is null");
+ return CWMP_ERROR;
+ }
+
+ len = sprintf(xmlbuf,"<cwmp>");
+ cwmp_chunk_copy(xmlbuf + len, session->readers, msglength);
+ strncpy(xmlbuf+len+msglength, "</cwmp>", 32-len-1);
+ strcpy(cwmp_id, "cwmp:ID");
+ to_upper_case_substring(xmlbuf, cwmp_id);
+
+ cwmp_log_debug("agent analyse xml: \n%s", xmlbuf);
+
+ doc = XmlParseBuffer(doctmppool, xmlbuf);
+ if (!doc)
+ {
+ cwmp_log_debug("analyse create doc null\n");
+ cwmp_chunk_write_string(session->writers, xml_fault, TRstrlen(xml_fault), session->envpool);
+ goto finished;
+
+ }
+
+ method = cwmp_get_rpc_method_name(doc);
+ cwmp_log_debug("analyse method is: %s\n", method);
+
+ cwmp_chunk_clear(session->writers);
+ pool_clear(session->envpool);
+
+ cwmp_log_info("----------------------------");
+
+ if (TRstrcmp(method, CWMP_RPC_GETRPCMETHODS) == 0)
+ {
+ newdoc = cwmp_session_create_getrpcmethods_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_INFORMRESPONSE) == 0)
+ {
+ newdoc = NULL;
+ }
+ else if (TRstrcmp(method, CWMP_RPC_GETPARAMETERNAMES) == 0)
+ {
+ newdoc = cwmp_session_create_getparameternames_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_GETPARAMETERVALUES) == 0)
+ {
+ newdoc = cwmp_session_create_getparametervalues_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_SETPARAMETERVALUES) == 0)
+ {
+ newdoc = cwmp_session_create_setparametervalues_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_DOWNLOAD) == 0)
+ {
+ newdoc = cwmp_session_create_download_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_UPLOAD) == 0)
+ {
+ newdoc = cwmp_session_create_upload_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_TRANSFERCOMPLETERESPONSE) == 0)
+ {
+ newdoc = NULL;
+ }
+ else if (TRstrcmp(method, CWMP_RPC_REBOOT) == 0)
+ {
+ newdoc = cwmp_session_create_reboot_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_ADDOBJECT) == 0)
+ {
+ newdoc = cwmp_session_create_addobject_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_DELETEOBJECT) == 0)
+ {
+ newdoc = cwmp_session_create_deleteobject_response_message(session, doc, doctmppool);
+ }
+
+ else if (TRstrcmp(method, CWMP_RPC_FACTORYRESET) == 0)
+ {
+ newdoc = cwmp_session_create_factoryreset_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_GETPARAMETERATTRIBUTES) == 0)
+ {
+ newdoc = cwmp_session_create_getparamterattributes_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_SETPARAMETERATTRIBUTES) == 0)
+ {
+ newdoc = cwmp_session_create_setparamterattributes_response_message(session, doc, doctmppool);
+ }
+ else if (TRstrcmp(method, CWMP_RPC_SCHEDULEINFORM) == 0)
+ {
+ schedule_inform_info_st si;
+ si.cwmp = session->cwmp;
+ newdoc = cwmp_session_create_scheduleinform_response_message(session, doc, doctmppool, &si);
+ int rc = schedule_inform_create_timer(&si);
+ }
+ else
+ {
+ //check event queue
+ //newdoc = cwmp_session_create_event_response_message(session, doc, doctmppool);
+ cwmp_log_info("unknown method type:%s", method);
+ }
+
+ cwmp_log_info("----------------------------");
+
+// cwmp_t * cwmp = session->cwmp;
+ if(newdoc == NULL)
+ {
+ cwmp_log_debug("agent analyse newdoc is null. ");
+
+eventcheck:
+ {
+
+ cwmp_log_debug("agent analyse begin check global event, %d", cwmp->event_global.event_flag);
+
+ //check global event for transfercomplete
+
+ if(cwmp->event_global.event_flag & EVENT_REBOOT_TRANSFERCOMPLETE_FLAG)
+ {
+ cwmp->event_global.event_flag &= ~EVENT_REBOOT_TRANSFERCOMPLETE_FLAG;
+ if(!doctmppool)
+ {
+ doctmppool = pool_create(POOL_DEFAULT_SIZE);
+ }
+
+ if(!doctmppool)
+ {
+ cwmp_log_error("doctmppool pool create return null");
+ return CWMP_ERROR;
+ }
+ event_code_t ec;
+ ec.event = INFORM_TRANSFERCOMPLETE;
+ TRstrncpy(ec.command_key, cwmp->event_global.event_key, COMMAND_KEY_LEN);
+ ec.fault_code = cwmp->event_global.fault_code;
+ ec.start = cwmp->event_global.start;
+ ec.end = cwmp->event_global.end;
+ newdoc = cwmp_session_create_transfercomplete_message(session, &ec, doctmppool);
+
+ }
+
+ }
+
+ }
+
+
+ cwmp_log_debug("newdoc %p, msglength: %d", newdoc, msglength );
+ if(newdoc != NULL) // || (newdoc == NULL && msglength == 0 && session->retry_count < 2))
+ {
+ session->newdata = CWMP_YES;
+ cwmp_write_doc_to_chunk(newdoc, session->writers, session->envpool);
+ rc = CWMP_OK;
+ }
+ else if(/*newdoc == NULL && */msglength != 0)
+ {
+ session->newdata = CWMP_YES;
+ cwmp_write_doc_to_chunk(newdoc, session->writers, session->envpool);
+ rc = CWMP_OK;
+ }
+ else
+ {
+ rc = CWMP_ERROR;
+ }
+
+finished:
+ if(doctmppool != NULL)
+ {
+ pool_destroy(doctmppool);
+ }
+
+ return rc;
+}
+
+
+
+static void print_param(parameter_node_t * param, int level)
+{
+ if(!param) return;
+
+ parameter_node_t * child;
+ char fmt[128];
+ //cwmp_log_debug("name: %s, type: %s, level: %d\n", param->name, cwmp_get_type_string(param->type), level);
+ int i=0;
+
+ snprintf(fmt, 127, "|%%-%ds%%s, get:%%p set:%%p refresh:%%p\n", level*4);
+
+ cwmp_log_debug_src(fmt, "----", param->name, param->get, param->set, param->refresh);
+
+ child = param->child;
+
+ if(!child)
+ return;
+ print_param(child, level+1);
+
+ parameter_node_t * next = child->next_sibling;
+
+ while(next)
+ {
+ print_param(next, level+1);
+ next = next->next_sibling;
+ }
+}
+
+
+
+void cwmp_agent_session(cwmp_t * cwmp)
+{
+ char name[1024] = {0};
+ char value[1024]= {0};
+ char local_ip[256];
+
+ char * envstr;
+ char * encstr;
+
+ envstr = "SOAP-ENV"; //cwmp_conf_get("cwmp:soap_env");
+ encstr = "SOAP-ENC"; // cwmp_conf_get("cwmp:soap_enc");
+
+ cwmp_set_envelope_ns(envstr, encstr);
+
+#if 0
+ if (cwmp_session_get_localip(local_ip) == -1)
+ {
+ cwmp_log_error("get local ip error. exited.\n");
+ exit(-1);
+ }
+#else
+ cwmp_session_get_localip(local_ip);
+#endif
+
+ print_param(cwmp->root, 0);
+
+ CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, ManagementServerModule, URLModule);
+ cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->acs_url, TRstrlen(cwmp->acs_url), cwmp->pool);
+
+ CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, ManagementServerModule, ConnectionRequestURLModule);
+ TRsnprintf(value, 1024, "http://%s:%d", local_ip, cwmp->httpd_port);
+ cwmp_data_set_parameter_value(cwmp, cwmp->root, name, value, TRstrlen(value), cwmp->pool);
+ cwmp_log_debug("set request name:%s, value:%s", name, value);
+
+
+ CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, ManufacturerModule);
+ cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_mf, TRstrlen(cwmp->cpe_mf), cwmp->pool);
+
+
+ CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, ManufacturerOUIModule);
+ cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_oui, TRstrlen(cwmp->cpe_oui), cwmp->pool);
+
+ CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, ProductClassModule);
+ cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_pc, TRstrlen(cwmp->cpe_pc), cwmp->pool);
+
+ CWMP_SPRINTF_PARAMETER_NAME(name, 3, InternetGatewayDeviceModule, DeviceInfoModule, SerialNumberModule);
+ cwmp_data_set_parameter_value(cwmp, cwmp->root, name, cwmp->cpe_sn, TRstrlen(cwmp->cpe_sn), cwmp->pool);
+
+
+ cwmp_agent_start_session(cwmp);
+}
+
+
+/*
+int cwmp_agent_download_file(download_arg_t * dlarg)
+{
+ int faultcode = 0;
+ char url[255];
+ if (TRstrncasecmp(dlarg->url, "ftp://", 6) == 0)
+ {
+ if (dlarg->username != NULL && strlen(dlarg->username) != 0)
+ {
+ TRsnprintf(url, 255, "ftp://%s:%s@%s", dlarg->username, dlarg->password, dlarg->url+6);
+ }
+ else
+ {
+ TRstrncpy(url, dlarg->url, 255);
+ }
+ }
+ else
+ {
+ TRstrncpy(url, dlarg->url, 255);
+ }
+
+ fetchIO * downfile = fetchGetURL(url, "");
+ if (!downfile)
+ {
+ cwmp_log_debug("download file fail: %s", url);
+ faultcode = 9001;
+ }
+ else
+ {
+ char readbuf[1024];
+ int readlen;
+ char targetfile[64];
+ if (dlarg->targetname != NULL && strlen(dlarg->targetname) != 0)
+ {
+ TRsnprintf(targetfile, 64, "/tmp/%s", dlarg->targetname);
+ }
+ else
+ {
+ TRsnprintf(targetfile, 64, "/tmp/%d.file", time(NULL));
+ }
+ FILE * df = fopen(targetfile, "wb+");
+ while (df != NULL)
+ {
+ readlen = fetchIO_read(downfile, readbuf, 1023);
+ if (readlen <= 0)
+ {
+ cwmp_log_debug("fetch io read zero. %s", readlen);
+ break;
+ }
+ readbuf[readlen] = 0;
+ fwrite(readbuf, readlen, 1, df);
+ }
+
+ if (df)
+ {
+ fclose(df);
+ }
+ else
+ {
+ faultcode = 9001;
+ }
+
+ cwmp_log_debug("download file ok: %s, %s", url, targetfile);
+
+
+ fetchIO_close(downfile);
+ }
+
+
+ return faultcode;
+
+}
+
+
+
+int cwmp_agent_upload_file(upload_arg_t * ularg)
+{
+ int faultcode = 0;
+ char url[255];
+
+ if (TRstrncasecmp(ularg->url, "ftp://", 6) == 0)
+ {
+ if (ularg->username != NULL && strlen(ularg->username) != 0)
+ {
+ TRsnprintf(url, 255, "ftp://%s:%s@%s", ularg->username, ularg->password, ularg->url+6);
+ }
+ else
+ {
+ TRstrncpy(url, ularg->url, 255);
+ }
+ }
+ else
+ {
+ TRstrncpy(url, ularg->url, 255);
+ }
+
+ fetchIO * uploadfile = fetchPutURL(url, "");
+ if (!uploadfile)
+ {
+ cwmp_log_debug("upload file fail: %s", url);
+ faultcode = 9001;
+ }
+ else
+ {
+ char readbuf[1024];
+ int readlen;
+ char targetfile[64];
+ FILE * uf;
+ int rc;
+ if(strcmp(ularg->filetype, "1 Vendor Configuration File") == 0)
+ {
+ //¸ù¾Ýʵ¼ÊÇé¿ö, ÐÞ¸ÄÕâÀïµÄÅäÖÃÎļþ·¾¶
+
+ uf = fopen("/tmp/mysystem.cfg", "rb");
+ }
+ else if(strcmp(ularg->filetype, "2 Vendor Log File") == 0)
+ {
+ //¸ù¾Ýʵ¼ÊÇé¿ö, ÐÞ¸ÄÕâÀïµÄÅäÖÃÎļþ·¾¶
+ uf = fopen("/tmp/mysystem.log", "rb");
+ }
+ else
+ {
+ uf = fopen("/tmp/mysystem.log", "rb");
+ }
+
+
+ while (uf != NULL)
+ {
+ readlen = fread(readbuf, 1024, 1, uf);
+ if (readlen <= 0)
+ {
+ cwmp_log_debug("fetch io read zero. %s", readlen);
+
+ break;
+ }
+ readbuf[readlen] = 0;
+
+ rc = fetchIO_write(uploadfile, readbuf, readlen);
+ if(rc <= 0)
+ {
+ faultcode = 9001;
+ break;
+ }
+
+ }
+
+ if(uf)
+ {
+ fclose(uf);
+ }
+ else
+ {
+ faultcode = 9001;
+ }
+
+
+
+ cwmp_log_debug("upload file finished: %s, file:%s", url, targetfile);
+
+
+ fetchIO_close(uploadfile);
+ }
+
+
+ return faultcode;
+
+}
+*/
+
+
+
+int cwmp_agent_download_file(download_arg_t * dlarg)
+{
+ int faultcode = 0;
+ char * fromurl = dlarg->url;
+
+ char tofile[256+1] = {0};
+ char downloadroot[256+1] = {0};
+
+ FUNCTION_TRACE();
+
+ if(!fromurl)
+ {
+ cwmp_log_error("download src file path is null!");
+ return 9001;
+ }
+
+ if(NULL == dlarg->targetname)
+ {
+ if(TRstrcmp(dlarg->filetype, "1 Firmware Upgrade Image") == 0)
+ {
+ cwmp_conf_get("file:download_img_path", tofile);
+ }
+ else if(TRstrcmp(dlarg->filetype, "3 Vendor Configuration File") == 0)
+ {
+ cwmp_conf_get("file:download_cfg_path", tofile);
+ }
+ else
+ {
+ cwmp_conf_get("file:download_unknown_path", tofile);
+ }
+ }
+ else
+ {
+ cwmp_conf_get("file:download_root", downloadroot);
+ TRsnprintf(tofile, 256, "%s/%s", downloadroot, dlarg->targetname);
+ }
+
+ cwmp_log_info("file type:%s, save file(%s) to path:%s", dlarg->filetype, fromurl, tofile);
+
+ if(/*dlarg->url &&*/ TRstrncasecmp("ftp://", dlarg->url, 6) == 0)
+ {
+ cwmp_log_debug("Download url:%s", dlarg->url);
+ return 9001;
+ }
+
+ faultcode = http_receive_file(fromurl, tofile);
+
+ if(faultcode != CWMP_OK)
+ {
+ cwmp_log_debug("faultcode:%d", faultcode);
+ faultcode = 9001;
+ }
+
+ return faultcode;
+}
+
+
+
+int cwmp_agent_upload_file(upload_arg_t * ularg)
+{
+ int faultcode = 0;
+ FUNCTION_TRACE();
+ char * fromfile;
+
+ char cfg_path[256] = {0};
+ char log_path[256] = {0};
+
+ FUNCTION_TRACE();
+
+ cwmp_conf_get("file:upload_cfg_path", cfg_path);
+ cwmp_conf_get("file:upload_log_path", log_path);
+
+ if(TRstrcmp(ularg->filetype, "1 Vendor Configuration File") == 0)
+ {
+ fromfile = cfg_path;
+ }
+ else if(TRstrcmp(ularg->filetype, "2 Vendor Log File") == 0)
+ {
+ fromfile = log_path;
+ }
+ else
+ {
+ fromfile = cfg_path;
+ }
+
+ cwmp_log_info("upload type:%s, send file:%s, url:%s", ularg->filetype, fromfile, ularg->url);
+
+
+ faultcode = http_send_file(fromfile, ularg->url);
+
+ if(faultcode != CWMP_OK)
+ {
+ cwmp_log_error("http send file return[%d], not CWMP_OK, set faultcode 9001", faultcode);
+ faultcode = 9001;
+ }
+
+ return faultcode;
+}
+
+
+
+int cwmp_agent_run_tasks(cwmp_t * cwmp)
+{
+ void * data;
+ int tasktype = 0;;
+ int ok = CWMP_NO;
+ int rc = 0;
+
+ FUNCTION_TRACE();
+
+ while(1)
+ {
+ tasktype = queue_pop(cwmp->queue, &data);
+ if(tasktype == -1)
+ {
+ cwmp_log_debug("no more task to run");
+ break;
+ }
+ ok = CWMP_YES;
+ switch(tasktype)
+ {
+ case TASK_DOWNLOAD_TAG:
+ {
+ cwmp_log_debug("Download begin.....");
+
+ download_arg_t * dlarg = (download_arg_t*)data;
+ //begin download file
+ time_t starttime = time(NULL);
+ int faultcode = 0;
+
+ faultcode = cwmp_agent_download_file(dlarg);
+
+ time_t endtime = time(NULL);
+ cwmp_event_set_value(cwmp, INFORM_TRANSFERCOMPLETE, 1,dlarg->cmdkey, faultcode, starttime, endtime);
+
+
+ FREE(dlarg);
+
+ cwmp_log_debug("Download OK.....");
+ }
+ break;
+
+ case TASK_UPLOAD_TAG:
+ {
+ cwmp_log_debug("Upload begin.....");
+
+ upload_arg_t * ularg = (upload_arg_t*)data;
+ //begin download file
+ time_t starttime = time(NULL);
+ int faultcode = 0;
+
+ faultcode = cwmp_agent_upload_file(ularg);
+
+ time_t endtime = time(NULL);
+ cwmp_event_set_value(cwmp, INFORM_TRANSFERCOMPLETE, 1,ularg->cmdkey, faultcode, starttime, endtime);
+
+
+ FREE(ularg);
+
+ cwmp_log_debug("Upload OK.....");
+ }
+ break;
+
+ case TASK_REBOOT_TAG:
+ {
+ //begin reboot system
+ cwmp_log_debug("reboot ...");
+ cwmp_event_set_value(cwmp, INFORM_MREBOOT, 1, NULL, 0, 0, 0);
+ cwmp_event_clear_active(cwmp);
+
+ // inorder to save file ok
+
+ sleep(20);
+
+ rc = restart_request(MODULE_ID_TR069);
+
+ if(0 != rc)
+ {
+ cwmp_log_info("restart request fail! rc:%d", rc);
+ }
+ }
+ break;
+
+ case TASK_FACTORYRESET_TAG:
+ {
+ //begin factory reset system
+ cwmp_log_debug("factory reset begin...");
+
+ cwmp_event_clear_active(cwmp);
+
+ rc = reset_request(MODULE_ID_TR069);
+
+ if(0 != rc)
+ {
+ cwmp_log_info("reset request fail! rc:%d", rc);
+ }
+
+
+ cwmp_log_debug("factory reset OK.....");
+ }
+ break;
+
+ default:
+
+ break;
+
+ }
+ }
+
+ return ok;
+}
+
+
+
+
+
+
diff --git a/lynq/R305/ap/app/cwmp/netcwmp/libcwmp/include/cwmp/cwmp.h b/lynq/R305/ap/app/cwmp/netcwmp/libcwmp/include/cwmp/cwmp.h
new file mode 100755
index 0000000..117edf1
--- /dev/null
+++ b/lynq/R305/ap/app/cwmp/netcwmp/libcwmp/include/cwmp/cwmp.h
@@ -0,0 +1,589 @@
+/************************************************************************
+ * *
+ * Netcwmp Project *
+ * *
+ * A software client for enabling TR-069 in embedded devices (CPE). *
+ * *
+ * Copyright (C) 2013-2014 netcwmp.netcwmp group *
+ * *
+ * Copyright 2013-2014 Mr.x() <netcwmp@gmail.com> *
+ * *
+ ***********************************************************************/
+
+#ifndef __CWMP_H__
+#define __CWMP_H__
+
+#include <cwmp/xmlet.h>
+#include <cwmp/types.h>
+#include <cwmp/util.h>
+#include <cwmp/memory.h>
+#include <cwmp/buffer.h>
+#include <cwmp/event.h>
+#include <cwmp/queue.h>
+
+
+#define ASSERT assert
+#define XMLCAST(x) ((XmlChar *)(x))
+
+
+
+
+
+
+#define CWMP_HEAD_MAX 64
+#define CWMP_NAME_MAX 64
+#define CWMP_PARAMVALUE_SIZE 512
+
+#define SOAP_ENV_NS "http://schemas.xmlsoap.org/soap/envelope/"
+#define SOAP_ENC_NS "http://schemas.xmlsoap.org/soap/encoding/"
+#define SOAP_XSI_NS "http://www.w3.org/2001/XMLSchema-instance"
+#define SOAP_XSD_NS "http://www.w3.org/2001/XMLSchema"
+#define SOAP_CWMP_NS "urn:dslforum-org:cwmp-1-0"
+
+
+
+#define SOAP_ENV_DEFAULT "SOAP-ENV"
+#define SOAP_ENC_DEFAULT "SOAP-ENC"
+#define SOAP_XML_HEADER "Header"
+#define SOAP_XML_BODY "Body"
+#define SOAP_XML_ENVELOPE "Envelope"
+#define SOAP_XML_FAULT "Fault"
+
+
+
+#define CWMP_XML_HEADER_ID "cwmp:ID"
+#define CWMP_XML_HEADER_HOLDREQUESTS "cwmp:HoldRequests"
+#define CWMP_XML_HEADER_NOMOREREQUESTS "cwmp:NoMoreRequests"
+#define CWMP_XML_INFORM_MAXENVELOPES "MaxEnvelopes"
+#define CWMP_XML_GETPARAMETERNAMES_PARAMETERPATH "ParameterPath"
+#define CWMP_XML_GETPARAMETERNAMES_NEXTLEVEL "NextLevel"
+#define CWMP_XML_COMMANDKEY "CommandKey"
+
+
+
+#define SOAP_XSI_TYPE "xsi:type"
+#define SOAP_XSI_NAME "xsi:name"
+
+#define SOAP_XSD_STRING "xsd:string"
+#define SOAP_XSD_UNSIGNEDINT "xsd:unsignedInt"
+#define SOAP_XSD_ANY "xsd:any"
+#define SOAP_XSD_DATETIME "xsd:dateTime"
+#define SOAP_TYPE_ARRAYTYPE "arrayType"
+
+
+
+#define CWMP_XML_MUSTUNDERSTAND "mustUnderstand"
+
+#define CWMP_RPC_INFORM "cwmp:Inform"
+#define CWMP_RPC_INFORMRESPONSE "cwmp:InformResponse"
+#define CWMP_RPC_GETPARAMETERNAMES "cwmp:GetParameterNames"
+#define CWMP_RPC_GETPARAMETERNAMESRESPONSE "cwmp:GetParameterNamesResponse"
+#define CWMP_RPC_GETPARAMETERVALUES "cwmp:GetParameterValues"
+#define CWMP_RPC_GETPARAMETERVALUESRESPONSE "cwmp:GetParameterValuesResponse"
+#define CWMP_RPC_SETPARAMETERVALUES "cwmp:SetParameterValues"
+#define CWMP_RPC_SETPARAMETERVALUESRESPONSE "cwmp:SetParameterValuesResponse"
+#define CWMP_RPC_GETRPCMETHODS "cwmp:GetRPCMethods"
+#define CWMP_RPC_GETRPCMETHODSRESPONSE "cwmp:GetRPCMethodsResponse"
+#define CWMP_RPC_DOWNLOAD "cwmp:Download"
+#define CWMP_RPC_DOWNLOADRESPONSE "cwmp:DownloadResponse"
+#define CWMP_RPC_UPLOAD "cwmp:Upload"
+#define CWMP_RPC_UPLOADRESPONSE "cwmp:UploadResponse"
+#define CWMP_RPC_REBOOT "cwmp:Reboot"
+#define CWMP_RPC_REBOOTRESPONSE "cwmp:RebootResponse"
+#define CWMP_RPC_ADDOBJECT "cwmp:AddObject"
+#define CWMP_RPC_ADDOBJECTRESPONSE "cwmp:AddObjectResponse"
+#define CWMP_RPC_DELETEOBJECT "cwmp:DeleteObject"
+#define CWMP_RPC_DELETEOBJECTRESPONSE "cwmp:DeleteObjectResponse"
+#define CWMP_RPC_TRANSFERCOMPLETE "cwmp:TransferComplete"
+#define CWMP_RPC_TRANSFERCOMPLETERESPONSE "cwmp:TransferCompleteResponse"
+#define CWMP_RPC_FACTORYRESET "cwmp:FactoryReset"
+#define CWMP_RPC_FACTORYRESETRESPONSE "cwmp:FactoryResetResponse"
+
+#define CWMP_RPC_GETPARAMETERATTRIBUTES "cwmp:GetParameterAttributes"
+#define CWMP_RPC_GETPARAMETERATTRIBUTESRESPONSE "cwmp:GetParameterAttributesResponse"
+#define CWMP_RPC_SETPARAMETERATTRIBUTES "cwmp:SetParameterAttributes"
+#define CWMP_RPC_SETPARAMETERATTRIBUTESRESPONSE "cwmp:SetParameterAttributesResponse"
+
+#define CWMP_RPC_SCHEDULEINFORM "cwmp:ScheduleInform"
+#define CWMP_RPC_SCHEDULEINFORMRESPONSE "cwmp:ScheduleInformResponse"
+
+
+
+#define CWMP_INFORM_EVENT_CODE_0 "0 BOOTSTRAP"
+#define CWMP_INFORM_EVENT_CODE_1 "1 BOOT"
+#define CWMP_INFORM_EVENT_CODE_2 "2 PERIODIC"
+#define CWMP_INFORM_EVENT_CODE_3 "3 SCHEDULED"
+#define CWMP_INFORM_EVENT_CODE_4 "4 VALUE CHANGE"
+#define CWMP_INFORM_EVENT_CODE_5 "5 KICKED"
+#define CWMP_INFORM_EVENT_CODE_6 "6 CONNECTION REQUEST"
+#define CWMP_INFORM_EVENT_CODE_7 "7 TRANSFER COMPLETE"
+#define CWMP_INFORM_EVENT_CODE_8 "8 DIAGNOSTICS COMPLETE"
+#define CWMP_INFORM_EVENT_CODE_9 "9 REQUEST DOWNLOAD"
+#define CWMP_INFORM_EVENT_CODE_10 "10 AUTONOMOUS TRANSFER COMPLETE"
+#define CWMP_INFORM_EVENT_CODE_11 "M Reboot"
+#define CWMP_INFORM_EVENT_CODE_12 "M ScheduleInform"
+#define CWMP_INFORM_EVENT_CODE_13 "M Download"
+#define CWMP_INFORM_EVENT_CODE_14 "M Upload"
+#define CWMP_INFORM_EVENT_CODE_15 "M X_0_AccountChanged"
+#define CWMP_INFORM_EVENT_CODE_16 "M 16"
+#define CWMP_INFORM_EVENT_CODE_17 "M 17"
+
+#define FAULT_CODE_OK 0
+#define FAULT_CODE_9000 9000
+#define FAULT_CODE_9001 9001
+#define FAULT_CODE_9002 9002
+#define FAULT_CODE_9003 9003
+#define FAULT_CODE_9004 9004
+#define FAULT_CODE_9005 9005
+#define FAULT_CODE_9006 9006
+#define FAULT_CODE_9007 9007
+#define FAULT_CODE_9008 9008
+#define FAULT_CODE_9009 9009
+#define FAULT_CODE_9010 9010
+#define FAULT_CODE_9011 9011
+#define FAULT_CODE_9012 9012
+#define FAULT_CODE_9013 9013
+#define FAULT_CODE_9014 9014
+#define FAULT_CODE_9015 9015
+#define FAULT_CODE_9016 9016
+#define FAULT_CODE_9017 9017
+#define FAULT_CODE_9018 9018
+#define FAULT_CODE_9019 9019
+
+
+
+#define FAULT_STR_9000 "Method not supported"
+#define FAULT_STR_9001 "Request denied"
+#define FAULT_STR_9002 "Internal error"
+#define FAULT_STR_9003 "Invalid arguments"
+#define FAULT_STR_9004 "Resources exceeded"
+#define FAULT_STR_9005 "Invalid parameter name"
+#define FAULT_STR_9006 "Invalid parameter type"
+#define FAULT_STR_9007 "Invalid parameter value"
+#define FAULT_STR_9008 "Attempt to set a non-writable parameter"
+#define FAULT_STR_9009 "Notification request rejected"
+#define FAULT_STR_9010 "Download failure"
+#define FAULT_STR_9011 "Upload failure"
+#define FAULT_STR_9012 "File transfer server authentication failure"
+#define FAULT_STR_9013 "Unsupported protocol for file transfer"
+#define FAULT_STR_9014 "Download failure: unable to join multicast group"
+#define FAULT_STR_9015 "Download failure: unable to contact file server"
+#define FAULT_STR_9016 "Download failure: unable to access file"
+#define FAULT_STR_9017 "Download failure: unable to complete download"
+#define FAULT_STR_9018 "Download failure: file corrupted"
+#define FAULT_STR_9019 "Download failure: file authentication failure"
+
+#define FAULT_STRING(x) cwmp_get_fault_string(x)
+
+
+#define InternetGatewayDeviceModule "InternetGatewayDevice"
+#define DeviceSummaryModule "DeviceSummary"
+#define DeviceInfoModule "DeviceInfo"
+
+#define ManufacturerModule "Manufacturer"
+#define ManufacturerOUIModule "ManufacturerOUI"
+#define ProductClassModule "ProductClass"
+#define DescriptionModule "Description"
+#define SerialNumberModule "SerialNumber"
+#define SpecVersionModule "SpecVersion"
+#define HardwareVersionModule "HardwareVersion"
+#define SoftwareVersionModule "SoftwareVersion"
+#define ProvisioningCodeModule "ProvisioningCode"
+#define UpTimeModule "UpTime"
+#define DeviceLogModule "DeviceLog"
+
+
+#define ManagementServerModule "ManagementServer"
+#define URLModule "URL"
+#define UsernameModule "Username"
+#define PasswordModule "Password"
+#define PeriodicInformIntervalModule "PeriodicInformInterval"
+#define PeriodicInformTimeModule "PeriodicInformTime"
+#define PeriodicInformEnableModule "PeriodicInformEnable"
+#define ParameterKeyModule "ParameterKey"
+#define ConnectionRequestURLModule "ConnectionRequestURL"
+#define ConnectionRequestUsernameModule "ConnectionRequestUsername"
+#define ConnectionRequestPasswordModule "ConnectionRequestPassword"
+#define UpgradesManagedModule "UpgradesManaged"
+#define UDPConnectionRequestAddressModule "UDPConnectionRequestAddress"
+#define STUNEnableModule "STUNEnable"
+#define STUNServerAddressModule "STUNServerAddress"
+#define STUNServerPortModule "STUNServerPort"
+#define STUNUsernameModule "STUNUsernameb"
+#define STUNPasswordModule "STUNPassword"
+#define NATDetectedModule "NATDetected"
+
+
+#define DeviceConfigModule "DeviceConfig"
+#define PersistentDataModule "PersistentData"
+#define ConfigFileModule "ConfigFile"
+
+
+#define TimeModule "Time"
+#define NTPServer1Module "NTPServer1"
+#define NTPServer2Module "NTPServer2"
+#define CurrentLocalTimeModule "CurrentLocalTime"
+#define LocalTimeZoneModule "LocalTimeZone"
+#define LocalTimeZoneNameModule "LocalTimeZoneName"
+#define DaylightSavingsUsedModule "DaylightSavingsUsed"
+#define DaylightSavingsStartModule "DaylightSavingsStart"
+#define DaylightSavingsEndModule "DaylightSavingsEnd"
+
+
+#define DeviceSummaryModule "DeviceSummary"
+
+#define WANDeviceModule "WANDevice"
+
+#define WANConnectionDeviceModule "WANConnectionDevice"
+#define WANIPConnectionModule "WANIPConnection"
+#define ExternalIPAddressModule "ExternalIPAddress"
+
+
+
+
+
+
+
+
+typedef enum
+{
+ CWMP_EMPTY_METHOD,
+ CWMP_INFORM_METHOD,
+ CWMP_INFORMRESPONSE_METHOD,
+ CWMP_GETPARAMETERNAMES_METHOD,
+ CWMP_GETPARAMETERNAMESRESPONSE_METHOD,
+ CWMP_GETPARAMETERVALUES_METHOD,
+ CWMP_GETPARAMETERVALUESRESPONSE_METHOD,
+ CWMP_SETPARAMETERVALUES_METHOD,
+ CWMP_SETPARAMETERVALUESRESPONSE_METHOD,
+ CWMP_GETRPCMETHODS_METHOD,
+ CWMP_GETRPCMETHODSRESPONSE_METHOD,
+ CWMP_DOWNLOAD_METHOD,
+ CWMP_DOWNLOADRESPONSE_METHOD,
+ CWMP_UPLOAD_METHOD,
+ CWMP_UPLOADRESPONSE_METHOD,
+ CWMP_REBOOT_METHOD,
+ CWMP_REBOOTRESPONSE_METHOD,
+ CWMP_ADDOBJECT_METHOD,
+ CWMP_ADDOBJECTRESPONSE_METHOD,
+ CWMP_DELETEOBJECT_METHOD,
+ CWMP_DELETEOBJECTRESPONSE_METHOD
+
+
+}cwmp_method_t;
+
+
+
+
+enum cwmp_type_t
+{
+ TYPE_OBJECT=0, //obj
+ TYPE_INT, //int
+ TYPE_UNSIGNEDINT, //uint
+ TYPE_STRING, //s
+ TYPE_STRING16, //s16
+ TYPE_STRING32, //s32
+ TYPE_STRING64, //s64
+ TYPE_STRING128, //s128
+ TYPE_STRING256, //s256
+ TYPE_STRING1024, //s1024
+ TYPE_DATETIME, //dt
+ TYPE_BOOLEAN, //bool
+ TYPE_BASE64, //base
+ TYPE_ANY,
+ TYPE_UNKNOWN
+};
+
+enum InformEventType
+{
+ INFORM_BOOTSTRAP = 0,
+ INFORM_BOOT,
+ INFORM_PERIODIC,
+ INFORM_SCHEDULED,
+ INFORM_VALUECHANGE,
+ INFORM_KICKED,
+ INFORM_CONNECTIONREQUEST,
+ INFORM_TRANSFERCOMPLETE,
+ INFORM_DIAGNOSTICSCOMPLETE,
+ INFORM_REQUESTDOWNLOAD,
+ INFORM_AUTONOMOUSTRANSFERCOMPLETE,
+ INFORM_MREBOOT,
+ INFORM_MSCHEDULEINFORM,
+ INFORM_MDOWNLOAD,
+ INFORM_MUPLOAD,
+ INFORM_ACCOUNTCHANGE,
+ INFORM_MVENDORSPECRPC,
+ INFORM_XOUIEVENT,
+ INFORM_MAX
+};
+
+#define SESSION_RUNNING (1)
+#define SESSION_NO_RUNNING (0)
+
+typedef struct datatime_st
+{
+ unsigned int year;
+ unsigned int month;
+ unsigned int day;
+ unsigned int hour;
+ unsigned int min;
+ unsigned int sec;
+}datatime_st;
+
+
+typedef struct periodic_info_st
+{
+ int PeriodicInformEnable;
+ int PeriodicInformInterval;
+ datatime_st PeriodicInformTime;
+
+}periodic_info_st;
+
+
+
+struct cwmp_st
+{
+ cwmp_t * old_cwmp;
+ int new_request;
+ int httpd_port;
+
+ int cpe_auth;
+ int acs_auth;
+
+ char * acs_url;
+ char * cpe_mf;
+ char * cpe_oui;
+ char * cpe_sn;
+ char * cpe_pc;
+ char * cpe_name;
+
+ char * acs_user;
+ char * acs_pwd;
+ char * cpe_user;
+ char * cpe_pwd;
+
+ char * event_filename;
+
+ pthread_mutex_t event_mutex;
+
+ event_list_t * el;
+
+ int event_count;
+
+ event_global_t event_global;
+
+ transfer_t transfer_info; //ÓÃÓÚDownloadºÍUpload
+
+ queue_t * queue;
+
+ pool_t * pool;
+ parameter_node_t * root;
+
+ int session_running;
+
+
+
+#ifdef USE_CWMP_OPENSSL
+ SSL_CTX * ssl_ctx;
+#endif
+
+ int boot_flag;
+
+ periodic_info_st periodic_info;
+};
+
+
+
+
+typedef struct parameter_node_attr_st
+{
+ cwmp_byte_t type; /* 0:single 1:multi */
+ cwmp_byte_t nc; /* Notification,0:off,1:passive,2:active */
+ cwmp_uint64_t acl; /* access list */
+ cwmp_uint64_t ext;
+}parameter_node_attr_st;
+
+#define PARAMETER_NODE_V_PADDING 0,0,0,0,0
+
+struct parameter_node_st
+{
+ char * name;
+ cwmp_byte_t rw; //read / writable
+ cwmp_byte_t type;
+
+ size_t value_length;
+ char * value;
+ parameter_node_attr_t attr;
+
+ parameter_node_t * parent;
+ parameter_node_t * child;
+ parameter_node_t * prev_sibling;
+ parameter_node_t * next_sibling;
+
+ parameter_get_handler_pt get;
+ parameter_set_handler_pt set;
+ parameter_notify_handler_pt notify;
+ parameter_add_handler_pt add;
+ parameter_del_handler_pt del;
+ parameter_refresh_handler_pt refresh;
+
+
+
+ cwmp_uint32_t max;
+ cwmp_uint32_t ext1;
+ cwmp_uint32_t ext2;
+ cwmp_uint32_t ext3;
+ cwmp_uint32_t ext4;
+
+};
+
+
+
+
+
+struct download_arg_st
+{
+ char *cmdkey;
+ char *filetype;
+ char *url;
+ char *username;
+ char *password;
+ char *targetname;
+ char *succurl;
+ char *failurl;
+ unsigned int delaysec;
+ unsigned int filesize;
+};
+
+
+struct upload_arg_st
+{
+ char *cmdkey;
+ char *filetype;
+ char *url;
+ char *username;
+ char *password;
+ unsigned int delaysec;
+};
+
+
+struct fault_code_st
+{
+ int fault_code;
+ char * fault_string;
+};
+
+
+
+typedef struct schedule_inform_info_st
+{
+ cwmp_t * cwmp;
+
+ int delaytime;
+ char commandKey[COMMAND_KEY_LEN+1];
+ int timer_running;
+}schedule_inform_info_st;
+
+
+
+typedef struct envelope_t envelope_t;
+
+
+void cwmp_set_envelope_ns(const char * envstr, const char * encstr);
+
+
+char * cwmp_xml_get_node_attribute(xmlnode_t * node, const char * name);
+
+
+parameter_list_t* cwmp_create_parameter_list(env_t * env );
+
+parameter_t* cwmp_create_parameter(env_t * env , const char * name, const char * value, size_t value_length, int type);
+parameter_t* cwmp_create_parameter_ex(env_t * env , const char * name, const char * value, size_t value_length, int type, parameter_node_attr_t *attr);
+
+
+
+int cwmp_create_parameter_node(env_t * env , parameter_node_t ** news, const char * name);
+
+download_arg_t * cwmp_clone_download_arg(download_arg_t * dlarg);
+upload_arg_t * cwmp_clone_upload_arg(upload_arg_t * ularg);
+
+xmldoc_t* cwmp_create_inform_message(env_t * env , header_t * header,
+ device_id_t * deviceid,
+ event_list_t *events,
+ datatime_t * currentt,
+ unsigned int max_envelope,
+ unsigned int retry_count,
+ parameter_list_t * pl);
+
+xmldoc_t* cwmp_create_getparameternames_response_message(env_t * env ,
+ header_t * header,
+ const char * path_name,
+ parameter_node_t * node,
+ unsigned int next_subset,
+ unsigned int next_level);
+
+xmldoc_t * cwmp_create_getparametervalues_response_message(env_t * env ,
+ header_t * header,
+ parameter_list_t * pl);
+
+xmldoc_t * cwmp_create_setparametervalues_response_message(env_t * env ,
+ header_t * header,
+ unsigned int status);
+
+xmldoc_t * cwmp_create_getrpcmethods_response_message(env_t * env ,
+ header_t * header,
+ char ** methods,
+ unsigned int count);
+
+xmldoc_t * cwmp_create_reboot_response_message(env_t * env ,
+ header_t * header);
+
+xmldoc_t * cwmp_create_download_response_message(env_t * env , header_t * header, int status);
+xmldoc_t * cwmp_create_upload_response_message(env_t * env , header_t * header, int status);
+xmldoc_t * cwmp_create_transfercomplete_message(env_t * env , header_t * header, event_code_t * evcode);
+xmldoc_t * cwmp_create_addobject_response_message(env_t * env , header_t * header, int instances, int status);
+xmldoc_t * cwmp_create_deleteobject_response_message(env_t * env , header_t * header, int status);
+xmldoc_t * cwmp_create_faultcode_response_message(env_t * env , header_t * header, fault_code_t * fault);
+xmldoc_t * cwmp_create_faultcode_setparametervalues_response_message(env_t * env , header_t * header, parameter_list_t * param_list, fault_code_t * fault);
+xmldoc_t * cwmp_create_factoryreset_response_message(env_t * env , header_t * header);
+
+event_code_t * cwmp_create_event_code(env_t * env );
+event_list_t * cwmp_create_event_list(env_t * env, int size );
+
+int cwmp_add_parameter_to_list(env_t * env , parameter_list_t * pl, parameter_t * parameter);
+void cwmp_add_event_to_list(env_t * env , event_list_t * eventlist, event_code_t * event);
+
+int cwmp_parse_getparameternames_message(env_t * env, xmldoc_t * doc, char ** path_name, unsigned int * next_level, fault_code_t *fault);
+int cwmp_parse_getparametervalues_message(env_t * env , xmldoc_t * doc, parameter_node_t * root, parameter_list_t ** ppl, fault_code_t *fault);
+int cwmp_parse_setparametervalues_message(env_t * env , xmldoc_t * doc, parameter_node_t * root, parameter_list_t ** ppl, fault_code_t *fault);
+int cwmp_parse_reboot_message(env_t * env , xmldoc_t *doc, char ** key, fault_code_t *fault);
+int cwmp_parse_addobject_message(env_t * env , xmldoc_t *doc, parameter_node_t * root, int * instances, int* status, fault_code_t *fault);
+int cwmp_parse_deleteobject_message(env_t * env , xmldoc_t *doc, parameter_node_t * root, int* status, fault_code_t *fault);
+
+xmlnode_t * cwmp_get_rpc_method_node(xmldoc_t * doc);
+xmlnode_t * cwmp_get_header_node(xmldoc_t * doc);
+
+int cwmp_parse_header_node(xmlnode_t * node, header_t ** header, pool_t * pool);
+char * cwmp_get_rpc_method_name(xmldoc_t * doc);
+char * cwmp_get_type_string(int type);
+int cwmp_get_type_value(char * type);
+char * cwmp_get_fault_string(int code);
+
+parameter_node_t * cwmp_get_parameter_node(parameter_node_t * root, const char * param_name);
+parameter_node_t * cwmp_get_parameter_path_node(parameter_node_t * parent, const char * param_name);
+
+int cwmp_get_parameter_node_value(cwmp_t * cwmp, parameter_node_t * node, const char * name, char ** value, pool_t * pool);
+int cwmp_set_parameter_node_value(cwmp_t * cwmp, parameter_node_t * node, const char * name, const char * value, int value_length);
+int cwmp_write_doc_to_chunk(xmldoc_t * doc, cwmp_chunk_t * chunk, pool_t * pool);
+
+xmldoc_t * cwmp_xml_parse_buffer(pool_t * pool, char * buffer);
+xmlnode_t * cwmp_xml_get_child_with_name(void * nodeptr, const char * nodeName);
+
+
+#define XmlNodeGetDocRoot(docptr) XmlNodeGetFirstChild(XmlNodeGetFirstChild(& (docptr)->node))
+
+
+
+
+#endif // CWMP_H
+
diff --git a/lynq/R305/ap/app/goahead/interface5.0/wifi/zte_web_lan.c b/lynq/R305/ap/app/goahead/interface5.0/wifi/zte_web_lan.c
new file mode 100755
index 0000000..8704ab3
--- /dev/null
+++ b/lynq/R305/ap/app/goahead/interface5.0/wifi/zte_web_lan.c
@@ -0,0 +1,2112 @@
+
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_lan.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷ Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-06
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
+
+/**************************************************************************
+* Ð޸ıàºÅ : й¦ÄÜ
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.6.24
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÖ§³Öufi monitor¹¦ÄÜ´¦Àí´úÂë
+**************************************************************************/
+#include <ctype.h>
+
+#include "zte_web_interface.h"
+#include "./net/zte_web_net_other.h"
+#include "netotherapi.h"
+
+#define WDS_DISABLE "0"
+#define WDS_ROOTAP "1"
+#define WDS_CLIENT "2"
+#define WDS_REPEATER "3"
+#define WIFI_MAX_STA_NUM 32 //kw 3
+
+
+#define NV_WRITE(nv_name, str, ret) do{ ret = zte_web_write(nv_name, (char *)str);}while(0)
+
+static int zte_wlan_ssid1_basic_set(webs_t wp, unsigned int *wifi_set_flags);
+static int zte_lan_ssid1_security_set(webs_t wp, unsigned int *wifi_set_flags);
+static int zte_wlan_ssid2_basic_set(webs_t wp, unsigned int *wifi_set_flags);
+static int zte_lan_ssid2_security_set(webs_t wp, unsigned int *wifi_set_flags);
+
+static int get_random(unsigned char* buf, size_t len);
+
+
+enum {WIFI_COVERAGE_LEN = 16};
+/**
+ * @brief wifi share mode setting's struct
+ * @param wep_key_index
+ * @param wep_key1_mode
+ * @param wep_key2_mode
+ * @param wep_key3_mode
+ * @param wep_key4_mode
+ * @param wep_key1
+ * @param wep_key2
+ * @param wep_key3
+ * @param wep_key4
+ * @note
+ * @warning
+ */
+typedef struct {
+ uint8 wep_key_index[WF_WPS_KEY_INDEX_LEN];
+ uint8 wep_key1_mode[WF_KEY_MODE_LEN];
+ uint8 wep_key2_mode[WF_KEY_MODE_LEN];
+ uint8 wep_key3_mode[WF_KEY_MODE_LEN];
+ uint8 wep_key4_mode[WF_KEY_MODE_LEN];
+ uint8 wep_key1[WF_WEP_KEY_MAX_LEN];
+ uint8 wep_key2[WF_WEP_KEY_MAX_LEN];
+ uint8 wep_key3[WF_WEP_KEY_MAX_LEN];
+ uint8 wep_key4[WF_WEP_KEY_MAX_LEN];
+} zte_wifi_open_and_share_mode_s_type;
+/*wifi WPA/WPA2 mode setting*/
+typedef struct {
+ uint8 pre_share_key[WF_WPA_KEY_MAX_LEN];
+} zte_wifi_wpa_and_wpa2_mode_s_type;
+
+static char * str2upper(const char * in, char * out)
+{
+ char *p1 = in;
+ char *p2 = out;
+ if (in == NULL || out == NULL) return NULL;
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s] in=%s\n", __FILE__, in);
+
+ while (*p1 != '\0') {
+ //if (isalpha(*p1)) {//cov m
+ if ((*p1) >= 'a' && (*p1) <= 'z') {
+ *p2 = toupper(*p1);
+ } else {
+ *p2 = *p1;
+ }
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s] UPPER = %c[%d], Lower=%c[%d]\n", __FILE__, *p2, *p2, *p1, *p1);
+ p1++;
+ p2++;
+ }
+
+ *p2 = '\0';
+ return out;
+
+}
+
+static int validate_pin_code(unsigned long code)
+{
+ unsigned long accum = 0;
+ accum += 3 * ((code / 10000000) % 10);
+ accum += 1 * ((code / 1000000) % 10);
+ accum += 3 * ((code / 100000) % 10);
+ accum += 1 * ((code / 10000) % 10);
+ accum += 3 * ((code / 1000) % 10);
+ accum += 1 * ((code / 100) % 10);
+ accum += 3 * ((code / 10) % 10);
+ accum += 1 * ((code / 1) % 10);
+ return (0 == (accum % 10));
+}
+static int zte_Safe_valid_SpecialCharForSSID(char single_data)
+{
+ /*if(single_data == '&') return 0;
+ else if(single_data == '.') return 0;
+ else if(single_data == '`') return 0;
+ else if(single_data == '\\') return 0;
+ else*/
+ return 1;
+}
+
+
+static data_safe_result_type_t zte_Safe_noSpecialCharForSSID(char *str)
+{
+#if 0 //kw 3
+ int i = 0;
+ int len = 0;
+ if (NULL == str) {
+ return 0;
+ }
+
+ len = strlen(str);
+ for (i = 0; i < len; i++) {
+ if (zte_Safe_valid_SpecialCharForSSID(str[i]) != 0) {
+ continue;
+ } else {
+ return 0;
+ }
+ }
+#endif
+ return 1;
+}
+
+void wlan_set_change_ssid_key_status()
+{
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MMI, MSG_CMD_MODIFY_SSID_KEY, 0, NULL, 0);
+}
+
+
+void wifi_work_mode_set_basic()
+{
+ char m_ssid_enable[20] = {0};
+ char system_restore_flg[32] = {0};
+ char MAX_Access_num[16] = {0};
+ char m_MAX_Access_num[16] = {0};
+ char MAX_Station_num[16] = {0};
+
+ char num_buf[12] = {0};
+ char m_num_buf[12] = {0};
+ int max_sta_num = 0;
+ int max_num = 0;
+ int m_max_num = 0;
+ char max_access_bak[16] = {0};
+ char max_station_bak[16] = {0};
+ cfg_get_item("MAX_Access_num_bbak", max_access_bak, sizeof(max_access_bak));
+ cfg_get_item("MAX_Station_num_bak", max_station_bak, sizeof(max_station_bak));
+ slog(MISC_PRINT, SLOG_ERR,"MAX_Access_num_bbak:%s,MAX_Station_num_bak:%s\n",max_access_bak,max_station_bak);
+ if(strlen(max_station_bak) != 0 && strcmp(max_station_bak, "0")){
+ cfg_set("MAX_Station_num",max_station_bak);
+ cfg_set("MAX_Station_num_bak","0");
+ }
+ if(strlen(max_access_bak) != 0 && strcmp(max_access_bak, "0")){
+ cfg_set("MAX_Access_num", max_access_bak);
+ }
+
+ //wifi workmode set
+ cfg_get_item("m_ssid_enable", m_ssid_enable, sizeof(m_ssid_enable));
+ cfg_get_item("system_restore_flg", system_restore_flg, sizeof(system_restore_flg));
+
+ if (!strcmp(m_ssid_enable, "1")) {
+ cfg_set("AP_STARTMODE", "multi");
+ if (!strcmp(system_restore_flg, "first_restore")) {
+ cfg_set("system_restore_flg", "not_first_restore");
+ slog(MISC_PRINT, SLOG_DEBUG,"is first config access num.....\n");
+
+ cfg_get_item("MAX_Access_num", MAX_Access_num, sizeof(MAX_Access_num));
+ max_num = atoi(MAX_Access_num);
+ if (max_num > 1 && max_num < 33) {
+ sprintf(num_buf, "%d", max_num / 2);
+ slog(MISC_PRINT, SLOG_DEBUG,"num_buf = %s\n", num_buf);
+ zte_web_write("MAX_Access_num", num_buf);
+ zte_web_write("m_MAX_Access_num", num_buf);
+ }
+ }
+
+ cfg_get_item("MAX_Station_num", MAX_Station_num, sizeof(MAX_Station_num));
+ cfg_get_item("MAX_Access_num", MAX_Access_num, sizeof(MAX_Access_num));
+ cfg_get_item("m_MAX_Access_num", m_MAX_Access_num, sizeof(m_MAX_Access_num));
+
+ zte_web_write("MAX_Access_num_bak", MAX_Access_num);
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s],MAX_Access_num_bak=%s\n", __FILE__, MAX_Access_num);
+
+ max_sta_num = atoi(MAX_Station_num);
+ max_num = atoi(MAX_Access_num);
+ m_max_num = atoi(m_MAX_Access_num);
+ if ((max_sta_num < 0 || max_sta_num > WIFI_MAX_STA_NUM) ||
+ (max_num < 0 || max_num > WIFI_MAX_STA_NUM)) { //kw 3
+ slog(MISC_PRINT, SLOG_ERR,"\n error max_sta_num parameter\n");
+ return;
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s],MAX_Station_num=%s,MAX_Access_num=%s,m_MAX_Access_num=%s\n", __FILE__, MAX_Station_num, MAX_Access_num, m_MAX_Access_num);
+ if (max_num == max_sta_num) {
+ sprintf(m_num_buf, "%d", max_sta_num / 2);
+ zte_web_write("MAX_Access_num", m_num_buf);
+ zte_web_write("m_MAX_Access_num", m_num_buf);
+ } else {
+ if (max_num < max_sta_num) { // ʵ¼ÊÉÏ£¬³ýÁ˵ÈÓÚ×î´óÖµ£¬¾ÍÊÇСÓÚ×î´óÖµ£¬´Ë´¦ÅжÏÎÞÒâÒå
+ m_max_num = max_sta_num - max_num;
+ sprintf(m_num_buf, "%d", m_max_num);
+ zte_web_write("m_MAX_Access_num", m_num_buf);
+ }
+
+ }
+
+ } else if (!strcmp(m_ssid_enable, "0")) {
+ cfg_set("AP_STARTMODE", "standard");
+ cfg_get_item("MAX_Access_num_bak", MAX_Access_num, sizeof(MAX_Access_num));
+ zte_web_write("MAX_Access_num", MAX_Access_num);
+ } else {
+ slog(MISC_PRINT, SLOG_ERR,"\n error wifi_work_mode_set parameter\n");
+ return;
+ }
+}
+
+void zte_lan_stop_apsta()
+{
+ zte_web_write("wifi_sta_connection", "0");
+ //zte_web_write("blc_switch", "00");
+ zte_web_write("user_initiate_disconnect", "0"); //Óû§Ö÷¶¯Á¬½Ó״̬£¬Í˳ö¸ÉԤģʽ
+ zte_web_write("manual_d_wifi", "0");
+
+ slog(MISC_PRINT, SLOG_NORMAL,"[zte_lan_stop_apsta]MSG_CMD_WIFI_STATION_CLOSE_OPEN_MSSID\n", 0, NULL);
+
+ //zte_send_message(MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_CLOSE_OPEN_MSSID, 0, NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_STATION_CLOSE_OPEN_MSSID, 0, NULL, 0);
+}
+
+void zte_wlan_basic_set(webs_t wp)
+{
+ char_t *wifi_on = NULL, *old_wifi_on = NULL;
+ char_t *radio_off = NULL;
+ char_t *wirelessmode = NULL, *old_wirelessmode = NULL;
+ char_t *countrycode = NULL, *old_countrycode = NULL;
+ //char_t *ssid = NULL, *old_ssid = NULL;
+ char_t *broadcastssid = NULL, *old_broadcastssid = NULL ;
+ char_t *channel = NULL, *old_channel = NULL;
+ //char_t *abg_rate = NULL,*old_abg_rate = NULL;
+ //char_t *NoForwarding = NULL,*old_NoForwarding = NULL;
+ char_t *MAX_Access_num = NULL, *old_MAX_Access_num = NULL;
+ char_t *m_ssid_enable = NULL, *old_m_ssid_enable = NULL;
+ //char_t *m_SSID = NULL,*old_m_SSID = NULL;
+ //char_t *m_HideSSID = NULL,*old_m_HideSSID = NULL;
+ //char_t *m_NoForwarding = NULL,*old_m_NoForwarding =NULL;
+ char_t *wifi_11n_cap = NULL, *old_wifi_11n_cap = NULL;
+ //char_t *channel_JP = NULL, *old_channel_JP = NULL;
+ char_t *wifi_band = NULL, *old_wifi_band = NULL;
+
+ //int Access_num = 0;
+ unsigned int wifi_set_flags = 0;
+ char wifi_set_flags_str[NV_ITEM_STRING_LEN_20] = {0};
+ char wifi_sta_connection[8] = {0};
+
+ zte_topsw_state_e_type nv_ret = ZTE_NVIO_DONE;
+ char nv_basic[NVIO_WIFI_MAX_LEN] = {0}; // for nv read and write
+//cov m
+#define NV_READ(nv_name, str, ret) do{ret = zte_web_read(nv_name, nv_basic); str = nv_basic;}while(0)
+ /*lint -e717*/
+ //#define NV_WRITE(nv_name, str, ret) do{ ret = zte_web_write(nv_name, (char *)str);}while(0)
+
+ slog(WIFI_PRINT, SLOG_ERR, "zte_wlan_basic_set enter \n");
+
+ //reset wifi_set_flags
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, "");
+
+ //wifiEnabled or not
+ memset(nv_basic, 0, sizeof(nv_basic));
+ wifi_on = websGetVar(wp, T("wifiEnabled"), NULL);
+ if (wifi_on != NULL) {
+ if (STR_EQUAL(wifi_on, "0")) {
+ slog(MISC_PRINT, SLOG_ERR, T("UFIx User disable WIFI swtich!\n"));
+ } else if (STR_EQUAL(wifi_on, "1")) {
+ slog(MISC_PRINT, SLOG_ERR, T("UFIx User enable WIFI swtich!\n"));
+ }
+ NV_READ("wifiEnabled", old_wifi_on, nv_ret);
+ printf("[%s:%s]old_wifi_on=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_wifi_on, nv_ret);
+ //NV_READ("RadioOff", radio_off, nv_ret);
+ //printf("[%s:%s]radio_off=%s, nv_ret=%d",__FILE__, __FUNCTION__, radio_off,nv_ret);
+ if (!STR_EQUAL(wifi_on, old_wifi_on)) { //kw 3
+ //send_to_mc = TRUE;
+ wifi_set_flags |= ZTE_WLAN_ON_OFF_SET;
+ NV_WRITE("wifiEnabled", wifi_on, nv_ret);
+
+#if 0
+ if (STR_EQUAL(wifi_on, "0") && STR_EQUAL(radio_off, "1")) {
+ NV_WRITE("wifiEnabled", wifi_on, nv_ret);
+ NV_WRITE("RadioOff", wifi_on, nv_ret);
+ NV_WRITE("RadioOn", wifi_on, nv_ret);
+
+ } else if (STR_EQUAL(wifi_on, "1")) {
+ NV_WRITE("wifiEnabled", wifi_on, nv_ret);
+ NV_WRITE("RadioOn", wifi_on, nv_ret);
+ }
+#endif
+ }
+ printf("[%s:%s]wifi_on:[%s]\n", __FILE__, __FUNCTION__, wifi_on);
+ }
+
+ //wifiMode
+ memset(nv_basic, 0, sizeof(nv_basic));
+ wirelessmode = websGetVar(wp, T("wifiMode"), NULL);
+ if (wirelessmode != NULL) {
+ slog(MISC_PRINT, SLOG_ERR, T("UFIx User set WIFI advanced settings!\n"));
+ printf("[%s:%s]wirelessmode:%s\n", __FILE__, __FUNCTION__, wirelessmode); /*lint !e26*/
+ NV_READ("WirelessMode", old_wirelessmode, nv_ret);
+ printf("[%s:%s]old_wirelessmode=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_wirelessmode, nv_ret); /*lint !e26*/
+ if (!STR_EQUAL(wirelessmode, old_wirelessmode)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_WIRELESS_MODE_SET;
+ NV_WRITE("WirelessMode", wirelessmode, nv_ret);
+ printf("[%s:%s]wirelessmode is :%s\n", __FILE__, __FUNCTION__, wirelessmode); /*lint !e26*/
+ }
+ }
+
+ /* country code*/
+ memset(nv_basic, 0, sizeof(nv_basic));
+ countrycode = websGetVar(wp, T("countryCode"), NULL);
+ if (countrycode != NULL) {
+#ifdef WEBS_SECURITY
+ zte_web_read("wifi_sta_connection", wifi_sta_connection);
+ if(wifi_sta_connection[0] == '1')
+ {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+#endif
+ NV_READ("CountryCode", old_countrycode, nv_ret);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]old_countrycode=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_countrycode, nv_ret); /*lint !e26*/
+ if (!STR_EQUAL(countrycode, old_countrycode)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_COUNTRY_SET;
+ NV_WRITE("CountryCode", countrycode, nv_ret);
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]countrycode:%s\n", __FILE__, __FUNCTION__, countrycode); /*lint !e26*/
+ }
+
+#if 0 //²»ÊôÓڸ߼¶É䯵²ÎÊý
+ //broadcastSsidEnabled
+ memset(nv_basic, 0, sizeof(nv_basic));
+ broadcastssid = websGetVar(wp, T("broadcastSsidEnabled"), NULL);
+ if (broadcastssid != NULL) {
+ NV_READ("HideSSID", old_broadcastssid, nv_ret);
+ printf("[%s:%s]old_broadcastssid=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_broadcastssid, nv_ret); /*lint !e26*/
+ if ((nv_ret == ZTE_NVIO_DONE &&
+ !STR_EQUAL(broadcastssid, old_broadcastssid)) ||
+ (nv_ret != ZTE_NVIO_DONE)) {
+ //send_to_mc = TRUE;
+ wifi_set_flags |= ZTE_WLAN_BROADCAST_SET;
+ NV_WRITE("HideSSID", broadcastssid, nv_ret);
+ }
+ printf("[%s:%s]broadcastssid:%s\n", __FILE__, __FUNCTION__, broadcastssid); /*lint !e26*/
+ }
+#endif
+ //selectedChannel
+ memset(nv_basic, 0, sizeof(nv_basic));
+ channel = websGetVar(wp, T("selectedChannel"), NULL);
+ if (channel != NULL) {
+ NV_READ("Channel", old_channel, nv_ret);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]old_channel=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_channel, nv_ret); /*lint !e26*/
+ if (!STR_EQUAL(channel, old_channel)) { //kw 3
+ //send_to_mc = TRUE;
+ wifi_set_flags |= ZTE_WLAN_CHANNEL_SET;
+ NV_WRITE("Channel", channel, nv_ret);
+ }
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]channel:%s\n", __FILE__, __FUNCTION__, channel); /*lint !e26*/
+ }
+
+ //band setting
+ memset(nv_basic, 0, sizeof(nv_basic));
+ wifi_band = websGetVar(wp, T("wifi_band"), NULL);
+ if (wifi_band != NULL) {
+ NV_READ("wifi_band", old_wifi_band, nv_ret);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]old_wifi_band=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_wifi_band, nv_ret); /*lint !e26*/
+ if (!STR_EQUAL(wifi_band, old_wifi_band)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_WIFI_BAND_SET;
+ NV_WRITE("wifi_band", wifi_band, nv_ret);
+ }
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]wifi_band:%s\n", __FILE__, __FUNCTION__, wifi_band); /*lint !e26*/
+ }
+
+
+ //set wifi rate
+#if 0
+ memset(nv_basic, 0, sizeof(nv_basic));
+ abg_rate = websGetVar(wp, T("abg_rate"), NULL);
+ if (abg_rate != NULL) {
+ NV_READ("HT_MCS", old_abg_rate, nv_ret);
+ printf("old_abg_rate=%s, nv_ret=%d", old_abg_rate, nv_ret); /*lint !e26*/
+ if ((nv_ret == ZTE_NVIO_DONE &&
+ !STR_EQUAL(abg_rate, old_abg_rate)) ||
+ (nv_ret != ZTE_NVIO_DONE)) {
+ wifi_set_flags |= ZTE_WLAN_DATA_RATE_SET;
+ NV_WRITE("HT_MCS", abg_rate, nv_ret);
+ }
+
+ printf("abg_rate:%s", abg_rate); /*lint !e26*/
+ }
+#endif
+
+#if 0 // not belong to RF parameters
+ //set MAX_Access_num
+ memset(nv_basic, 0, sizeof(nv_basic));
+ MAX_Access_num = websGetVar(wp, T("MAX_Access_num"), NULL);
+ if (MAX_Access_num != NULL) {
+ NV_READ("MAX_Access_num", old_MAX_Access_num, nv_ret);
+ printf("[%s:%s]old_MAX_Access_num=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_MAX_Access_num, nv_ret); /*lint !e26*/
+ if ((nv_ret == ZTE_NVIO_DONE &&
+ !STR_EQUAL(MAX_Access_num, old_MAX_Access_num)) ||
+ (nv_ret != ZTE_NVIO_DONE)) {
+ wifi_set_flags |= ZTE_WLAN_MAX_ACCESS_NUM_SET;
+ NV_WRITE("MAX_Access_num", MAX_Access_num, nv_ret);
+ NV_WRITE("MAX_Access_num_user_set", "1", nv_ret);
+ }
+
+ printf("[%s:%s]MAX_Access_num:%s\n", __FILE__, __FUNCTION__, MAX_Access_num); /*lint !e26*/
+ }
+#endif
+ //set m_ssid_enable
+ memset(nv_basic, 0, sizeof(nv_basic));
+ m_ssid_enable = websGetVar(wp, T("m_ssid_enable"), NULL);
+ if (m_ssid_enable != NULL) {
+#if 1
+ NV_READ("m_ssid_enable", old_m_ssid_enable, nv_ret);
+ slog(MISC_PRINT, SLOG_DEBUG,"old_m_ssid_enable=%s, nv_ret=%d\n", old_m_ssid_enable, nv_ret);/*lint !e26*/
+ if (!STR_EQUAL(m_ssid_enable, old_m_ssid_enable)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ NV_WRITE("m_ssid_enable", m_ssid_enable, nv_ret);
+ wlan_set_change_ssid_key_status();//added by dujiajiao
+ wifi_work_mode_set_basic();
+ }
+#else
+ if (!strcmp(m_ssid_enable, "1")) {
+ NV_WRITE("m_ssid_enable", "0", nv_ret);
+ }
+#endif
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]m_ssid_enable:%s\n", __FILE__, __FUNCTION__, m_ssid_enable); /*lint !e26*/
+ }
+
+ //set wifi_11n_cap
+ memset(nv_basic, 0, sizeof(nv_basic));
+ NV_READ("wifi_11n_cap", old_wifi_11n_cap, nv_ret);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]old_wifi_11n_cap=%s, nv_ret=%d\n", __FILE__, __FUNCTION__, old_wifi_11n_cap, nv_ret); /*lint !e26*/
+ wifi_11n_cap = websGetVar(wp, T("wifi_11n_cap"), NULL);
+ if (wifi_11n_cap != NULL) {
+ if (!STR_EQUAL(wifi_11n_cap, old_wifi_11n_cap)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_WIRELESS_MODE_SET;
+ NV_WRITE("wifi_11n_cap", wifi_11n_cap, nv_ret);
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]wifi_11n_cap:%s\n", __FILE__, __FUNCTION__, wifi_11n_cap); /*lint !e26*/
+ }
+
+ //last, write the wifi_set_flags
+ (void)snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str) - 1, "%u", wifi_set_flags);
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, wifi_set_flags_str);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]wifi_set_flags:[0x%x] to [%s]\n", __FILE__, __FUNCTION__, wifi_set_flags, wifi_set_flags_str); /*lint !e26*/
+
+ if (0 != wifi_set_flags) {
+ unsigned int flags = 0;
+ UCHAR flag_str[8] = {0};
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]send wifi para to wlan-server@basic_set\n", __FILE__, __FUNCTION__); /*lint !e26*/
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]m_ssid_enable=%s,wifi_on=%s\n", __FILE__, __FUNCTION__, m_ssid_enable, wifi_on); /*lint !e26*/
+
+ if (NULL != wifi_on && (wifi_set_flags & ZTE_WLAN_ON_OFF_SET)) {
+//¿ªÆôwifiʱºò£¬Èç¹ûͬʱ¿ªÆôMSSID£¬»¹ÊÇÖ»ÉèÖÿªÆôwifi µÄflags£¬ÒòΪMSSIDµÄnvÒѾÉèÖùýÁË
+
+ if (0 == atoi(wifi_on))
+ flags = WIFI_ADVANCED_CLOSE;
+ else if (m_ssid_enable != NULL && 1 == atoi(m_ssid_enable)) { // ͬʱ¿ªÆômultisssid£¬ÒªÔ¤·Àapsta Ò»²¢¿ªÆôµÄÇé¿ö
+ flags = WIFI_ADVANCED_OPEN_VA01;
+ } else
+ flags = WIFI_ADVANCED_OPEN;
+
+ } else if (wifi_set_flags & ZTE_WLAN_SET_AP_MSSID) { // ÔÚwifi¿ª¹Ø¿ªÆôµÄ״̬Ï£¬¶Ô Multi SSID ½øÐпª¹ØÇл»
+ if (1 == atoi(m_ssid_enable))
+ flags = WIFI_ADVANCED_OPEN_VA1;
+ else
+ flags = WIFI_ADVANCED_CLOSE_MSSID;
+
+ } else { // ÉèÖø߼¶²ÎÊýÉ䯵
+ flags = WIFI_ADVANCED_RF;
+ }
+ snprintf(flag_str,sizeof(flag_str), "%d", flags);
+ zte_web_read("wifi_sta_connection", wifi_sta_connection);
+
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]m_ssid_enable=%s,wifi_on=%s\n", __FILE__, __FUNCTION__, m_ssid_enable, wifi_on); /*lint !e26*/
+
+//when open mssid , need close apsta at same time
+ if ((flags == WIFI_ADVANCED_OPEN_VA1) && atoi(wifi_sta_connection) == 1) {
+ zte_lan_stop_apsta();
+ } else {
+ //if(0 != zte_send_message(MODULE_ID_WIFI, MSG_CMD_WIFI_ADVANCED, strlen(flag_str)+1, flag_str))
+ if (0 != ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_ADVANCED, strlen(flag_str) + 1, flag_str, 0)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ }
+ slog(WIFI_PRINT, SLOG_ERR, "[%s:%s]wifi set cmd done! \n", __FILE__, __FUNCTION__); /*lint !e26*/
+ }
+ zte_write_result_to_web(wp, SUCCESS);
+
+}
+
+void zte_wlan_mac_filter_set(webs_t wp)
+{
+ char_t *ACL_mode = NULL;
+ char_t *old_ACL_mode = NULL;
+ char_t *wifi_mac_black_list = NULL;
+ char_t *wifi_mac_white_list = NULL;
+ char_t *old_wifi_mac_black_list = NULL;
+ char_t *old_wifi_mac_white_list = NULL;
+ char_t *wifi_hostname_black_list = NULL;
+ char_t *wifi_hostname_white_list = NULL;
+ unsigned int wifi_set_flags = 0;
+ char wifi_set_flags_str[NV_ITEM_STRING_LEN_20] = {0};
+ char accesscontrollist0[720] = {0};
+ zte_topsw_state_e_type nv_ret = ZTE_NVIO_DONE;
+ char nv_basic[NVIO_WIFI_MAX_LEN] = {0}; // for nv read and write
+ char nv_mac[720] = {0};
+//cov m
+#define NV_READ(nv_name, str, ret) do{ret = zte_web_read(nv_name, nv_basic); str = nv_basic;}while(0)
+#define NV_READ_MAC(nv_name, str, ret) do{ret = zte_web_read(nv_name, nv_mac); str = nv_mac;}while(0)
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]zte_wlan_mac_filter_set.\n", __FILE__, __FUNCTION__); /*lint !e26*/
+ memset(nv_basic, 0, sizeof(nv_basic));
+ NV_READ("ACL_mode", old_ACL_mode, nv_ret);
+ ACL_mode = websGetVar(wp, T("ACL_mode"), T(""));
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s] ACL_mode =%s,nv_ret = %d old_ACL_mode = %s \n", __FILE__, __FUNCTION__, ACL_mode, nv_ret, old_ACL_mode);
+ if (ACL_mode != NULL) {
+ if (!strcmp(ACL_mode, "2")) {
+ slog(MISC_PRINT, SLOG_ERR, T("UFIx User enable black list!\n"));
+ } else if (!strcmp(ACL_mode, "0")) {
+ slog(MISC_PRINT, SLOG_ERR, T("UFIx User disable black list!\n"));
+ }
+ if (!STR_EQUAL(ACL_mode, old_ACL_mode)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_ACL_SET;
+ NV_WRITE("ACL_mode", ACL_mode, nv_ret);
+ }
+
+ } else {//klocwork
+ slog(MISC_PRINT, SLOG_ERR,"[%s:%s]ACL_mode:no such para.", __FILE__, __FUNCTION__); /*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ memset(nv_mac, 0, sizeof(nv_mac));
+ if (!strcmp(ACL_mode, "2")) {
+ char black_list[720] = {0};
+ NV_READ_MAC("wifi_mac_black_list", old_wifi_mac_black_list, nv_ret);
+ wifi_mac_black_list = websGetVar(wp, T("wifi_mac_black_list"), T(""));
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s] wifi_mac_black_list = %s, old_wifi_mac_black_list=%s \n", __FILE__, wifi_mac_black_list, old_wifi_mac_black_list);
+ //cov m
+ if ((wifi_mac_black_list != NULL) && (strlen(wifi_mac_black_list) < sizeof(black_list))) {
+ str2upper(wifi_mac_black_list, black_list);
+ if (!STR_EQUAL(black_list, old_wifi_mac_black_list)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_ACL_SET;
+ NV_WRITE("wifi_mac_black_list", black_list, nv_ret);
+ }
+
+ }
+ wifi_hostname_black_list = websGetVar(wp, T("wifi_hostname_black_list"), T(""));
+ if (wifi_hostname_black_list != NULL)//klocwork
+ (void)zte_web_write("wifi_hostname_black_list", wifi_hostname_black_list);
+ } else if (!strcmp(ACL_mode, "1")) {
+ char white_list[720] = {0};
+ NV_READ_MAC("wifi_mac_white_list", old_wifi_mac_white_list, nv_ret);
+ wifi_mac_white_list = websGetVar(wp, T("wifi_mac_white_list"), T(""));
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s] wifi_mac_white_list = %s,old_wifi_mac_white_list=%s \n", __FILE__, wifi_mac_white_list, old_wifi_mac_white_list);
+ //cov m
+ if ((wifi_mac_white_list != NULL) && (strlen(wifi_mac_white_list) < sizeof(white_list))) {
+ str2upper(wifi_mac_white_list, white_list);
+ if (!STR_EQUAL(white_list, old_wifi_mac_white_list)) { //kw 3
+ wifi_set_flags |= ZTE_WLAN_ACL_SET;
+ NV_WRITE("wifi_mac_white_list", white_list, nv_ret);
+ }
+
+ }
+ wifi_hostname_white_list = websGetVar(wp, T("wifi_hostname_white_list"), T(""));
+ if (wifi_hostname_white_list != NULL)//klocwork
+ (void)zte_web_write("wifi_hostname_white_list", wifi_hostname_white_list);
+ }
+ if ('\0' == *ACL_mode) {
+ slog(MISC_PRINT, SLOG_ERR,"[%s:%s]ACL_mode:invalid input para.", __FILE__, __FUNCTION__); /*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ //(void)zte_web_write("ACL_mode",ACL_mode);
+ //(void)zte_web_write("wifi_mac_black_list", wifi_mac_black_list);
+
+
+/*
+ if (!strcmp(ACL_mode, "2")) {
+ (void)zte_web_write("wifi_hostname_black_list", wifi_hostname_black_list);
+ } else if (!strcmp(ACL_mode, "1")) {
+ (void)zte_web_write("wifi_hostname_white_list", wifi_hostname_white_list);
+ }
+*/
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s] wifi_mac_black_list=%s ,wifi_mac_white_list=%s, wifi_set_flags=%d\n",
+ __FILE__, wifi_mac_black_list, wifi_mac_white_list, wifi_set_flags);
+
+ if (wifi_set_flags != 0) {
+ (void)snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str) - 1, "%u", wifi_set_flags);
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, wifi_set_flags_str);
+ //zte_send_message(MODULE_ID_WIFI,MSG_CMD_WIFI_MAC,0,NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_MAC, 0, NULL, 0);
+
+ slog(MISC_PRINT, SLOG_NORMAL,"[%s:%s] MSG_CMD_WIFI_MAC send to wlan-server!\n", __FILE__, __FUNCTION__); /*lint !e26*/
+ } else {
+ slog(MISC_PRINT, SLOG_NORMAL,"[%s:%s]do not deal\n", __FILE__, __FUNCTION__);
+ }
+
+ zte_write_result_to_web(wp, SUCCESS);
+
+}
+
+void zte_wlan_wps_mode_set(webs_t wp)
+
+{
+ slog(MISC_PRINT, SLOG_ERR, T("UFIx User set wps mode!\n"));
+
+ char *wps_mode = NULL;
+ char *WPS_SSID = NULL;
+ char *wps_pin = NULL;
+
+// char pinIsValidate[10] = {0};
+ char auth_mode[NV_ITEM_STRING_LEN_20] = {0};
+ char encrypType[WF_ENCRY_TYPE_LEN] = {0};
+ char wps_state[NV_ITEM_STRING_LEN_50] = {0};
+ int pin_len = 0;
+ unsigned int wifi_set_flags = 0;
+ char wifi_set_flags_str[NV_ITEM_STRING_LEN_20] = {0};
+
+ char *wifi_wps_index = NULL;
+ char wps_msg[16] = {0};
+
+ wps_mode = websGetVar(wp, T("wps_mode"), T(""));
+ WPS_SSID = websGetVar(wp, T("WPS_SSID"), T(""));
+ wifi_wps_index = websGetVar(wp, T("wifi_wps_index"), T(""));
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s] wifi_wps_index = %s\n", __FILE__, __FUNCTION__, wifi_wps_index);
+
+ if (('\0' == *wps_mode) || ('\0' == *WPS_SSID)) {
+ slog(MISC_PRINT, SLOG_ERR,"[%s:%s]zte_lan_wps_set:invalid input para.\n wps_mode is [%s]\n WPS_SSID is [%s]", __FILE__, __FUNCTION__, wps_mode, WPS_SSID); /*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ (void) zte_web_read(NV_WIFI_WPS_STATE, wps_state);
+ if (0 == strcmp(wps_state, "1")) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_lan_wps_set:invalid operate, wps in processing..");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ if (0 == strcmp(wps_mode, WPS_MODE_PBC)) {
+ (void)zte_web_write(NV_WIFI_WPS_STATE, "1");
+ (void)zte_web_write(NV_WIFI_WPS_MODE, wps_mode);
+ (void)zte_web_write(NV_WIFI_WPS_SSID, WPS_SSID);
+ } else if (0 == strcmp(wps_mode, WPS_MODE_PIN)) {
+ wps_pin = websGetVar(wp, T("wps_pin"), T(""));
+ //add by liuyingnan for server safe for xss attack start
+ if (DATA_NO_SAFE == zte_Safe_noSpecialChar(wps_pin)) {
+ slog(MISC_PRINT, SLOG_ERR,"[%s:%s]Get Data is no Safe:wps_pin:%s\n", __FILE__, __FUNCTION__, wps_pin); /*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ //printf(" ---- zte_wlan_wps_mode_set len is %s\n", wps_pin);
+ if (wps_pin == NULL) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ pin_len = strlen(wps_pin);
+ if ((pin_len == 0) || ((pin_len != 4) && (pin_len != 8))) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ int wps_pin_num = atoi(wps_pin);
+ if(wps_pin_num<0 || wps_pin_num> INT_MAX-1)
+ {
+ wps_pin_num = 0;
+ }
+ if ((pin_len == 8) && !validate_pin_code(wps_pin_num)) {
+ zte_write_result_to_web(wp, FAILURE);
+ slog(MISC_PRINT, SLOG_ERR,"%s PIN check failed\n", __FUNCTION__);
+ return;
+ }
+
+
+ //add by liuyingnan for server safe for xss attack end
+ (void)zte_web_write(NV_WIFI_WPS_STATE, "1");
+ (void)zte_web_write(NV_WIFI_WPS_MODE, wps_mode);
+ (void)zte_web_write(NV_WIFI_WPS_SSID, WPS_SSID);
+ (void)zte_web_write(NV_WIFI_WPS_PIN, wps_pin);
+ } else {
+ slog(MISC_PRINT, SLOG_ERR,"[%s][%s]invalid wps_mode[%s].", __FILE__, __FUNCTION__, wps_mode); /*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ wifi_set_flags |= ZTE_WLAN_WPS_SET;
+
+ //last, write the wifi_set_flags
+ (void)snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str) - 1, "%u", wifi_set_flags);
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, wifi_set_flags_str);
+
+ slog(MISC_PRINT, SLOG_NORMAL,"[%s][%s] send to wlan-server wps cmd\n", __FILE__, __FUNCTION__);
+
+
+ if (wifi_wps_index != NULL) {
+ zte_web_write(NV_WIFI_WPS_INDEX, wifi_wps_index);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s] wifi_wps_index = %s\n", __FILE__, __FUNCTION__, wifi_wps_index);
+ }
+
+ //zte_send_message(MODULE_ID_WIFI,MSG_CMD_WIFI_WPS,0,NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_WPS, 0, NULL, 0);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]wifi set cmd done!", __FILE__, __FUNCTION__); /*lint !e26*/
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+
+void zte_wlan_web_ssid1_set(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_DEBUG, T("UFIx User set WIFI SSID settings!\n"));
+
+ unsigned int wifi_set_flags = 0;
+ char wifi_set_flags_str[NV_ITEM_STRING_LEN_20] = {0};
+ zte_topsw_state_e_type ret = ZTE_NVIO_DONE;
+
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, "");
+
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_web_ssid1_set:+++++++++++++++++======\n");
+ if (FALSE == zte_wlan_ssid1_basic_set(wp, &wifi_set_flags)) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_web_ssid1_set: zte_wlan_ssid1_basic_set failure .\n");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ if (-1 == zte_lan_ssid1_security_set(wp, &wifi_set_flags)) {
+ slog(MISC_PRINT, SLOG_ERR,"call zte_lan_ssid1_security_set failure .\n");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ (void)snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str) - 1, "%u", wifi_set_flags);
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, wifi_set_flags_str);
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_web_ssid1_set: wifi_set_flags [%u] to [%s].\n", wifi_set_flags, wifi_set_flags_str); /*lint !e26*/
+
+ if (0 != wifi_set_flags) {
+ slog(MISC_PRINT, SLOG_NORMAL,"send wifi para to wlan-server@ssid1\n");/*lint !e26*/
+ //zte_send_message(MODULE_ID_WIFI,MSG_CMD_WIFI_SSID,NULL,NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_CFG_AP, 0, NULL, 0);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]wifi set cmd done!", __FILE__, __FUNCTION__); /*lint !e26*/
+ }
+ zte_write_result_to_web(wp, SUCCESS);
+
+}
+
+
+
+void zte_wlan_ssid2_set(webs_t wp)
+{
+
+ unsigned int wifi_set_flags = 0;
+ char wifi_set_flags_str[NV_ITEM_STRING_LEN_20] = {0};
+ zte_topsw_state_e_type ret = ZTE_NVIO_DONE;
+
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, "");
+
+ if (FALSE == zte_wlan_ssid2_basic_set(wp, &wifi_set_flags)) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_ssid2_set: zte_wlan_ssid2_basic_set failure .");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ if (-1 == zte_lan_ssid2_security_set(wp, &wifi_set_flags)) {
+ slog(MISC_PRINT, SLOG_ERR,"call zte_lan_ssid2_security_set fail.\n .");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ (void)snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str) - 1, "%u", wifi_set_flags);
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, wifi_set_flags_str);
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_ssid2_set: wifi_set_flags [%u] to [%s].", wifi_set_flags, wifi_set_flags_str);
+
+ if (0 != wifi_set_flags) {
+ slog(MISC_PRINT, SLOG_NORMAL,"send wifi para to wlan-server@ssid2");/*lint !e26*/
+ //zte_send_message(MODULE_ID_WIFI,MSG_CMD_WIFI_SSID_M,NULL,NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_CFG_AP2, 0, NULL, 0);
+ slog(MISC_PRINT, SLOG_DEBUG,"wifi set cmd done!"); /*lint !e26*/
+ }
+ zte_write_result_to_web(wp, SUCCESS);
+
+}
+
+
+
+/**********************************************************************
+* Function: zte_wlan_sleep_set
+* Description: to set the wifi sleep mode
+* Input: http info
+* Output:
+* Return: 0:ok;-1:fail
+* Others:
+* Modify Date Version Author Modification
+* -----------------------------------------------
+* 2012/07/11 V1.0 zhouti first version
+**********************************************************************/
+void zte_wlan_sleep_set(webs_t wp)
+{
+ char_t *sleepMode = NULL;
+ //char_t *wifi_mac_black_list = NULL;
+ //char_t *wifi_hostname_black_list = NULL;
+ unsigned int wifi_set_flags = 0;
+ char wifi_set_flags_str[NV_ITEM_STRING_LEN_20] = {0};
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]zte_wlan_sleep_set.", __FILE__, __FUNCTION__); /*lint !e26*/
+ //printf("zhouti zte_wlan_sleep_set------------------------\n");
+ sleepMode = websGetVar(wp, T("sysIdleTimeToSleep"), T(""));
+
+ if (NULL == sleepMode || '\0' == *sleepMode) {
+ slog(MISC_PRINT, SLOG_ERR,"sleepMode:invalid input para.");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ //printf("zhouti zte_wlan_sleep_set sleepMode is %s\n", sleepMode);
+ (void)zte_web_write("Sleep_interval", sleepMode);
+ // (void)zte_web_write("wifi_mac_black_list", wifi_mac_black_list);
+ // (void)zte_web_write("wifi_hostname_black_list", wifi_hostname_black_list);
+
+
+ wifi_set_flags |= ZTE_WLAN_SET_AP_SLEEPTIMER;
+
+ (void)snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str) - 1, "%u", wifi_set_flags);
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, wifi_set_flags_str);
+
+ slog(MISC_PRINT, SLOG_NORMAL,"send wifi para to wlan-mac_filter_set@basic_set");/*lint !e26*/
+ //zte_send_message(MODULE_ID_WIFI, MSG_CMD_WIFI_SLEEP, 0, NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_SLEEP, 0, NULL, 0);
+ //printf("wifi set cmd done!");/*lint !e26*/
+
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+static int check_web_input_wifi(char *str, int len)
+{
+ int i = 0;
+ if (str == NULL || len <= 0 || strlen(str) < len) {
+ return 0;
+ }
+ for (i = 0; i < len; i++) {
+ if (strchr("`$&*\\[];:\'\"<>,",str[i]) || !isprint(str[i])) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+/**********************************************************************
+* Function: zte_wlan_coverage_set
+* Description: to set the wifi coverage
+* Input: http info
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* -----------------------------------------------
+* 2014/05/27 V1.0 zhouti first version
+**********************************************************************/
+void zte_wlan_coverage_set(webs_t wp)
+{
+ char_t *wifi_coverage = NULL;
+ char_t old_wifi_coverage[WIFI_COVERAGE_LEN + 1] = {0};
+ unsigned int wifi_set_flags = 0;
+ char wifi_set_flags_str[NV_ITEM_STRING_LEN_20] = {0};
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_coverage_set.");
+ //printf("zhouti zte_wlan_coverage_set------------------------\n");
+ wifi_coverage = websGetVar(wp, T(NV_WIFI_COVERAGE), T(""));
+
+ if (NULL == wifi_coverage || '\0' == *wifi_coverage) {
+ slog(MISC_PRINT, SLOG_ERR,"[%s][%s]coverage: invalid input para.", __FILE__, __FUNCTION__);
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ (void)zte_web_read(NV_WIFI_COVERAGE, old_wifi_coverage);
+ if (strcmp(wifi_coverage, old_wifi_coverage)) { //kw 3
+ (void)zte_web_write(NV_WIFI_COVERAGE, wifi_coverage);
+
+ wifi_set_flags |= ZTE_WLAN_POWER_SET;
+
+ (void)snprintf(wifi_set_flags_str, sizeof(wifi_set_flags_str) - 1, "%u", wifi_set_flags);
+ (void)zte_web_write(WIFI_NV_ITEM_WIFI_SET_FLAGS, wifi_set_flags_str);
+
+ slog(MISC_PRINT, SLOG_NORMAL,"send wifi para to wlan-mac_filter_set@basic_set");/*lint !e26*/
+ //zte_send_message(MODULE_ID_WIFI,MSG_CMD_WIFI_COVERAGE,0,NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_COVERAGE, 0, NULL, 0);
+ //printf("wifi set cmd done!");/*lint !e26*/
+ }
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+static int zte_wlan_ssid1_basic_set(webs_t wp, unsigned int *wifi_set_flags)
+{
+
+ char_t *ssid = NULL;
+ char_t *broadcastssid = NULL ;
+ char_t *NoForwarding = NULL ;
+ char_t *MAX_Access_num = NULL;
+ zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+ char nv_tmp[NVIO_WIFI_MAX_LEN] = {0};
+ char_t *wirelessmode = NULL;
+ char_t *countrycode = NULL;
+ char_t *channel = NULL;
+ char_t *wifi_11n_cap = NULL;
+ char_t *wifi_band = NULL;
+ char_t *show_qrcode_flag = NULL;//main ssid show qrcode flag
+
+ char wifi_sta_connection[8] = {0};
+
+ cfg_get_item("wifi_sta_connection", wifi_sta_connection, sizeof(wifi_sta_connection));
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]wifi_sta_connection=%s\n", __FILE__, __FUNCTION__, wifi_sta_connection);
+
+ //ssid
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ ssid = websGetVar(wp, T("ssid"), NULL);
+#ifdef WEBS_SECURITY
+ if(ssid && !check_web_input_wifi(ssid,strlen(ssid)))
+ {
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]ssid1=%s\n",ssid);
+ return FALSE;
+ }
+#endif
+ if (ssid != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("SSID1", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]old_ssid=[%s], ssid=[%s]", __FILE__, __FUNCTION__, nv_tmp, ssid); /*lint !e26*/
+ //add by liuyingnan for server safe for xss attack start
+#if 0 //kw 3
+ if (DATA_NO_SAFE == zte_Safe_noSpecialCharForSSID(ssid)) {
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]Get Data is no Safe:ssid:%s\n", __FILE__, __FUNCTION__, ssid); /*lint !e26*/
+ return FALSE;
+ }
+#endif
+ //add by liuyingnan for server safe for xss attack end
+ if (0 != strcmp(ssid, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_SSID_SET;
+ status = zte_web_write("SSID1", ssid);
+ wlan_set_change_ssid_key_status();
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]zte_wlan_ssid1_basic_set: write nv [SSID1] fail.", __FILE__, __FUNCTION__); /*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ //broadcastSsidEnabled
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ broadcastssid = websGetVar(wp, T("broadcastSsidEnabled"), NULL);
+
+ if (broadcastssid != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("HideSSID", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"old_HideSSID=[%s], HideSSID=[%s]", nv_tmp, broadcastssid); /*lint !e26*/
+ if (0 != strcmp(broadcastssid, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_BROADCAST_SET;
+ status = zte_web_write("HideSSID", broadcastssid);
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_ssid1_basic_set: write nv [HideSSID] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+#if 0
+ //set NoForwarding(ap isolated)
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ NoForwarding = websGetVar(wp, T("NoForwarding"), NULL);
+ if (NoForwarding != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("NoForwarding", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"old_NoForwarding=[%s], NoForwarding=[%s]", nv_tmp, NoForwarding);/*lint !e26*/
+ if (0 != strcmp(NoForwarding, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_AP_ISOLATION_SET;
+ status = zte_web_write("NoForwarding", NoForwarding);
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_ssid1_basic_set: write nv [NoForwarding] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+#endif
+ //set MAX_Access_num
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ MAX_Access_num = websGetVar(wp, T("MAX_Access_num"), NULL);
+ if (MAX_Access_num != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("MAX_Access_num", nv_tmp);
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]old_MAX_Access_num=[%s], MAX_Access_num=[%s]\n", __FILE__, __FUNCTION__, nv_tmp, MAX_Access_num);
+
+ if (0 != strcmp(MAX_Access_num, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_MAX_ACCESS_NUM_SET;
+ zte_web_write("MAX_Access_num", MAX_Access_num); //kw 3
+ zte_web_write("MAX_Access_num_user_set", "1");
+ }
+ }
+ //set show_qrcode_flag
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ show_qrcode_flag = websGetVar(wp, T("show_qrcode_flag"), NULL);
+ if (show_qrcode_flag != NULL) {
+ (void)zte_web_read("show_qrcode_flag", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]ssid1:old_show_qrcode_flag=[%s], show_qrcode_flag=[%s]\n", __FILE__, __FUNCTION__, nv_tmp, show_qrcode_flag);
+
+ if (0 != strcmp(show_qrcode_flag, nv_tmp)) {
+ status = zte_web_write("show_qrcode_flag", show_qrcode_flag);
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_ssid1_basic_set: write nv [show_qrcode_flag] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+
+
+#if 0
+ //wifiMode
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ wirelessmode = websGetVar(wp, T("wifiMode"), NULL);
+ if (wirelessmode != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ printf("wirelessmode:%s", wirelessmode); /*lint !e26*/
+ (void)zte_web_read("WirelessMode", nv_tmp);
+ printf("[%s][%s]old_WirelessMode=[%s], wirelessmode=[%s]", __FILE__, __FUNCTION__, nv_tmp, wirelessmode); /*lint !e26*/
+ if (0 != strcmp(wirelessmode, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_WIRELESS_MODE_SET;
+ status = zte_web_write("WirelessMode", wirelessmode);
+ if (ZTE_NVIO_DONE != status) {
+ printf("zte_wlan_ssid1_basic_set: write nv [WirelessMode] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ /* country code*/
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ countrycode = websGetVar(wp, T("countryCode"), NULL);
+ if (countrycode != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("CountryCode", nv_tmp);
+ printf("[%s][%s]old_countrycode=%s, countrycode = %s", __FILE__, __FUNCTION__, nv_tmp, countrycode); /*lint !e26*/
+ if (0 != strcmp(countrycode, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_COUNTRY_SET;
+ status = zte_web_write("CountryCode", countrycode);
+ if (ZTE_NVIO_DONE != status) {
+ printf("[%s][%s]zte_wlan_ssid1_basic_set: write nv [CountryCode] fail.", __FILE__, __FUNCTION__); /*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ //selectedChannel
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ channel = websGetVar(wp, T("selectedChannel"), NULL);
+ if (channel != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("Channel", nv_tmp);
+ printf("[%s][%s]old_channel=%s, channel = %s", __FILE__, __FUNCTION__, nv_tmp, channel); /*lint !e26*/
+ if (0 != strcmp(channel, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_CHANNEL_SET;
+ status = zte_web_write("Channel", channel);
+ if (ZTE_NVIO_DONE != status) {
+ printf("zte_wlan_ssid1_basic_set: write nv [Channel] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ //band setting
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ wifi_band = websGetVar(wp, T("wifi_band"), NULL);
+ if (wifi_band != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("wifi_band", nv_tmp);
+ printf("[%s][%s]old_wifi_band=%s, wifi_band = %s", __FILE__, __FUNCTION__, nv_tmp, wifi_band); /*lint !e26*/
+ if (0 != strcmp(wifi_band, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_WIFI_BAND_SET;
+ status = zte_web_write("wifi_band", channel);
+ if (ZTE_NVIO_DONE != status) {
+ printf("zte_wlan_ssid1_basic_set: write nv [wifi_band] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ //set wifi_11n_cap
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ wifi_11n_cap = websGetVar(wp, T("wifi_11n_cap"), NULL);
+ if (wifi_11n_cap != NULL && !(wp->flags & WEBS_XML_CLIENT_REQUEST)) {
+ (void)zte_web_read("wifi_11n_cap", nv_tmp);
+ printf("[%s][%s]old_wifi_11n_cap=%s, wifi_11n_cap=%s", __FILE__, __FUNCTION__, nv_tmp, wifi_11n_cap); /*lint !e26*/
+ if (0 != strcmp(wifi_11n_cap, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_WIRELESS_MODE_SET;
+ status = zte_web_write("wifi_11n_cap", wifi_11n_cap);
+ if (ZTE_NVIO_DONE != status) {
+ printf("zte_wlan_ssid1_basic_set: write nv [wifi_11n_cap] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+#endif
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_ssid1_basic_set: wifi basic setup success.");/*lint !e26*/
+ return TRUE;
+
+}
+
+static int zte_wlan_ssid2_basic_set(webs_t wp, unsigned int *wifi_set_flags)
+{
+ char_t *ssid = NULL;
+ char_t *broadcastssid = NULL ;
+ char_t *NoForwarding = NULL ;
+ char_t *MAX_Access_num = NULL;
+ char_t *show_qrcode_flag = NULL;//guest ssid show qrcode flag
+ zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+ char nv_tmp[NVIO_WIFI_MAX_LEN] = {0};
+
+ if ((NULL == wp) || (NULL == wifi_set_flags)) {
+ return FALSE;
+ }
+
+ //ssid
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ ssid = websGetVar(wp, T("m_SSID"), NULL);
+#ifdef WEBS_SECURITY
+ if(ssid && !check_web_input_wifi(ssid,strlen(ssid)))
+ {
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]ssid2=%s\n",ssid);
+ return FALSE;
+ }
+#endif
+ if (ssid != NULL) {
+ //add by liuyingnan for server safe for xss attack start
+ if (DATA_NO_SAFE == zte_Safe_noSpecialChar(ssid)) {
+ slog(MISC_PRINT, SLOG_DEBUG,"Get Data is no Safe:ssid:%s\n", ssid); /*lint !e26*/
+ return FALSE;
+ }
+ //add by liuyingnan for server safe for xss attack end
+ (void)zte_web_read("m_SSID", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"old_m_SSID=[%s], m_SSID=[%s]", nv_tmp, ssid); /*lint !e26*/
+ if (0 != strcmp(ssid, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ status = zte_web_write("m_SSID", ssid);
+ wlan_set_change_ssid_key_status();//added by dujiajiao
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_ssid2_basic_set: write nv [m_SSID] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ //broadcastSsidEnabled
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ broadcastssid = websGetVar(wp, T("m_HideSSID"), NULL);
+ if (broadcastssid != NULL) {
+ (void)zte_web_read("m_HideSSID", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"old_m_HideSSID=[%s], m_HideSSID=[%s]", nv_tmp, broadcastssid); /*lint !e26*/
+ if (0 != strcmp(broadcastssid, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ status = zte_web_write("m_HideSSID", broadcastssid);
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_ssid2_basic_set: write nv [m_HideSSID] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+
+ //set NoForwarding
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ NoForwarding = websGetVar(wp, T("m_NoForwarding"), NULL);
+ if (NoForwarding != NULL) {
+ (void)zte_web_read("m_NoForwarding", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"old_m_NoForwarding=[%s], m_NoForwarding=[%s]", nv_tmp, NoForwarding);/*lint !e26*/
+ if (0 != strcmp(NoForwarding, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ status = zte_web_write("m_NoForwarding", NoForwarding);
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_ssid1_basic_set: write nv [m_NoForwarding] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ //set MAX_Access_num
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ MAX_Access_num = websGetVar(wp, T("m_MAX_Access_num"), NULL);
+ if (MAX_Access_num != NULL) {
+ (void)zte_web_read("m_MAX_Access_num", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"old_m_MAX_Access_num=[%s], m_MAX_Access_num=[%s]", nv_tmp, MAX_Access_num);/*lint !e26*/
+ if (0 != strcmp(MAX_Access_num, nv_tmp)) {
+ *wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ status = zte_web_write("m_MAX_Access_num", MAX_Access_num);
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_ssid2_basic_set: write nv [MAX_Access_num] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+ //set show_qrcode_flag
+ memset(nv_tmp, 0, sizeof(nv_tmp));
+ show_qrcode_flag = websGetVar(wp, T("m_show_qrcode_flag"), NULL);
+ if (show_qrcode_flag != NULL) {
+ (void)zte_web_read("m_show_qrcode_flag", nv_tmp);
+ slog(MISC_PRINT, SLOG_DEBUG,"ssid2: old_show_qrcode_flag=[%s], show_qrcode_flag=[%s]", nv_tmp, show_qrcode_flag);/*lint !e26*/
+ if (0 != strcmp(show_qrcode_flag, nv_tmp)) {
+ status = zte_web_write("m_show_qrcode_flag", show_qrcode_flag);
+ if (ZTE_NVIO_DONE != status) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_ssid2_basic_set: write nv [show_qrcode_flag] fail.");/*lint !e26*/
+ return FALSE;
+ }
+ }
+ }
+
+
+
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_wlan_ssid2_basic_set: wifi basic setup success.");/*lint !e26*/
+ return TRUE;
+
+}
+
+static int zte_lan_ssid1_security_set(webs_t wp, unsigned int *wifi_set_flags)
+{
+#define KEY_INDEX_MAX 5
+
+ char_t *security_mode = NULL;
+ char *encryp_type = NULL;
+ int i = 0;
+ char_t *pass_phrase_str = NULL;
+ //add by liuyingnan for Server safe start
+ int pass_phrase_str_decode_length = 0;
+ char_t *pass_phrase_str_decode = NULL;
+#ifdef WEBS_SECURITY
+ char_t *pass_phrase_b64_encode = NULL;
+#endif
+ char_t zte_pass_phrase_str[WIFI_PSW_DEFAULT_LENGTH] = {0};
+ int zte_pass_phrase_len = 0;
+ //add by liuyingnan for Server safe end
+
+ char_t *DefaultKeyID = NULL;
+ char_t * KeyType[KEY_INDEX_MAX];
+ char_t * KeyStr[KEY_INDEX_MAX];
+
+ char_t *cipher_str = NULL;
+ char_t wpa_encry_type[WF_ENCRY_TYPE_LEN] = {0};
+
+ zte_topsw_state_e_type nv_ret = ZTE_NVIO_DONE; /*lint -e550*/
+
+ uint8 nv_au_mode[WF_AU_MODE_LEN] = {0};
+ uint8 nv_ecry_type[WF_ENCRY_TYPE_LEN] = {0};
+ char_t psw[NV_ITEM_VALUE_DEFAULT_STRING_LEN] = {0};
+ //char nv_basic[NVIO_WIFI_MAX_LEN]={0}; // for nv read and write
+
+ /*lint -e717*/
+#define SECURITY_NV_WRITE(nv_name, str, ret) do{ ret = zte_web_write(nv_name, (char *)str);}while(0)
+
+ memset(KeyType, 0, sizeof(KeyType)); //set 0
+ memset(KeyStr, 0, sizeof(KeyStr)); //set 0
+
+ if ((NULL == wp) || (NULL == wifi_set_flags)) {
+ slog(MISC_PRINT, SLOG_ERR,"[%s][%s]input para is null.\n", __FILE__, __FUNCTION__); /*lint !e26*/
+ return -1;
+ }
+
+ security_mode = websGetVar(wp, T("security_mode"), NULL);
+ if (security_mode != NULL) {
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]security_mode = [%s]", __FILE__, __FUNCTION__, security_mode); /*lint !e26*/
+
+ encryp_type = websGetVar(wp, T("security_shared_mode"), NULL);
+ if (NULL == encryp_type) {
+ slog(MISC_PRINT, SLOG_ERR,"encryp_type == NULL");/*lint !e26*/
+ return -1;
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]encryp_type = [%s]", __FILE__, __FUNCTION__, encryp_type); /*lint !e26*/
+
+ if (STR_EQUAL(security_mode, WF_AU_OPEN) || STR_EQUAL(security_mode, WF_AU_SHARE)) {
+ if ((STR_EQUAL(security_mode, WF_AU_OPEN) && STR_EQUAL(encryp_type, WF_ENCRY_WEP)) ||
+ (STR_EQUAL(security_mode, WF_AU_SHARE))) { //&&STR_EQUAL(wifi_encry_type, WF_AU_OPEN)) )
+ zte_wifi_open_and_share_mode_s_type nv_open_and_share_s;
+ memset(&nv_open_and_share_s, 0, sizeof(zte_wifi_open_and_share_mode_s_type));
+
+ //read nv
+ (void)zte_web_read("AuthMode", nv_au_mode);
+ (void)zte_web_read("EncrypType", nv_ecry_type);
+ (void)zte_web_read("DefaultKeyID", nv_open_and_share_s.wep_key_index);
+ (void)zte_web_read("Key1Str1", nv_open_and_share_s.wep_key1);
+ (void)zte_web_read("Key2Str1", nv_open_and_share_s.wep_key2);
+ (void)zte_web_read("Key3Str1", nv_open_and_share_s.wep_key3);
+ (void)zte_web_read("Key4Str1", nv_open_and_share_s.wep_key4);
+ (void)zte_web_read("Key1Type", nv_open_and_share_s.wep_key1_mode);
+ (void)zte_web_read("Key2Type", nv_open_and_share_s.wep_key2_mode);
+ (void)zte_web_read("Key3Type", nv_open_and_share_s.wep_key3_mode);
+ (void)zte_web_read("Key4Type", nv_open_and_share_s.wep_key4_mode);
+
+ DefaultKeyID = websGetVar(wp, T("wep_default_key"), "");
+ KeyStr[1] = websGetVar(wp, T("wep_key_1"), "");
+ KeyStr[2] = websGetVar(wp, T("wep_key_2"), "");
+ KeyStr[3] = websGetVar(wp, T("wep_key_3"), "");
+ KeyStr[4] = websGetVar(wp, T("wep_key_4"), "");
+ KeyType[1] = websGetVar(wp, T("WEP1Select"), "");
+ KeyType[2] = websGetVar(wp, T("WEP2Select"), "");
+ KeyType[3] = websGetVar(wp, T("WEP3Select"), "");
+ KeyType[4] = websGetVar(wp, T("WEP4Select"), "");
+
+ //when the wifi setting has changed,then set them
+ if (STR_EQUAL(security_mode, nv_au_mode) && STR_EQUAL(encryp_type, nv_ecry_type) \
+ && STR_EQUAL(DefaultKeyID, nv_open_and_share_s.wep_key_index) \
+ && STR_EQUAL(KeyStr[1], nv_open_and_share_s.wep_key1) && STR_EQUAL(KeyStr[2], nv_open_and_share_s.wep_key2) && STR_EQUAL(KeyStr[3], nv_open_and_share_s.wep_key3) && STR_EQUAL(KeyStr[4], nv_open_and_share_s.wep_key4) \
+ && STR_EQUAL(KeyType[1], nv_open_and_share_s.wep_key1_mode) && STR_EQUAL(KeyType[2], nv_open_and_share_s.wep_key2_mode) && STR_EQUAL(KeyType[3], nv_open_and_share_s.wep_key3_mode) && STR_EQUAL(KeyType[4], nv_open_and_share_s.wep_key4_mode)) {
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]wifi:[%s][%s] not changed.\n", __FILE__, __FUNCTION__, security_mode, encryp_type); /*lint !e26*/
+ } else {
+ SECURITY_NV_WRITE("AuthMode", security_mode, nv_ret);
+ SECURITY_NV_WRITE("EncrypType", encryp_type, nv_ret);
+
+ SECURITY_NV_WRITE("DefaultKeyID", DefaultKeyID, nv_ret);
+
+ SECURITY_NV_WRITE("Key1Str1", KeyStr[1], nv_ret);
+ SECURITY_NV_WRITE("Key2Str1", KeyStr[2], nv_ret);
+ SECURITY_NV_WRITE("Key3Str1", KeyStr[3], nv_ret);
+ SECURITY_NV_WRITE("Key4Str1", KeyStr[4], nv_ret);
+
+ SECURITY_NV_WRITE("Key1Type", KeyType[1], nv_ret);
+ SECURITY_NV_WRITE("Key2Type", KeyType[2], nv_ret);
+ SECURITY_NV_WRITE("Key3Type", KeyType[3], nv_ret);
+ SECURITY_NV_WRITE("Key4Type", KeyType[4], nv_ret);
+
+ *wifi_set_flags |= ZTE_WLAN_BASIC_SECURITY_SET;
+ wlan_set_change_ssid_key_status();
+ }
+ } else if (STR_EQUAL(security_mode, WF_AU_OPEN) && STR_EQUAL(encryp_type, WF_ENCRY_NONE)) {
+ (void)zte_web_read("AuthMode",nv_au_mode);
+ (void)zte_web_read("EncrypType", nv_ecry_type);
+
+ if (STR_EQUAL(security_mode, nv_au_mode) && STR_EQUAL(encryp_type, nv_ecry_type)) {
+ printf("[%s][%s]wifi:[%s][%s] not changed.\n", __FILE__, __FUNCTION__, security_mode, encryp_type); /*lint !e26*/
+ } else {
+ SECURITY_NV_WRITE("AuthMode", security_mode, nv_ret);
+ SECURITY_NV_WRITE("EncrypType", encryp_type, nv_ret);
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_ENCODE, "", nv_ret);
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS, "", nv_ret);
+ SECURITY_NV_WRITE("Key1Str1", "", nv_ret);
+ SECURITY_NV_WRITE("Key2Str1", "", nv_ret);
+ SECURITY_NV_WRITE("Key3Str1", "", nv_ret);
+ SECURITY_NV_WRITE("Key4Str1", "", nv_ret);
+ *wifi_set_flags |= ZTE_WLAN_BASIC_SECURITY_SET;
+ wlan_set_change_ssid_key_status();
+ }
+ } else {
+ //wifi_au_mode or encrype invalid
+ slog(MISC_PRINT, SLOG_ERR,"[%s][%s]wifi:[%s][%s] is invalid.\n", __FILE__, __FUNCTION__, security_mode, encryp_type); /*lint !e26*/
+ return -1;
+ }
+ } else if (STR_EQUAL(security_mode, WF_AU_WPA) || STR_EQUAL(security_mode, WF_AU_WPA2) ||
+ STR_EQUAL(security_mode, WF_AU_WPA_WPA2) || STR_EQUAL(security_mode, WF_AU_WPA3) || STR_EQUAL(security_mode, WF_AU_WPA2_WPA3)) {
+ zte_wifi_wpa_and_wpa2_mode_s_type nv_wpa_and_wpa2;
+ memset(&nv_wpa_and_wpa2, 0, sizeof(zte_wifi_wpa_and_wpa2_mode_s_type));
+
+ pass_phrase_str = websGetVar(wp, T("passphrase"), "");
+ int j = 0;
+ for (i = 0; i < strlen(pass_phrase_str) && j < NV_ITEM_VALUE_DEFAULT_STRING_LEN; i++) {
+ if (pass_phrase_str[i] != '\r' && pass_phrase_str[i] != '\n') {
+ psw[j] = pass_phrase_str[i];
+ j++;
+ }
+ }
+ pass_phrase_str = psw;
+ if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+ cipher_str = websGetVar(wp, T("cipher"), "");
+ } else {
+#ifndef CONFIG_CHINA_UNICOM
+ if (STR_EQUAL(security_mode, WF_AU_WPA_WPA2)) {
+ cipher_str = websGetVar(wp, T("cipher_str"), "");
+ } else
+#endif
+ {
+ cipher_str = websGetVar(wp, T("cipher"), "");
+ }
+ }
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]pass_phrase_str = %s", __FILE__, __FUNCTION__, pass_phrase_str); /*lint !e26*/
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]cipher_str = %s", __FILE__, __FUNCTION__, cipher_str); /*lint !e26*/
+ //add by liuyingnan for server safe for xss attack start
+ if (DATA_NO_SAFE == zte_Safe_noSpecialChar(pass_phrase_str)) {
+ slog(MISC_PRINT, SLOG_ERR,"Get Data is no Safe:ssid:%s\n", pass_phrase_str); /*lint !e26*/
+ return -1;
+ }
+ //add by liuyingnan for server safe for xss attack end
+
+ switch (cipher_str[0]) {
+ case '0':
+ strncpy(wpa_encry_type, WF_ENCRY_TKIP, sizeof(wpa_encry_type) - 1);
+ break;
+ case '1':
+ strncpy(wpa_encry_type, WF_ENCRY_AES, sizeof(wpa_encry_type) - 1);
+ break;
+ case '2':
+ strncpy(wpa_encry_type, WF_ENCRY_TKIP_AES, sizeof(wpa_encry_type) - 1);
+ break;
+ default:
+ slog(MISC_PRINT, SLOG_ERR,"unvalid encry type [%c]", encryp_type[0], 0, 0);
+ return -1;
+ }
+
+ (void)zte_web_read("AuthMode", nv_au_mode);
+ (void)zte_web_read("EncrypType", nv_ecry_type);
+ (void)zte_web_read(NV_WIFI_WPA_PASS, nv_wpa_and_wpa2.pre_share_key);
+
+ if (STR_EQUAL(security_mode, nv_au_mode) && STR_EQUAL(wpa_encry_type, nv_ecry_type) && STR_EQUAL(pass_phrase_str, nv_wpa_and_wpa2.pre_share_key)) {
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]wifi:[%s][%s] not changed.\n", __FILE__, __FUNCTION__, security_mode, wpa_encry_type); /*lint !e26*/
+ } else {
+ SECURITY_NV_WRITE("AuthMode", security_mode, nv_ret);
+ SECURITY_NV_WRITE("EncrypType", wpa_encry_type, nv_ret);
+#ifndef CONFIG_CHINA_UNICOM
+ if (STR_EQUAL(security_mode, WF_AU_WPA_WPA2)) {
+#endif
+ SECURITY_NV_WRITE("cipher_str", cipher_str, nv_ret);
+#ifndef CONFIG_CHINA_UNICOM
+ }
+#endif
+ //add by liuyingnan for Server safe start
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]pass_phrase_str:%s.\n", __FILE__, __FUNCTION__, pass_phrase_str); /*lint !e26*/
+#ifdef WEBS_SECURITY
+ pass_phrase_str_decode = js_aes_decode(pass_phrase_str, strlen(pass_phrase_str), (unsigned int*)&pass_phrase_str_decode_length);
+#else
+ pass_phrase_str_decode = (char*)zte_base64_decode((const unsigned char *)pass_phrase_str, strlen(pass_phrase_str), (unsigned int*)&pass_phrase_str_decode_length);
+#endif
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s][%s]login2 -> zte_password:%s.\n", __FILE__, __FUNCTION__, pass_phrase_str_decode); /*lint !e26*/
+
+ if (NULL == pass_phrase_str_decode) {
+ slog(MISC_PRINT, SLOG_DEBUG,"pass_phrase_str_decode: psw is empty.\n");/*lint !e26*/
+ free(pass_phrase_str_decode);
+ return -1;
+ }
+ zte_pass_phrase_len = (pass_phrase_str_decode_length < sizeof(zte_pass_phrase_str) ? pass_phrase_str_decode_length : sizeof(zte_pass_phrase_str) - 1);
+ snprintf(zte_pass_phrase_str,zte_pass_phrase_len+1,"%s",pass_phrase_str_decode);
+ //strncpy(zte_pass_phrase_str, pass_phrase_str_decode, zte_pass_phrase_len);
+ free(pass_phrase_str_decode);
+ slog(MISC_PRINT, SLOG_DEBUG,"login3 -> zte_psw_admin:%s.\n", zte_pass_phrase_str); //cov m
+#ifdef WEBS_SECURITY
+ if(zte_pass_phrase_str && !check_web_input_wifi(zte_pass_phrase_str,strlen(zte_pass_phrase_str)))
+ {
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]wifipass1=%s\n",zte_pass_phrase_str);
+ return -1;
+ }
+ pass_phrase_b64_encode = zte_base64_encode(zte_pass_phrase_str, strlen(zte_pass_phrase_str));
+ if (NULL == pass_phrase_b64_encode) {
+ slog(MISC_PRINT, SLOG_DEBUG,"pass_phrase_b64_encode: psw is NULL.\n");/*lint !e26*/
+ return -1;
+ }
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_ENCODE, pass_phrase_b64_encode, nv_ret);
+ free(pass_phrase_b64_encode);
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS, zte_pass_phrase_str, nv_ret);
+ SECURITY_NV_WRITE("WPAPSK1_enaes", pass_phrase_str, nv_ret);
+#else
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_ENCODE, pass_phrase_str, nv_ret);
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS, zte_pass_phrase_str, nv_ret);
+#endif
+ //add by liuyingnan for Server safe end
+ //SECURITY_NV_WRITE(NV_WIFI_WPA_PASS, pass_phrase_str, nv_ret);
+
+ *wifi_set_flags |= ZTE_WLAN_BASIC_SECURITY_SET;
+ wlan_set_change_ssid_key_status();
+ }
+ } else {
+ // other security mode is invalid
+ slog(MISC_PRINT, SLOG_ERR,"ERROR:security mode is invalid", 0, 0, 0);/*lint !e26*/
+ return -1;
+ }
+ } else {
+ //security_mode is NULL
+ slog(MISC_PRINT, SLOG_ERR,"ERROR:security_mode is NULL ", 0, 0, 0);/*lint !e26*/
+ return -1;
+ }
+
+ return 0;
+
+}
+
+/**********************************************************************
+* Function: zte_lan_ssid2_security_set
+* Description: to set the wifi security paras for SSID2
+* Input: http info
+* Output:
+* Return: 0:ok;-1:fail
+* Others:
+* Modify Date Version Author Modification
+* -----------------------------------------------
+* 2012/07/11 V1.0 chenyi first version
+**********************************************************************/
+/*lint -e{818,830}*/
+static int zte_lan_ssid2_security_set(webs_t wp, unsigned int *wifi_set_flags) /*lint !e533*/
+{
+#define KEY_INDEX_MAX 5
+
+ char_t *security_mode = NULL;
+ char *encryp_type = NULL;
+
+ char_t *pass_phrase_str = NULL;
+ //add by liuyingnan for Server safe start
+ int pass_phrase_str_decode_length = 0;
+ char_t *pass_phrase_str_decode = NULL;
+#ifdef WEBS_SECURITY
+ char_t *pass_phrase_b64_encode = NULL;
+#endif
+ char_t zte_pass_phrase_str[WIFI_PSW_DEFAULT_LENGTH] = {0};
+ int zte_pass_phrase_len = 0;
+ //add by liuyingnan for Server safe end
+
+ char_t *DefaultKeyID = NULL;
+ char_t * KeyType[KEY_INDEX_MAX];
+ char_t * KeyStr[KEY_INDEX_MAX];
+
+ char_t *cipher_str = NULL;
+ char_t wpa_encry_type[WF_ENCRY_TYPE_LEN] = {0};
+
+ zte_topsw_state_e_type nv_ret = ZTE_NVIO_DONE; /*lint -e550*/
+
+ uint8 nv_au_mode[WF_AU_MODE_LEN] = {0};
+ uint8 nv_ecry_type[WF_ENCRY_TYPE_LEN] = {0};
+
+ //char nv_basic[NVIO_WIFI_MAX_LEN]={0}; // for nv read and write
+
+ /*lint -e717*/
+#define SECURITY_NV_WRITE(nv_name, str, ret) do{ ret = zte_web_write(nv_name, (char *)str);}while(0)
+
+ memset(KeyType, 0, sizeof(KeyType)); //set 0
+ memset(KeyStr, 0, sizeof(KeyStr)); //set 0
+
+ if ((NULL == wp) || (NULL == wifi_set_flags)) {
+ slog(MISC_PRINT, SLOG_ERR,"input para is null.\n");/*lint !e26*/
+ return -1;
+ }
+
+ security_mode = websGetVar(wp, T("m_AuthMode"), NULL);
+ if (security_mode != NULL) {
+ slog(MISC_PRINT, SLOG_DEBUG,"security_mode = [%s]", security_mode);/*lint !e26*/
+
+ encryp_type = websGetVar(wp, T("m_EncrypType"), NULL);
+ if (NULL == encryp_type) {
+ slog(MISC_PRINT, SLOG_DEBUG,"encryp_type == NULL", 0, 0, 0);/*lint !e26*/
+ return -1;
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG,"encryp_type = [%s]", encryp_type); /*lint !e26*/
+
+ if (STR_EQUAL(security_mode, WF_AU_OPEN) || STR_EQUAL(security_mode, WF_AU_SHARE)) {
+ if ((STR_EQUAL(security_mode, WF_AU_OPEN) && STR_EQUAL(encryp_type, WF_ENCRY_WEP)) ||
+ (STR_EQUAL(security_mode, WF_AU_SHARE))) { //&&STR_EQUAL(wifi_encry_type, WF_AU_OPEN)) )
+ zte_wifi_open_and_share_mode_s_type nv_open_and_share_s;
+ memset(&nv_open_and_share_s, 0, sizeof(zte_wifi_open_and_share_mode_s_type));
+
+ //read nv
+ (void)zte_web_read("m_AuthMode", nv_au_mode);
+ (void)zte_web_read("m_EncrypType", nv_ecry_type);
+ (void)zte_web_read("m_DefaultKeyID", nv_open_and_share_s.wep_key_index);
+ (void)zte_web_read("m_Key1Str1", nv_open_and_share_s.wep_key1);
+ (void)zte_web_read("m_Key2Str1", nv_open_and_share_s.wep_key2);
+ (void)zte_web_read("m_Key3Str1", nv_open_and_share_s.wep_key3);
+ (void)zte_web_read("m_Key4Str1", nv_open_and_share_s.wep_key4);
+ (void)zte_web_read("m_Key1Type", nv_open_and_share_s.wep_key1_mode);
+ (void)zte_web_read("m_Key2Type", nv_open_and_share_s.wep_key2_mode);
+ (void)zte_web_read("m_Key3Type", nv_open_and_share_s.wep_key3_mode);
+ (void)zte_web_read("m_Key4Type", nv_open_and_share_s.wep_key4_mode);
+
+ DefaultKeyID = websGetVar(wp, T("m_DefaultKeyID"), "");
+ KeyStr[1] = websGetVar(wp, T("m_Key1Str1"), "");
+ KeyStr[2] = websGetVar(wp, T("m_Key2Str1"), "");
+ KeyStr[3] = websGetVar(wp, T("m_Key3Str1"), "");
+ KeyStr[4] = websGetVar(wp, T("m_Key4Str1"), "");
+ KeyType[1] = websGetVar(wp, T("m_Key1Type"), "");
+ KeyType[2] = websGetVar(wp, T("m_Key2Type"), "");
+ KeyType[3] = websGetVar(wp, T("m_Key3Type"), "");
+ KeyType[4] = websGetVar(wp, T("m_Key4Type"), "");
+
+ //when the wifi setting has changed,then set them
+ if (STR_EQUAL(security_mode, nv_au_mode) && STR_EQUAL(encryp_type, nv_ecry_type) \
+ && STR_EQUAL(DefaultKeyID, nv_open_and_share_s.wep_key_index) \
+ && STR_EQUAL(KeyStr[1], nv_open_and_share_s.wep_key1) && STR_EQUAL(KeyStr[2], nv_open_and_share_s.wep_key2) && STR_EQUAL(KeyStr[3], nv_open_and_share_s.wep_key3) && STR_EQUAL(KeyStr[4], nv_open_and_share_s.wep_key4) \
+ && STR_EQUAL(KeyType[1], nv_open_and_share_s.wep_key1_mode) && STR_EQUAL(KeyType[2], nv_open_and_share_s.wep_key2_mode) && STR_EQUAL(KeyType[3], nv_open_and_share_s.wep_key3_mode) && STR_EQUAL(KeyType[4], nv_open_and_share_s.wep_key4_mode)) {
+
+ printf("wifi:[%s][%s] not changed.\n", security_mode, encryp_type); /*lint !e26*/
+ } else {
+ SECURITY_NV_WRITE("m_AuthMode", security_mode, nv_ret);
+ SECURITY_NV_WRITE("m_EncrypType", encryp_type, nv_ret);
+
+ SECURITY_NV_WRITE("m_DefaultKeyID", DefaultKeyID, nv_ret);
+
+ SECURITY_NV_WRITE("m_Key1Str1", KeyStr[1], nv_ret);
+ SECURITY_NV_WRITE("m_Key2Str1", KeyStr[2], nv_ret);
+ SECURITY_NV_WRITE("m_Key3Str1", KeyStr[3], nv_ret);
+ SECURITY_NV_WRITE("m_Key4Str1", KeyStr[4], nv_ret);
+
+ SECURITY_NV_WRITE("m_Key1Type", KeyType[1], nv_ret);
+ SECURITY_NV_WRITE("m_Key2Type", KeyType[2], nv_ret);
+ SECURITY_NV_WRITE("m_Key3Type", KeyType[3], nv_ret);
+ SECURITY_NV_WRITE("m_Key4Type", KeyType[4], nv_ret);
+
+ *wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ wlan_set_change_ssid_key_status(); //added by dujiajiao
+ }
+ } else if (STR_EQUAL(security_mode, WF_AU_OPEN) && STR_EQUAL(encryp_type, WF_ENCRY_NONE)) {
+ (void)zte_web_read("m_AuthMode", nv_au_mode);
+ (void)zte_web_read("m_EncrypType", nv_ecry_type);
+
+ if (STR_EQUAL(security_mode, nv_au_mode) && STR_EQUAL(encryp_type, nv_ecry_type)) {
+ slog(MISC_PRINT, SLOG_NORMAL,"wifi:[%s][%s] not changed.\n", security_mode, encryp_type); /*lint !e26*/
+ } else {
+ SECURITY_NV_WRITE("m_AuthMode", security_mode, nv_ret);
+ SECURITY_NV_WRITE("m_EncrypType", encryp_type, nv_ret);
+ /* added by dujiajiao, in open&no encrypt condition, there is no password */
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_M_ENCODE, "", nv_ret);
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_M, "", nv_ret);
+ SECURITY_NV_WRITE("m_Key1Str1", "", nv_ret);
+ SECURITY_NV_WRITE("m_Key2Str1", "", nv_ret);
+ SECURITY_NV_WRITE("m_Key3Str1", "", nv_ret);
+ SECURITY_NV_WRITE("m_Key4Str1", "", nv_ret);
+ /*added by dujiajiao end */
+ *wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ wlan_set_change_ssid_key_status(); //added by dujiajiao
+ }
+ } else {
+ //wifi_au_mode or encrype invalid
+ slog(MISC_PRINT, SLOG_ERR,"wifi:[%s][%s] is invalid.\n", security_mode, encryp_type); /*lint !e26*/
+ return -1;
+ }
+ } else if (STR_EQUAL(security_mode, WF_AU_WPA) || STR_EQUAL(security_mode, WF_AU_WPA2) ||
+ STR_EQUAL(security_mode, WF_AU_WPA_WPA2) || STR_EQUAL(security_mode, WF_AU_WPA3) || STR_EQUAL(security_mode, WF_AU_WPA2_WPA3)) {
+ zte_wifi_wpa_and_wpa2_mode_s_type nv_wpa_and_wpa2;
+ memset(&nv_wpa_and_wpa2, 0, sizeof(zte_wifi_wpa_and_wpa2_mode_s_type));
+
+ pass_phrase_str = websGetVar(wp, T(NV_WIFI_WPA_PASS_M), "");
+ cipher_str = websGetVar(wp, T("cipher"), "");
+
+ slog(MISC_PRINT, SLOG_DEBUG,"pass_phrase_str = %s", pass_phrase_str); /*lint !e26*/
+ slog(MISC_PRINT, SLOG_DEBUG,"cipher_str = %s", cipher_str); /*lint !e26*/
+
+ //add by liuyingnan for server safe for xss attack start
+ if (DATA_NO_SAFE == zte_Safe_noSpecialChar(pass_phrase_str)) {
+ printf("Get Data is no Safe:ssid:%s\n", pass_phrase_str); /*lint !e26*/
+ return -1;
+ }
+ //add by liuyingnan for server safe for xss attack end
+
+ switch (cipher_str[0]) {
+ case '0':
+ strncpy(wpa_encry_type, WF_ENCRY_TKIP, sizeof(wpa_encry_type) - 1);
+ break;
+ case '1':
+ strncpy(wpa_encry_type, WF_ENCRY_AES, sizeof(wpa_encry_type) - 1);
+ break;
+ case '2':
+ strncpy(wpa_encry_type, WF_ENCRY_TKIP_AES, sizeof(wpa_encry_type) - 1);
+ break;
+ default:
+ printf("unvalid encry type [%c]", encryp_type[0]);/*lint !e26*/
+ return -1;
+ }
+
+ (void)zte_web_read("m_AuthMode", nv_au_mode);
+ (void)zte_web_read("m_EncrypType", nv_ecry_type);
+ (void)zte_web_read(NV_WIFI_WPA_PASS_M, nv_wpa_and_wpa2.pre_share_key);
+
+ if (STR_EQUAL(security_mode, nv_au_mode) && STR_EQUAL(wpa_encry_type, nv_ecry_type) && STR_EQUAL(pass_phrase_str, nv_wpa_and_wpa2.pre_share_key)) {
+
+ slog(MISC_PRINT, SLOG_NORMAL,"wifi:[%s][%s] not changed.\n", security_mode, wpa_encry_type); /*lint !e26*/
+ } else {
+ SECURITY_NV_WRITE("m_AuthMode", security_mode, nv_ret);
+ SECURITY_NV_WRITE("m_EncrypType", wpa_encry_type, nv_ret);
+ //add by liuyingnan for Server safe start
+ slog(MISC_PRINT, SLOG_DEBUG,"pass_phrase_str:%s.\n", pass_phrase_str); /*lint !e26*/
+#ifdef WEBS_SECURITY
+ pass_phrase_str_decode = js_aes_decode(pass_phrase_str, strlen(pass_phrase_str), (unsigned int)&pass_phrase_str_decode_length);
+#else
+ pass_phrase_str_decode = (char*)zte_base64_decode((const unsigned char *)pass_phrase_str, strlen(pass_phrase_str), (unsigned int)&pass_phrase_str_decode_length);
+#endif
+ slog(MISC_PRINT, SLOG_DEBUG,"pass_phrase_str_decode:%s.\n", pass_phrase_str_decode); /*lint !e26*/
+
+ if (NULL == pass_phrase_str_decode) {
+ slog(MISC_PRINT, SLOG_DEBUG,"pass_phrase_str_decode: psw is empty.\n");/*lint !e26*/
+ free(pass_phrase_str_decode);
+ return -1;
+ }
+ zte_pass_phrase_len = (pass_phrase_str_decode_length < sizeof(zte_pass_phrase_str) ? pass_phrase_str_decode_length : sizeof(zte_pass_phrase_str) - 1);
+ snprintf(zte_pass_phrase_str,zte_pass_phrase_len+1,"%s",pass_phrase_str_decode);
+ //strncpy(zte_pass_phrase_str, pass_phrase_str_decode, zte_pass_phrase_len);
+ free(pass_phrase_str_decode);
+ slog(MISC_PRINT, SLOG_DEBUG,"login3 -> zte_pass_phrase_str:%s.\n", zte_pass_phrase_str); //cov m
+#ifdef WEBS_SECURITY
+ if(zte_pass_phrase_str && !check_web_input_wifi(zte_pass_phrase_str,strlen(zte_pass_phrase_str)))
+ {
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]wifipass2=%s\n",zte_pass_phrase_str);
+ return -1;
+ }
+ pass_phrase_b64_encode = zte_base64_encode(zte_pass_phrase_str, strlen(zte_pass_phrase_str));
+ if (NULL == pass_phrase_b64_encode) {
+ slog(MISC_PRINT, SLOG_DEBUG,"pass_phrase_b64_encode: psw is NULL.\n");/*lint !e26*/
+ return -1;
+ }
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_M_ENCODE, pass_phrase_b64_encode, nv_ret);
+ free(pass_phrase_b64_encode);
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_M, zte_pass_phrase_str, nv_ret);
+ SECURITY_NV_WRITE("m_WPAPSK1_enaes", pass_phrase_str, nv_ret);
+#else
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_M_ENCODE, pass_phrase_str, nv_ret);
+ SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_M, zte_pass_phrase_str, nv_ret);
+#endif
+ //add by liuyingnan for Server safe end
+ //SECURITY_NV_WRITE(NV_WIFI_WPA_PASS_M, pass_phrase_str, nv_ret);
+
+ *wifi_set_flags |= ZTE_WLAN_SET_AP_MSSID;
+ wlan_set_change_ssid_key_status(); //added by dujiajiao
+ }
+ } else {
+ // other security mode is invalid
+ slog(MISC_PRINT, SLOG_ERR,"ERROR:security mode is invalid");/*lint !e26*/
+ return -1;
+ }
+ } else {
+ //security_mode is NULL
+ slog(MISC_PRINT, SLOG_ERR,"ERROR:security_mode is NULL ");/*lint !e26*/
+ return -1;
+ }
+
+ return 0;
+
+}
+
+void zte_wlan_set_tsw(webs_t wp)
+{
+ char * openEnable = NULL;
+ char * closeEnable = NULL;
+ char * openTime = NULL;
+ char * closeTime = NULL;
+ char old_open_time[16] = {0};
+ char old_close_time[16] = {0};
+ char old_open_enable[16] = {0};
+ char tsw_sleep_time_hour[16] = {0};
+ char tsw_sleep_time_min[16] = {0};
+ char tsw_wake_time_hour[16] = {0};
+ char tsw_wake_time_min[16] = {0};
+ char *tmp = NULL;
+ int tsw_change_flag = 0;
+ cfg_get_item("openEnable", old_open_enable, sizeof(old_open_enable));
+
+ cfg_get_item("openTime", old_open_time, sizeof(old_open_time));
+
+ cfg_get_item("closeTime", old_close_time, sizeof(old_close_time));
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s]old_open_enable=%s,old_open_time=%s,old_close_time=%s\n", __FUNCTION__, old_open_enable, old_open_time, old_close_time);
+ openEnable = websGetVar(wp, T("openEnable"), T(""));
+ closeEnable = websGetVar(wp, T("closeEnable"), T(""));
+ openTime = websGetVar(wp, T("openTime"), T(""));
+ closeTime = websGetVar(wp, T("closeTime"), T(""));
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s]openEnable=%s,closeEnable=%s,openTime=%s,closeTime=%s\n", __FUNCTION__, openEnable, closeEnable, openTime, closeTime);
+
+ //check the param: openEnable & closeEnable
+ if (NULL == openEnable || '\0' == *openEnable || NULL == closeEnable || '\0' == *closeEnable) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_set_tsw: **open/close**invalid input para.\n");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ //if swtich is open , then check the param: openTime & closeTime
+ if (strcmp(openEnable, "1") == 0) {
+ if (NULL == openTime || '\0' == *openTime || NULL == closeTime || '\0' == *closeTime) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_wlan_set_tsw: **open**invalid input para:openTime /closeTime.\n");/*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ }
+ cfg_set("openEnable", openEnable);
+ cfg_set("closeEnable", closeEnable);
+
+ //send msg to wlan-server to close timing sleep wake up
+ if (strcmp(openEnable, "0") == 0 && strcmp(old_open_enable, "1") == 0) {
+ tsw_change_flag = 1;
+ slog(MISC_PRINT, SLOG_NORMAL,"send to wlan-server : MSG_CMD_WIFI_TSW_CLOSE\n");
+ //zte_send_message(MODULE_ID_WIFI,MSG_CMD_WIFI_TSW_CLOSE,0,NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_TSW_CLOSE, 0, NULL, 0);
+
+ }
+ // 1.if current openEnable is 1, and old_open_enable is 0, then send msg to wlan-server to setup tsw
+ // 2. if current openEnable is 1, and openTime is changed or closeTime changed, then send msg to wlan-server to setup tsw
+ else if ((strcmp(openEnable, "1") == 0 && strcmp(old_open_enable, "0") == 0) || \
+ ((strcmp(openEnable, "1") == 0) && (strcmp(openTime, old_open_time) != 0 || strcmp(closeTime, old_close_time) != 0))) {
+ tsw_change_flag = 1;
+
+ cfg_set("openTime", openTime);
+ cfg_set("closeTime", closeTime);
+ snprintf(tsw_wake_time_hour, 3, "%s", openTime);
+ snprintf(tsw_wake_time_min, 3, "%s", openTime + 3);
+ snprintf(tsw_sleep_time_hour, 3, "%s", closeTime);
+ snprintf(tsw_sleep_time_min, 3, "%s", closeTime + 3);
+ slog(MISC_PRINT, SLOG_DEBUG,"tsw_wake_time_hour:%s,tsw_wake_time_min:%s\n", tsw_wake_time_hour, tsw_wake_time_min);
+ slog(MISC_PRINT, SLOG_DEBUG,"tsw_sleep_time_hour:%s,tsw_sleep_time_min:%s\n", tsw_sleep_time_hour, tsw_sleep_time_min);
+ cfg_set("tsw_wake_time_hour", tsw_wake_time_hour);
+
+ cfg_set("tsw_wake_time_min", tsw_wake_time_min);
+ cfg_set("tsw_sleep_time_hour", tsw_sleep_time_hour);
+
+ cfg_set("tsw_sleep_time_min", tsw_sleep_time_min);
+
+ slog(MISC_PRINT, SLOG_NORMAL,"send msg to wlan-server : MSG_CMD_WIFI_TSW_SET\n ");
+ //zte_send_message(MODULE_ID_WIFI,MSG_CMD_WIFI_TSW_SET,0,NULL);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_WIFI, MSG_CMD_WIFI_TSW_SET, 0, NULL, 0);
+ }
+
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+static void zte_get_cur_user_mac(struct list_head *Dhcp_info_list)
+{
+ struct in_addr addr;
+ char ipaddress[16] = {0};
+ char client_mac_addr[18] = {0};
+ char old_client_mac_addr[18] = {0};
+ DHCPOFFERADDR_LIST_t * p_dhcp_info = NULL;
+
+ cfg_get_item("client_mac_address", old_client_mac_addr, sizeof(old_client_mac_addr));
+ cfg_get_item(NV_USER_IP_ADDR, ipaddress, sizeof(ipaddress));
+ list_for_each_entry(p_dhcp_info, Dhcp_info_list, list) {
+ addr.s_addr = p_dhcp_info->dhcp_info.ip;
+ if ((strcmp(ipaddress, "") != 0) && (strcmp(inet_ntoa(addr), "")) && (!strcmp(ipaddress, inet_ntoa(addr)))) {
+ snprintf(client_mac_addr, 18, "%02X:%02X:%02X:%02X:%02X:%02X", p_dhcp_info->dhcp_info.mac[0], p_dhcp_info->dhcp_info.mac[1], p_dhcp_info->dhcp_info.mac[2], p_dhcp_info->dhcp_info.mac[3], p_dhcp_info->dhcp_info.mac[4], p_dhcp_info->dhcp_info.mac[5]);
+ if (strcmp(client_mac_addr, old_client_mac_addr)) {
+ cfg_set("client_mac_address", client_mac_addr);
+ break;
+ }
+ }
+ }
+}
+
+static DHCPOFFERADDR_LIST_t *find_match_sta(struct list_head *dhcp_info_list, RT_802_11_MAC_ENTRY * pEntry)
+{
+ DHCPOFFERADDR_LIST_t * p_dhcp_info = NULL;
+
+ list_for_each_entry(p_dhcp_info, dhcp_info_list, list) {
+ // printf("[%s] p_dhcp_info:%d\n", __FUNCTION__, p_dhcp_info);
+
+
+ if ((p_dhcp_info->dhcp_info.mac[0] == pEntry->Addr[0]) && (p_dhcp_info->dhcp_info.mac[1] == pEntry->Addr[1]) &&
+ (p_dhcp_info->dhcp_info.mac[2] == pEntry->Addr[2]) && (p_dhcp_info->dhcp_info.mac[3] == pEntry->Addr[3]) &&
+ (p_dhcp_info->dhcp_info.mac[4] == pEntry->Addr[4]) && (p_dhcp_info->dhcp_info.mac[5] == pEntry->Addr[5])) {
+
+ return p_dhcp_info;
+
+ }
+ }
+
+
+ return NULL;
+
+}
+
+//»ñÈ¡wifi lan¿ÚÐÅÏ¢: wifi·Ö¿ªÔÒò£¬ÁÚ¾ÓÁбíºÍlease¶¼ÎÞ·¨Çø·ÖËÊÇwifi£¬Ö»ÓÐwifiоƬ֪µÀ
+void zte_wlan_get_station_list(webs_t wp)
+{
+ int i = 0;
+ int result = 0;
+
+ BOOL first = TRUE;
+ BOOL match = FALSE;
+
+ struct in_addr ipAddr = {0};
+ RT_802_11_MAC_TABLE staList = {0};
+ DHCPOFFERADDR_LIST_t * p_dhcp_info = NULL;
+
+ struct list_head dhcp_info_list;
+ INIT_LIST_HEAD(&dhcp_info_list);
+
+ zte_get_wifi_sta_list(&staList);
+ if (staList.Num > MAX_NUMBER_OF_MAC) {//kw 2,3
+ slog(MISC_PRINT, SLOG_ERR, "sta_count err, Num=%d\n", staList.Num);
+ return;
+ }
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s]staList.Num:%d\n", __FUNCTION__, staList.Num);
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s]sta_list->ConnectedTime:%d\n", __FUNCTION__, staList.Entry[0].ConnectedTime);
+ if (0 == staList.Num) {
+ cfg_set("client_mac_address", ""); //added by dujiajiao 2016-2-24
+ }
+
+ result = zte_get_mac_list_from_lease(&dhcp_info_list);
+
+ web_feedback_header(wp);
+ (void)websWrite(wp, T("{\"%s\":["), CMD_WIFI_STATION_LIST);
+
+ /*
+ if(-1 == result || -2 == result || -3 == result)
+ {
+ (void)websWrite(wp, T("]}"));
+ safe_free(dhcp_info_list);
+ return;
+ }
+ */
+
+ if (0 == result) {
+ zte_get_cur_user_mac(&dhcp_info_list);//added by dujiajiao 2016-2-24
+ }
+
+
+ for (i = 0; i < staList.Num; i++) {
+
+ if (first == FALSE) {
+ (void)websWrite(wp, T(","));
+ } else {
+ first = FALSE;
+ }
+
+ if (staList.Entry[i].ConnectedTime) {
+ (void)websWrite(wp, T("{\"%s\":%ld,"), WIFI_STATION_CONNECTTIME, staList.Entry[i].ConnectedTime);
+ } else {
+ (void)websWrite(wp, T("{\"%s\":\"--\","), WIFI_STATION_CONNECTTIME);
+ }
+
+ /*do not use macro, the SSID_index = 0 in broadcom*/
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s]SSID_index:%d\n", __FUNCTION__, staList.Entry[i].SSID_index);
+
+ if (staList.Entry[i].SSID_index) {
+ (void)websWrite(wp, T("\"%s\":\"%d\","), WIFI_SSID_INDEX, staList.Entry[i].SSID_index);
+ }
+
+ (void)websWrite(wp, T("\"%s\":\"wifi\","), WIFI_STATION_DEVTYPE);
+
+
+ (void)websWrite(wp, T("\"%s\":\"%02X:%02X:%02X:%02X:%02X:%02X\","), WIFI_STATION_MAC, \
+ staList.Entry[i].Addr[0], staList.Entry[i].Addr[1], staList.Entry[i].Addr[2], staList.Entry[i].Addr[3], staList.Entry[i].Addr[4], staList.Entry[i].Addr[5]);
+
+ if ((p_dhcp_info = find_match_sta(&dhcp_info_list, &staList.Entry[i])) != NULL) {
+
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s] dhcp_info.mac= %02X %02X %02X %02X %02X %02X \n", __FUNCTION__, \
+ p_dhcp_info->dhcp_info.mac[0], p_dhcp_info->dhcp_info.mac[1], p_dhcp_info->dhcp_info.mac[2], \
+ p_dhcp_info->dhcp_info.mac[3], p_dhcp_info->dhcp_info.mac[4], p_dhcp_info->dhcp_info.mac[5]);
+
+ if (p_dhcp_info->dhcp_info.ip != NULL) {
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s]dhcp_info_ip:%d\n", __FUNCTION__, p_dhcp_info->dhcp_info.ip);
+
+ }
+
+ ipAddr.s_addr = p_dhcp_info->dhcp_info.ip;
+
+ if (strlen(p_dhcp_info->dhcp_info.host_name) > 0) { //kw 3 ??
+ (void)websWrite(wp, T("\"%s\":\"%s\","), WIFI_STATION_HOSTNAME, p_dhcp_info->dhcp_info.host_name);
+ } else {
+ (void)websWrite(wp, T("\"%s\":\"--\","), WIFI_STATION_HOSTNAME);
+ }
+
+ if (inet_ntoa(ipAddr)) {
+ (void)websWrite(wp, T("\"%s\":\"%s\","), WIFI_STATION_IPADDR, inet_ntoa(ipAddr));
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s]dhcp_info_ip-inet_ntoa:%s\n", __FUNCTION__, inet_ntoa(ipAddr));
+ } else {
+ (void)websWrite(wp, T("\"%s\":\"--\","), WIFI_STATION_IPADDR);
+ }
+
+ if (zte_is_static_dhcp_ip(inet_ntoa(ipAddr))) {
+ //(void)websWrite(wp,T("\"%s\":-1,"),WIFI_STATION_VALIDTIME);
+ (void)websWrite(wp, T("\"%s\":\"STATIC\"}"), WIFI_STATION_IPTYPE);
+ } else {
+ //(void)websWrite(wp,T("\"%s\":%ld,"),WIFI_STATION_VALIDTIME, dhcpInfo.expires);
+ (void)websWrite(wp, T("\"%s\":\"DHCP\"}"), WIFI_STATION_IPTYPE);
+ }
+ match = FALSE;
+ } else {
+//1. dchp not give an IP
+//2. customer set a static ip
+ slog(MISC_PRINT, SLOG_DEBUG,"[%s:%s]do not match ++++++++ \n", __FILE__, __FUNCTION__);
+
+ (void)websWrite(wp, T("\"%s\":\"--\","), WIFI_STATION_HOSTNAME);
+ (void)websWrite(wp, T("\"%s\":\"--\","), WIFI_STATION_IPADDR);
+ (void)websWrite(wp, T("\"%s\":\"--\"}"), WIFI_STATION_IPTYPE);
+ }
+
+ }
+
+ (void)websWrite(wp, T("]}"));
+
+ free_dhcp_list(&dhcp_info_list);
+}
+
+
+static unsigned int wps_pin_checksum(unsigned long pin)
+{
+ unsigned long int accum = 0;
+ while (pin) {
+ accum += 3 * (pin % 10);
+ pin /= 10;
+ accum += pin % 10;
+ pin /= 10;
+ }
+
+ return (10 - accum % 10) % 10;
+}
+
+int os_get_time(struct os_time *t)
+{
+ int res = 0;
+ struct timeval tv;
+ res = gettimeofday(&tv, NULL);
+ t->sec = tv.tv_sec;
+ t->usec = tv.tv_usec;
+ return res;
+}
+static int get_random(unsigned char* buf, size_t len)
+{
+ FILE* f;
+ size_t rc;
+
+ f = fopen("/dev/urandom", "rb");
+ if (f == NULL) {
+ slog(MISC_PRINT, SLOG_ERR,"Could not open /dev/urandom.\n");
+ return -1;
+ }
+
+ rc = fread(buf, 1, len, f);
+ //kw 3
+ fclose(f);
+
+ //printf("rc is %d, buf is %s\n", rc, buf);
+ return rc != len ? -1 : 0;
+}
+
+int random_get_bytes(void* buf, size_t len)
+{
+ int ret;
+ unsigned char* bytes = buf;
+
+ ret = get_random(buf, len);
+ return ret;
+}
+
+static int wps_generate_pin(void)
+{
+ unsigned int val = 0;
+
+ /*Generate seven random digits for the PIN*/
+ if (random_get_bytes((unsigned char *) &val, sizeof(val)) < 0) {
+ struct os_time now;
+ os_get_time(&now);
+ val = random() ^ now.sec ^ now.usec;
+ } else {//klocwork
+ if (val > 0xFFFFFFF0) {
+ struct os_time now;
+ os_get_time(&now);
+ val = random() ^ now.sec ^ now.usec;
+ }
+ }
+ val %= 10000000;
+ //printf("val is %ld\n", val);
+ /*Append checksum digit*/
+ return val * 10 + wps_pin_checksum(val);
+}
+
+void zte_wlan_get_wps_pin(webs_t wp)
+{
+ unsigned long pincode = 0;
+ char pin[9] = {0};
+
+ pincode = wps_generate_pin();
+ snprintf(pin,sizeof(pin), "%08d", pincode);
+
+ (void)zte_web_write(NV_WIFI_WPS_AP_PIN, pin);
+ web_feedback_header(wp);
+ zte_rest_cmd_write_head(wp);
+ zte_rest_cmd_write(wp, NV_WIFI_WPS_AP_PIN, pin, 0);
+ zte_rest_cmd_write_foot(wp);
+}
+
+void zte_wlan_get_wps_defpin(webs_t wp)
+{
+ //unsigned long defpincode = 0;
+ char pin[9] = {0};
+ (void)zte_web_read(NV_WIFI_WPS_DEF_PIN, pin);
+
+ web_feedback_header(wp);
+ zte_rest_cmd_write_head(wp);
+ zte_rest_cmd_write(wp, NV_WIFI_WPS_DEF_PIN, pin, 0);
+ zte_rest_cmd_write_foot(wp);
+}
+
+
diff --git a/lynq/R305/ap/app/goahead/interface5.0/zte_web_interface.h b/lynq/R305/ap/app/goahead/interface5.0/zte_web_interface.h
new file mode 100755
index 0000000..08f86fe
--- /dev/null
+++ b/lynq/R305/ap/app/goahead/interface5.0/zte_web_interface.h
@@ -0,0 +1,1119 @@
+/**
+ * @file zte_web_interface.h
+ * @brief Public APIs of Sanechips
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Hong Wu <wu.hong@sanechips.com.cn>
+ * @defgroup si_ap_app_webserver_id si_ap_app_webserver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+
+#ifndef ZTE_WEB_INTERFACE_H
+#define ZTE_WEB_INTERFACE_H
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+#include <time.h>
+#include "../server/webs.h"
+#include "message.h"
+//#include "errorcode.h"
+#include "cfg_nv_def.h"
+#include "cfg_api.h"
+#include "zte_web_mgmt.h"
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include "softap_api.h"
+#include "netotherapi.h"
+#include "net/zte_web_net_lan.h"
+#include "net/zte_web_net_wan.h"
+#include "net/zte_web_net_other.h"
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+#define cprintf(fmt, args...) do { \
+ FILE *fp = fopen("/dev/console", "w"); \
+ if (fp) { \
+ fprintf(fp, fmt, ## args); \
+ fclose(fp); \
+ } \
+} while (0)
+
+#define WEBLOG cprintf
+#define IFSTREQUAL(str1, str2) (strcmp((str1), (str2))?0:1)
+#define STR_EQUAL(a,b) ( strcmp((char*)a, (char*)b)==0 )
+#ifndef uint8
+#define uint8 unsigned char
+#endif
+
+#define ID "id"
+#define NAME "name"
+#define SITE "site"
+#define SUCCESS "success"
+#define FAILURE "failure"
+#define EXIST "exist"
+#define NOEXIST "noexist"
+#define PROCESSING "processing"
+#define MSG_INVALID_WEB_PARAM "MSG_INVALID_WEB_PARAM"
+#define ZTE_MC_OK_S (0)
+
+#define CFG_BUF_LENGTH 512
+#define CONFIG_DEFAULT_LENGTH 64
+
+#define DIAGLOG_DATA_PATH "/etc_ro/web/diaglog"
+
+/*** define about NV ***/
+#define NV_ITEM_VALUE_DEFAULT_STRING_LEN 128
+#define NV_ITEM_VALUE_BOOLEAN_LEN 1
+#define NV_ITEM_VALUE_YES_NO_LEN 5
+#define NV_ITEM_VALUE_IP_LEN 20
+#define NV_ITEM_MODE_STRING_LEN 25
+#define NV_ITEM_ADMIN_STRING_LEN 25
+#define NV_ITEM_VALUE_APN_STRING_LEN 400
+#define NV_ITEM_VALUE_NW_LIST_STRING_LEN 700
+#define NV_ITEM_STRING_LEN_5 5
+#define NV_ITEM_STRING_LEN_10 10
+#define NV_ITEM_STRING_LEN_20 20
+#define NV_ITEM_STRING_LEN_50 50
+#define NV_ITEM_STRING_LEN_64 64
+#define NV_ITEM_STRING_LEN_150 150
+#define NV_ITEM_STRING_LEN_200 200
+#define NV_FW_RULE_MAX_LEN_V6 400
+#define NV_ITEM_VALUE_STRING_LEN 50
+#define NVIO_MAX_LEN 1500
+#define NVIO_TMP_LEN 512
+#define NVIO_DEFAULT_LEN 50
+#define NV_ITEM_VALUE_STRING_LEN 50
+#define NV_ITEM_VALUE_MAX_LEN 1024
+#define zte_web_write(xx_item, xx_value) zte_nvconfig_write(xx_item, xx_value,(int)strlen(xx_value))
+#define zte_web_read(xx_item, xx_value) zte_nvconfig_read(xx_item, xx_value,sizeof(xx_value)) //modified,-1 deleted
+
+/*webuiÕʺÅ*/
+#define LOGIN_SUCCESS "0"
+#define LOGIN_FAIL "1"
+#define LOGIN_DUPLICATE_USER "2"
+#define LOGIN_BAD_PASSWORD "3"
+#define LOGIN_ALREADY_LOGGED "4"
+#define LOGIN_USER_NAME_NOT_EXSIT "5"
+#define LOGIN_TIMEOUT 600 //timeout after webui login
+#define LOGIN_PSW_MIN_LEN 1
+#define LOGIN_PSW_MAX_LEN 32
+#define LOGIN_FAIL_LOCK_TIME 300//the lock time after login failed
+#define LOGIN_FAIL_TIMES "5"
+#define LOGIN_RECORD_TIME 32
+
+#define COOKIE_SESSION_SIZE 32
+#define COOKIE_TOKEN_TIMEOUT 30
+
+#define NV_LANGUAGE "Language"
+#define NV_LOGINFO "loginfo"
+#define NV_USER_IP_ADDR "user_ip_addr"
+#define NV_LOGIN_LOCK_TIME "login_lock_time"
+#define NV_LAST_LOGIN_TIME "last_login_time"
+#define NV_USER_LOGIN_TIMEMARK "user_login_timemark"
+#define NV_COOKIE_ID "cookie_id"
+#define NV_WEB_TOKEN "web_token"
+
+/* ¿ìËÙÉèÖà */
+#define MAX_QUICK_SET_NUM 10
+
+/*Á÷Á¿Í³¼Æ*/
+#define ZTE_WEB_DATA_STATISTICS_CLEAR_ALL "ALL"
+#define ZTE_WEB_DATA_STATISTICS_CLEAR_TOTAL "TOTAL"
+#define ZTE_WEB_DATA_STATISTICS_CLEAR_CURRENT "CURRENT"
+
+
+
+//wan module
+#define ZTE_DAILNUM_LEN 8
+#define ZTE_ADDR_LEN 16
+#define ZTE_SEL_TYPE 8
+#define ZTE_PDP_TYPE_LEN 12
+#define ZTE_AUTH_TYPE_LEN 8
+#define ZTE_WAN_UMTS_MAX_PROFILE_NAME_LEN 32
+#define ZTE_WAN_UMTS_MAX_APN_STRING_LEN 104
+#define ZTE_WAN_UMTS_MAX_USERNAME_STRING_LEN 65
+#define ZTE_WAN_UMTS_MAX_PASSWD_STRING_LEN 65
+#define ZTE_USSD_DATA_TO_WEB_LEN 900
+#define CMD_CONNECTION_MODE "ConnectionMode"
+
+//pbm module
+#define CMD_PBM_DATA_INFO "pbm_data_info"
+#define CMD_PBM_DATA_TOTAL "pbm_data_total"
+#define CMD_PBM_CAPACITY_INFO "pbm_capacity_info"
+
+//sms module
+#define CMD_SMS_PAGE_DATA "sms_page_data"
+#define CMD_SMS_PARAMETER_INFO "sms_parameter_info"
+#define CMD_SMS_STATUS_INFO "sms_cmd_status_info"
+#define CMD_SMS_CAPACITY_INFO "sms_capacity_info"
+#define CMD_SMS_STATUS_RPT_DATA "sms_status_rpt_data"
+#define CMD_SMS_DATA_TOTAL "sms_data_total"
+#define CMD_SMS_UNREAD_COUNT "sms_unread_count"
+#define CMD_BROADCAST_DATA "broadcast_data"
+#define NV_SMS_UNREAD_NUM "sms_unread_num"
+
+//APN
+#define APN_SAVE_AND_SET_DEFAULT "0"
+#define APN_ONLY_SET_DEFAULT "1"
+#define ZTE_WEB_ACT_AUTO "auto"
+#define ZTE_WEB_ACT_MANUAL "manual"
+#define ZTE_WEB_ACT_SAVE "save"
+#define ZTE_WEB_ACT_SETDEFAULT "set_default"
+#define ZTE_WEB_ACT_SAVE_AND_SETDEFAULT "set_save_and_default"
+#define ZTE_WEB_ACT_DELETE "delete"
+#define ZTE_WEB_DIAL_MODE_AUTO "auto_dial"
+#define ZTE_WEB_DIAL_MODE_MANUAL "manual_dial"
+#define ZTE_WEB_DIAL_MODE_DEMAND "demand_dial"
+#define ZTE_WEB_MANUAL_DIAL_ACTION_CONN "connect"
+#define ZTE_WEB_MANUAL_DIAL_ACTION_DISCONN "disconnect"
+
+//nv for data limit settings
+#define NV_DATA_VOLUME_LIMIT_SWITCH "data_volume_limit_switch" /*0:disable;1:enable*/
+#define NV_DATA_VOLUME_LIMIT_UNIT "data_volume_limit_unit" /*time/data*/
+#define NV_DATA_VOLUME_LIMIT_SIZE "data_volume_limit_size"
+#define NV_DATA_VOLUME_ALERT_PERCENT "data_volume_alert_percent"
+#define DATA_VOLUME_LIMIT_UNIT_TIME "time"
+#define DATA_VOLUME_LIMIT_UNIT_DATA "data"
+#define NV_HTTPSHARE_STATUS "HTTP_SHARE_STATUS"
+#define NV_HTTPSHARE_WR_AUTH "HTTP_SHARE_WR_AUTH"
+#define NV_HTTPSHARE_FILE "HTTP_SHARE_FILE"
+
+//other fluxstat
+#define NV_DATA_TRAFFIC_SIM_PROVINCE "sim_home_location"
+#define NV_DATA_TRAFFIC_SWITCH "is_traffic_aline_on"
+#define NV_DATA_TRAFFIC_MONTH_TOTAL "traffic_month_total"
+#define NV_DATA_TRAFFIC_MONTH_USED "traffic_month_used"
+
+//fota module
+#define FOTA_ACTION_CANCEL_DOWNLOAD "0"
+#define FOTA_ACTION_CONFIRM_DOWNLOAD "1"
+#define FOTA_ACTION_DOWNLOADING_USER_CLICK_CANCEL "2"
+//#define FOTA_UPDATE_VERSION "version"
+#define FOTA_UPGRADE_RESULT "upgrade_result"
+//#define FOTA_PACK_SIZE_INFO "pack_size_info"
+//#define FOTA_UPDATE_INFO "update_info"
+//#define FOTA_SETTINGS_INFO "GetUpgAutoSetting"
+//#define FOTA_NEW_VERSION_STATE "new_version_state"
+
+//NET
+#define HOSTANME "hostname"
+#define MAC "mac"
+#define ADDR "ip"
+#define DOMAIN "domain"
+#define MAC_ADDR "mac_addr"
+#define DEVICES "devices"
+#define SITELIST "siteList"
+#define CMD_LAN_STATION_LIST "lan_station_list"
+#define CMD_CHILDREN_DEVICE_LIST "childGroupList"
+#define CMD_WHITE_SITE_LIST "site_white_list"
+#define CMD_GET_USER_MAC_ADDR "get_user_mac_addr"
+#define CMD_CURRENT_STATICADDR_LIST "current_static_addr_list"
+#define CMD_GET_POWERON_TIME "get_poweron_time"
+#define CMD_GET_LAN_DEV_INFO "get_lan_dev_info" //you wen ti
+#define CMD_GETDDNS_STATUS "getddns_status"
+#define CMD_USSD_DATA_INFO "ussd_data_info"
+#define CMD_GET_DEVICE_MODE "get_device_mode"
+
+//SD
+#define STR_SDCARD_MODE_OPT "sdcard_mode_option"
+
+
+/*useradded module start*/
+#define CMD_GET_SAMPLE "station_list"
+/*useradded module end*/
+
+/****************************All the Goform ID************************************/
+
+//#define GOFORM_MGMT_SET_WEB_DATA "SET_WEB_DATA"
+//#define GOFORM_MGMT_GUEST_USER_CONTROL "GUEST_USER_CONTROL"
+#define GOFORM_MGMT_SET_EXTERNAL_NV "SET_EXTERNAL_NV"
+/*management start*/
+#define GOFORM_MGMT_SET_WEB_LANGUAGE "SET_WEB_LANGUAGE"
+#define GOFORM_MGMT_SET_DEVICEMODE "SET_DEVICE_MODE"
+#define GOFORM_MGMT_LOGIN_IP "LOGIN"
+#define GOFORM_MGMT_LOGOUT_IP "LOGOUT"
+#define GOFORM_MGMT_CHANGE_PASSWORD "CHANGE_PASSWORD"
+#define GOFORM_MGMT_CHANGE_ACCOUNT "CHANGE_ACCOUNT"
+#define GOFORM_MGMT_RESTORE_FACTORY_SETTINGS "RESTORE_FACTORY_SETTINGS"
+#define GOFORM_MGMT_REBOOT "REBOOT_DEVICE"
+#define GOFORM_MGMT_POWEROFF "TURN_OFF_DEVICE"
+#define GOFORM_MGMT_POWER_ON_SPEED "MGMT_CONTROL_POWER_ON_SPEED"
+#define GOFORM_MGMT_QUICK_SETUP "QUICK_SETUP_EX"
+//#define GOFORM_SET_WORK_TYPE "SET_WORK_TYPE"
+#define GOFORM_MGMT_SNTP "SNTP"
+#define GOFORM_MGMT_SYSLOG "SYSLOG"
+#define GOFORM_MGMT_SCHEDULE_SETTING "SCHEDULE_SETTING"
+//#define GOFORM_HTTP_REDIRECT "HTTP_REDIRECT"
+/*management end*/
+
+/*wan module start*/
+#define GOFORM_WAN_LOCK_FREQUENCY "LOCK_FREQUENCY"
+#define GOFORM_WAN_SET_NETWORK "SET_NETWORK"
+#define GOFORM_WAN_SET_CONNECTION_MODE "SET_CONNECTION_MODE"
+#define GOFORM_WAN_CONNECT_NETWORK "CONNECT_NETWORK"
+#define GOFORM_WAN_DISCONNECT_NETWORK "DISCONNECT_NETWORK"
+#define GOFORM_WAN_SCAN_NETWORK "SCAN_NETWORK"
+#define GOFORM_WAN_SET_BEARER_PREFERENCE "SET_BEARER_PREFERENCE"
+//#define GOFORM_WAN_SET_CONN_SETTING "SET_CONN_SETTING"
+//#define GOFORM_WAN_CANCEL_AUTO_RECONNECT "CANCEL_AUTO_RECONNECT"
+#define GOFORM_WAN_UNLOCK_NETWORK "UNLOCK_NETWORK"
+//statistics module
+#define GOFORM_WAN_RESET_DATA_COUNTER "RESET_DATA_COUNTER"
+#define GOFORM_WAN_DATA_LIMIT_SETTING "DATA_LIMIT_SETTING"
+#define GOFORM_WAN_DATA_FLOW_CALIBRATION_MANUAL "FLOW_CALIBRATION_MANUAL"
+#define GOFORM_SNTP_GETDATASTATIC "SNTP_Getdatastatic"
+//pin,puk module
+#define GOFORM_MGMT_ENTER_PIN "ENTER_PIN"
+#define GOFORM_MGMT_DISABLE_PIN "DISABLE_PIN"
+#define GOFORM_MGMT_ENABLE_PIN "ENABLE_PIN"
+//#define GOFORM_MGMT_MODIFY_PIN "MODIFY_PIN"
+#define GOFORM_MGMT_ENTER_PUK "ENTER_PUK"
+#define GOFORM_MGMT_AUTO_PIN "AUTO_PIN"
+//pbm
+#define GOFORM_PBM_CONTACT_ADD "PBM_CONTACT_ADD"
+#define GOFORM_PBM_CONTACT_DEL "PBM_CONTACT_DEL"
+//sms module
+#define GOFORM_SMS_SET_MSG_CENTER "SET_MESSAGE_CENTER"
+#define GOFORM_SMS_DELETE_SMS "DELETE_SMS"
+#define GOFORM_SMS_DELETE_SMS_ALL "ALL_DELETE_SMS"
+#define GOFORM_SMS_MOVE_TO_SIM "MOVE_TO_SIM"
+#define GOFORM_SMS_SAVE_SMS "SAVE_SMS"
+#define GOFORM_SMS_SEND_SMS "SEND_SMS"
+#define GOFORM_SMS_SET_MSG_READ "SET_MSG_READ"
+//ussd module
+//#define GOFORM_USSD_SEND_CMD "SEND_USSD_CMD"
+#define GOFORM_USSD_PROCESS "USSD_PROCESS"
+//apn module
+#define GOFORM_WAN_APN_PROC_EX "APN_PROC_EX"
+/*wan module end*/
+
+/*wifi module start*/
+#define GOFORM_WLAN_SET "SET_WIFI_INFO"
+//#define GOFORM_WIFI_SET_FOR_SLEEP "SET_WIFI_INFO_FOR_SLEEP"
+//#define GOFORM_SET_SHOW_SSID_KEY_OLED "SET_SHOW_SSID_KEY_OLED"
+#define GOFORM_WLAN_MAC_FILTER "WIFI_MAC_FILTER"
+#define GOFORM_WLAN_WPS_SET "WIFI_WPS_SET"
+#define GOFORM_WLAN_SSID1_SET "SET_WIFI_SSID1_SETTINGS"
+#define GOFORM_WLAN_SSID2_SET "SET_WIFI_SSID2_SETTINGS"
+#define GOFORM_WLAN_WIFI_SLEEP_SET "SET_WIFI_SLEEP_INFO"
+#define GOFORM_WLAN_WIFI_COVERAGE_SET "SET_WIFI_COVERAGE"
+#define GOFORM_WLAN_SET_TSW "SAVE_TSW"
+#define GOFORM_PARENT_CONTROL_SET "SAVE_TIME_LIMITED"
+//wifi station start
+#define GOFORM_WLAN_WIFI_STA_CONTROL "WIFI_STA_CONTROL"
+#define GOFORM_WLAN_WIFI_SPOT_PROFILE_UPDATE "WIFI_SPOT_PROFILE_UPDATE"
+#define GOFORM_WLAN_SET_STA_CON "WLAN_SET_STA_CON"
+#define GOFORM_WLAN_SET_STA_DISCON "WLAN_SET_STA_DISCON"
+#define GOFORM_WLAN_SET_STA_REFRESH "WLAN_SET_STA_REFRESH"
+/*wifi module end*/
+
+/*router module start*/
+#define GOFORM_ROUTER_DEL_IP_PORT_FILETER "DEL_IP_PORT_FILETER"
+#define GOFORM_ROUTER_ADD_IP_PORT_FILETER_V4V6 "ADD_IP_PORT_FILETER_V4V6"//ÉèÖö˿ڹýÂËÐÅÏ¢
+#define GOFORM_ROUTER_DEL_IP_PORT_FILETER_V4V6 "DEL_IP_PORT_FILETER_V4V6"
+#define GOFORM_ROUTER_ADD_PORT_FORWARE "FW_FORWARD_ADD"
+#define GOFORM_ROUTER_DEL_PORT_FORWARE "FW_FORWARD_DEL"
+#define GOFORM_ROUTER_ADD_PORT_MAP "ADD_PORT_MAP"
+#define GOFORM_ROUTER_DEL_PORT_MAP "DEL_PORT_MAP"
+#define GOFORM_ROUTER_BASIC_SETTING "BASIC_SETTING"
+#define GOFORM_ROUTER_FORWARD_SETTING "VIRTUAL_SERVER"
+#define GOFORM_ROUTER_SYSTEM_SECURITY "FW_SYS"
+#define GOFORM_ROUTER_DHCP_SETTING "DHCP_SETTING"
+#define GOFORM_ROUTER_STATIC_DHCP_SETTING "STATIC_DHCP_SETTING"
+#define GOFORM_ROUTER_UPNP_SETTING "UPNP_SETTING"
+#define GOFORM_ROUTER_DMZ_SETTING "DMZ_SETTING"
+#define GOFORM_ROUTER_EDIT_HOSTNAME "EDIT_HOSTNAME"
+#define GOFORM_BIND_STATIC_ADDRESS_SET "SET_BIND_STATIC_ADDRESS"
+#define GOFORM_BIND_STATIC_ADDRESS_ADD "BIND_STATIC_ADDRESS_ADD"
+#define GOFORM_BIND_STATIC_ADDRESS_DEL "BIND_STATIC_ADDRESS_DEL"
+#define GOFORM_ADD_CHILDREN_DEVICE "ADD_DEVICE"
+#define GOFORM_DEL_CHILDREN_DEVICE "DEL_DEVICE"
+#define GOFORM_ADD_WHITE_SITE "ADD_WHITE_SITE"
+#define GOFORM_REMOVE_WHITE_SITE "REMOVE_WHITE_SITE"
+#define GOFORM_URL_FILTER_DELETE "URL_FILTER_DELETE"
+#define GOFORM_URL_FILTER_ADD "URL_FILTER_ADD"
+#define GOFORM_DDNS "DDNS"
+//#define GOFORM_DNS_MODE_SET "SET_DNS_MODE"
+//#define GOFORM_DNS_SERVER_SET "SET_DNS_SERVER"
+
+// wan pppoe *
+#define GOFORM_SET_OPERATION_MODE "OPERATION_MODE"
+//#define GOFORM_SET_WAN_GATEWAYMODE "WAN_GATEWAYMODE"
+#define GOFORM_SET_WAN_GATEWAYMODE_PPPOE "WAN_GATEWAYMODE_PPPOE"
+#define GOFORM_SET_WAN_GATEWAYMODE_DHCP "WAN_GATEWAYMODE_DHCP"
+#define GOFORM_SET_WAN_GATEWAYMODE_STATIC "WAN_GATEWAYMODE_STATIC"
+#define GOFORM_SET_WAN_GATEWAYMODE_AUTO "WAN_GATEWAYMODE_AUTO"
+/*router module end*/
+
+/*httpShare module start*/
+#define GOFORM_HTTPSHARE_GETCARD_VAULE "HTTPSHARE_GETCARD_VALUE"
+#define GOFORM_HTTPSHARE_ENTERFOLD "HTTPSHARE_ENTERFOLD"
+#define GOFORM_HTTPSHARE_NEW "HTTPSHARE_NEW"
+#define GOFORM_HTTPSHARE_DEL "HTTPSHARE_DEL"
+#define GOFORM_HTTPSHARE_FILE_RENAME "HTTPSHARE_FILE_RENAME"
+#define GOFORM_HTTPSHARE_AUTH_SET "HTTPSHARE_AUTH_SET"
+#define GOFORM_HTTPSHARE_MODE_SET "HTTPSHARE_MODE_SET"
+#define GOFORM_HTTPSHARE_CHECK_FILE "GOFORM_HTTPSHARE_CHECK_FILE"
+#define CMD_HTTPSHARE_GETCARD_VAULE "HTTPSHARE_GETCARD_VALUE"
+#define CMD_HTTPSHARE_GETCARD_NMEA "HTTPSHARE_GETCARD_NAME"
+#define CMD_HTTPSHARE_AUTH_GET "HTTPSHARE_AUTH_GET"
+/*httpShare module end*/
+
+/*FOTA module start*/
+#define GOFORM_SET_FOTAAUTOUPDATE "IF_UPGRADE"
+#define GOFORM_SET_FOTASETTINGS "SetUpgAutoSetting"
+/*FOTA module end*/
+
+/*ping test*/
+#define GOFORM_PING_DIAGNOSTICS_START "PINT_DIAGNOSTICS_START"
+#define GOFORM_PING_DIAGNOSTICS_STOP "PINT_DIAGNOSTICS_STOP"
+/*ping test*/
+
+/*useradded module start*/
+#define GOFORM_SET_SAMPLE "GOFORM_SET_SAMPLE"
+/*useradded module end*/
+
+
+/****************************All the web pages' URL************************************/
+#define ZTE_WEB_PAGE_LOGIN_NAME "index.html"
+#define ZTE_WEB_MOBILE_PAGE_LOGIN_NAME "mobile.html"
+
+#define ZTE_WEB_PAGE_MSG "/message.asp"
+#define ZTE_WEB_PAGE_NET_CONNECT "/air_network/net_connect.asp"
+#define ZTE_WEB_PAGE_PPP_CONNECTING "/air_network/pppconnect.asp"
+#define ZTE_WEB_PAGE_PPP_DISCONNECT "/air_network/pppdisconnect.asp"
+
+/*******************************************************************************
+ * Type definitions *
+ ******************************************************************************/
+/**
+ * @brief time
+ * @param sec second
+ * @param usec Microsecond
+ * @note
+ * @warning
+ */
+struct os_time {
+ long sec;
+ long usec;
+};
+
+
+/**
+ * @brief goform/cmd table's struct
+ * @param goform_id the message id extract from URL
+ * @param proc_func the handler of this goform_id
+ * @note
+ * @warning
+ */
+typedef struct web_goform_struct {
+ char goform_id[50];
+ void (*proc_func)(webs_t wp);
+} web_goform_type;
+
+/*******************************************************************************
+ * Global variable declarations *
+ ******************************************************************************/
+typedef enum _data_safe_result_type_t {
+ DATA_NO_SAFE = 0,
+ DATA_SAFE = 1
+} data_safe_result_type_t;
+
+typedef enum {
+ ZTE_NVIO_FAIL = 0,
+ ZTE_NVIO_DONE = 1,
+ ZTE_NVIO_BUSY = 2,
+ ZTE_NVIO_BADCMD = 3,
+ ZTE_NVIO_MAX
+} zte_topsw_state_e_type;
+
+
+
+/*******************************************************************************
+ * Global function declarations *
+ ******************************************************************************/
+/**
+* @brief Get current systime
+*
+* @param
+*
+* @return currentTime
+* @note
+* @warning
+*/
+int zte_web_getCurrentTime();
+
+/**
+* @brief the entry of zte code in goahead.
+*
+* @param
+*
+* @return currentTime
+* @note
+* @warning
+*/
+extern void zte_web_init();
+
+/**
+ * @brief Read the NV's value from the nv file.
+ *
+ * @param item Pointer to the NV's name.
+ * @param data Pointer to the NV's value.
+ * @param dataLen data's length.
+ *
+ * @return zte_topsw_state_e_type result number
+ * @note
+ * @warning
+ */
+zte_topsw_state_e_type zte_nvconfig_read(char *item, char *data, int dataLen);
+
+/**
+* @brief Write the NV's name and value into the nv file.
+*
+* @param item Pointer to the NV's name.
+* @param data Pointer to the NV's value.
+* @param dataLen data's length.
+*
+* @return zte_topsw_state_e_type result number
+* @note
+* @warning
+*/
+zte_topsw_state_e_type zte_nvconfig_write(char *item, char *data, int dataLen);
+
+/**
+* @brief goform entry from web pages to get fw para, call the related functions according to the cmd
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+void zte_goform_get_cmd_process(webs_t wp, char *path, char *query);
+
+/**
+* @brief goform entry from web pages to set fw para, call the related functions according to the goformId
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+void zte_goform_set_cmd_process(webs_t wp, char *path, char *query);
+
+/**
+* @brief Feed back web page at top location.
+*
+* @param i_wp HTTP Request Info.
+* @param i_pageName The page name.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_webs_feedback_top(webs_t i_wp, char *i_pageName);
+
+/**
+* @brief Check whether the login timeout.
+*
+* @param i_wp HTTP Request Info.
+* @param i_pageName The page name.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_mgmt_login_timeout_check();
+
+/**
+* @brief Send SMS.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_send_msg_process(webs_t wp);
+
+/**
+* @brief Save SMS.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_save_msg_process(webs_t wp);
+
+/**
+* @brief Delete message.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_delete_msg_process(webs_t wp);
+
+/**
+* @brief Move message to SIM.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_move_to_sim_msg_process(webs_t wp);
+
+/**
+* @brief Delete all messages.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_sms_alldel_msg_process(webs_t wp);
+
+/**
+* @brief Set SMS related parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_set_message_center(webs_t wp);
+
+/**
+* @brief To set the viewed message as read.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_sms_view_msg_process(webs_t wp);
+
+/**
+* @brief Add new contact.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_pbm_contact_add_process(webs_t wp);
+
+/**
+* @brief Delete contact.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_pbm_contact_del_process(webs_t wp);
+
+/**
+* @brief Set WiFi basic parameter.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_basic_set(webs_t wp);
+
+/**
+* @brief Set WiFi MAC filter parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_mac_filter_set(webs_t wp);
+
+/**
+* @brief Set WiFi WPS mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_wps_mode_set(webs_t wp);
+
+/**
+* @brief Set WiFi sleep and wake up at regular time.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_set_tsw(webs_t wp);
+
+/**
+* @brief Set WiFi SSID1 parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_web_ssid1_set(webs_t wp);
+
+/**
+* @brief Set WiFi SSID2 parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_ssid2_set(webs_t wp);
+
+/**
+* @brief To set the WiFi sleep mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_sleep_set(webs_t wp);
+
+/**
+* @brief Set WiFi coverage mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_coverage_set(webs_t wp);
+
+/**
+* @brief Set WiFi apstation parameters.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_set(webs_t wp);
+
+/**
+* @brief Update the wifi spot profile.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_spot_profile_update(webs_t wp);
+
+/**
+* @brief Connect to wifi spot.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_connect(webs_t wp);
+
+/**
+* @brief Disconnect wifi spot.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_disconnect(webs_t wp);
+
+/**
+* @brief Scan the wifi spot.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_station_refresh(webs_t wp);
+
+/**
+* @brief Get the wlan port's information.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wlan_get_station_list(webs_t wp);
+extern void zte_wlan_get_wps_pin(webs_t wp);
+extern void zte_wlan_get_wps_defpin(webs_t wp);
+
+
+
+/**
+* @brief Register network after manual search.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_set_network(webs_t wp);
+
+/**
+* @brief Set connect mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_set_connection_mode(webs_t wp);
+
+/**
+* @brief Connect to the network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_connect_network(webs_t wp);
+
+/**
+* @brief Disonnect the network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_disconnect_network(webs_t wp);
+
+/**
+* @brief Scan the network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_scan_network(webs_t wp);
+
+/**
+* @brief Set the mode of searching network.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_network_select(webs_t wp);
+
+/**
+* @brief Set the management of network flow.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_data_limit_setting(webs_t wp);
+
+/**
+* @brief Calibrate the network flow by manual.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_data_flow_calibration_manual(webs_t wp);
+
+
+/**
+* @brief Clear the network flow records.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_wan_data_statistics_clear_process(webs_t wp, char_t *path, char_t *query);//11
+
+/**
+* @brief Init the httpshare.
+*
+* @param
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpshare_init();
+
+/**
+* @brief Get file list from httpshare's database.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_enterFold(webs_t wp);
+
+/**
+* @brief Creat a new folder.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_new(webs_t wp);
+
+/**
+* @brief Delete file or folder from SD card.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_del(webs_t wp);
+
+/**
+* @brief Set the httpshare's configs.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_auth_set(webs_t wp);
+
+/**
+* @brief Set the SD card's mode:usb mode or httpshare mode.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_modeset(webs_t wp);
+
+/**
+* @brief Creat a new folder.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_rename(webs_t wp);
+
+/**
+* @brief Check file exists.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_check_file(webs_t wp);
+
+/**
+* @brief Get the httpshare's configs.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_auth_get(webs_t wp);
+
+/**
+* @brief Get the SD card's name:"MicroSD Card".
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_getcard_name(webs_t wp);
+
+/**
+* @brief Get the SD card's available capacity and total capacity.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_httpShare_getcard_value(webs_t wp);
+
+/**
+* @brief Ussd's operator process.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_goform_ussd_process(webs_t wp);
+
+/**
+* @brief Handle the auto or manual apn set for ipv4ipv6.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_form_multi_apn_proc_ex(webs_t wp);
+
+/**
+* @brief Set the user's selection:update or cancel.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_fota_update(webs_t wp);
+
+/**
+* @brief Set the fota's configs.
+*
+* @param wp HTTP Request Info.
+*
+* @return
+* @note
+* @warning
+*/
+extern void zte_fota_settings(webs_t wp);
+
+
+extern void zte_init_login_psw_time(void);
+extern int zte_apn_param_check(webs_t wp, char * type);
+extern void zte_get_login_lock_time(webs_t wp);
+extern void zte_get_login_status_value(webs_t wp, char *login_status);
+extern void zte_get_ddns_status(webs_t wp);
+extern void zte_dhcpv6_state_set(webs_t wp);
+extern void zte_mtu_set(webs_t wp);
+extern void zte_dns_mode_set(webs_t wp);
+//extern void zte_dns_server_set(webs_t wp);
+extern void zte_ping_diagnostics_start(webs_t wp);
+extern void zte_ping_diagnostics_stop(webs_t wp);
+extern void zte_get_poweron_time(webs_t wp);
+extern void zte_get_lan_dev_info(webs_t wp);
+extern void zte_goform_set_external_nv(webs_t wp);
+extern void zte_goform_set_work_type(webs_t wp);
+
+//other sntp + fluxstat + parent_control_set
+extern void zte_goform_sntp_getdatastatic_process(webs_t wp);
+extern void zte_parent_control_set(webs_t wp);//parent mode time control
+
+/*useradded module start*/
+extern void zte_goform_set_sample(webs_t wp);
+/*useradded module end*/
+
+
+/**
+* @brief Data to be decoded.
+*
+* @param src Data to be decoded.
+* @param len Length of the data to be decoded.
+* @param out_len Pointer to output length variable.
+*
+* @return Allocated buffer of out_len bytes of decoded data,or NULL on failure
+* @note Caller is responsible for freeing the returned buffer.
+* @warning
+*/
+extern unsigned char * zte_base64_decode(const unsigned char *src, size_t len, size_t *out_len);
+#ifdef WEBS_SECURITY
+extern char *zte_base64_encode(const char *data, int data_len);
+#endif
+
+extern int zte_Safe_valid_SpecialChar(char single_data);
+extern int zte_Safe_valid_SpecialChar_other(char single_data);
+extern int zte_valid_length_str(char *string_s, int min, int max);
+
+extern data_safe_result_type_t zte_Safe_isMacValid(char *str);
+extern data_safe_result_type_t zte_Safe_isIpValid(char *str);
+extern data_safe_result_type_t zte_Safe_isNumOnly(char *str);
+extern data_safe_result_type_t zte_Safe_noSpecialChar(char *str);
+extern data_safe_result_type_t zte_Safe_noSpecialChar_other(char *str);
+extern data_safe_result_type_t zte_Safe_isStringOnly(char *str);
+extern data_safe_result_type_t zte_Safe_isNumorStringOnly(char *str);
+
+extern int web_set_pwd(char *buf);
+extern void web_init_pwd(void);
+extern int web_check_pwd(char* buf);
+
+extern int web_aes_init(void);
+
+#endif
+
diff --git a/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
new file mode 100755
index 0000000..1b5372c
--- /dev/null
+++ b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.c
@@ -0,0 +1,3691 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_mgmt.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷ Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-06
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+
+
+* ECµ¥ºÅ:EC616000235556 ¿ª·¢¹ÊÕÏ
+* ¹ÊÕÏÖ÷Ìâ:¿ª»ú¸üÐÂʧ°ÜºóÁ¢¼´ÖØÆô£¬ÖØÆôºóÈÔÏÔʾ¸üÐÂʧ°ÜÎÊÌâ / Ôö¼Ówebui fota´¦Àílog
+* ÐÞ¸Äʱ¼ä:20140715
+************************************************************************/
+#include <sys/time.h>
+#include <sys/types.h>
+#include <string.h>
+#include <pthread.h>
+#include <dirent.h>
+#include <stdlib.h>
+
+#include <signal.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+#include <openssl/aes.h>
+
+#include "zte_web_interface.h"
+#include "zte_web_get_fw_para.h"
+#include "zte_web_mgmt_wifi.h"
+#include "fota_common.h"
+#include "nv_api.h"
+#include "libkey.h"
+
+/****************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+****************************************************************************/
+/* password check result*/
+typedef enum _psw_check_result_type_t {
+ PSW_EMPTY = 0,
+ PSW_OK = 1,
+ PSW_TOO_LONG = 2,
+ PSW_TIME_OUT = 3,
+ PSW_OTHER = 4
+} psw_check_result_type_t;
+
+typedef enum {
+ PIN_MANAGE_DISABLE = 0,
+ PIN_MANAGE_ENABLE,
+ PIN_MANAGE_MODIFY
+} emPIN_MANAGE_ACTION;
+
+typedef struct UNLOCK_PARA {
+ char unlock_code[20];
+} UNLOCK_PARA_ST;
+
+//quick setting
+typedef void (*funcWPType)(webs_t);
+
+pthread_mutex_t g_login_timemark_mutex = PTHREAD_MUTEX_INITIALIZER;
+#define TIME_SEM_KEY_1 0x0A2B
+#define TIME_SEM_KEY_2 0x3A4B
+
+//bsim
+typedef struct
+{
+ unsigned int pubKeyRsaE[32];
+ unsigned int pubKeyRsaN[32];
+ unsigned int secureFlag;
+ unsigned int pubKeyHash[4];
+ unsigned int secureDevId[3];
+}T_ZDrvEfuse_Secure;
+
+#define EFUSE_IOC_MAGIC 'E'
+#define EFUSE_GET_DATA _IOWR(EFUSE_IOC_MAGIC, 1, char *)
+#define PPPOE_CODE_LEN 32 //webui limit 30
+
+static unsigned char web_aes_key[16] = {0};
+
+#define APNCONFIG_NUM_MAX 10
+//bsim end
+
+/****************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+****************************************************************************/
+void deal_quick_setup_apn_ex(webs_t wp);
+void deal_quick_setup_wifi_basic(webs_t wp);
+void deal_quick_setup_wifi_security(webs_t wp);
+int zte_mgmt_handle_account(webs_t wp);
+void zte_setLastLoginTime();
+int zte_checkLoginTime();
+void zte_reduct_login_times();
+psw_check_result_type_t zte_password_check(webs_t wp, char* psw);
+static void wait_verify(char *wait_name, char *wait_value);
+static void zte_mgmt_enable_pin(webs_t wp, char_t *old_pin);
+static void zte_mgmt_modify_pin(webs_t wp, char_t *old_pin, char_t *new_pin);
+void deal_quick_setup_wifi_basic(webs_t wp);
+void deal_quick_setup_wifi_security(webs_t wp);
+static void deal_quick_setup_wps(webs_t wp);
+static char *split_str_by_sep(char *src, char *sep, char *dst, int len);
+static void set_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile);
+#ifdef WEBS_SECURITY
+static void js_aes_wifi_encode(void);
+#endif
+
+/* ¿ìËÙÉèÖà */
+const funcWPType G_ZQUICK_SET[MAX_QUICK_SET_NUM] = {
+ deal_quick_setup_apn_ex,
+ deal_quick_setup_wifi_basic,
+ deal_quick_setup_wifi_security,
+ zte_mgmt_handle_account,
+ quick_dhcp_set
+};
+
+/******************************************************
+* Function: void zte_mgmt_login(webs_t wp)
+* Description: deal with the login goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_mgmt_login(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User login!\n"));
+ char_t *psw = NULL;
+ char_t *user = NULL;
+ char_t *save_flag = NULL;
+ char_t *ip_address = NULL;
+
+ int user_name_len = 0;
+ char_t *pUser = NULL;
+ char user_name[CONFIG_DEFAULT_LENGTH] = {0};
+ int zte_password_len = 0;
+ char_t *zte_password = NULL;
+ char zte_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+ psw_check_result_type_t psw_cheak_result = PSW_EMPTY;
+ char buf[CONFIG_DEFAULT_LENGTH] = {0};
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[login] zte_mgmt_login enter====\n");
+ if (NULL == wp) {
+ slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: wp is null.");/*lint !e26*/
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+
+ psw = websGetVar(wp, T("password"), T(""));
+ user = websGetVar(wp, T("username"), NULL);
+
+ if ('\0' == (*psw)) {
+ slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: psw is empty.");/*lint !e26*/
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+
+ if (user != NULL) {
+ slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login user = %s\n", user);
+ pUser = (char *)zte_base64_decode((const unsigned char *)user, strlen(user), (unsigned int*)&user_name_len);
+ if (NULL == pUser) {
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+
+ //strncpy(user_name, pUser, user_name_len);
+ if(user_name_len < sizeof(user_name))
+ snprintf(user_name,user_name_len+1,"%s",pUser);
+ else
+ snprintf(user_name,sizeof(user_name),"%s",pUser);
+ free(pUser);
+
+ slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login user_name = %s\n", user_name);
+ cfg_get_item("admin_user", buf, sizeof(buf));
+ if (0 != strcmp(user_name, buf)) {
+ slog(MISC_PRINT, SLOG_ERR," zte_mgmt_login user_name fail \n");
+ zte_write_result_to_web(wp, LOGIN_USER_NAME_NOT_EXSIT);
+ return;
+ }
+ slog(MISC_PRINT, SLOG_DEBUG," zte_mgmt_login uername correct \n");
+ }
+ slog(MISC_PRINT, SLOG_DEBUG,"[login] login1 -> zte_password_encode:%s.\n", psw); /*lint !e26*/
+#ifdef WEBS_SECURITY
+ zte_password = js_aes_decode(psw, strlen(psw), (unsigned int*)&zte_password_len);
+#else
+ zte_password = (char *)zte_base64_decode((const unsigned char *)psw, strlen(psw), (unsigned int*)&zte_password_len);
+#endif
+ slog(MISC_PRINT, SLOG_DEBUG,"[login] login2 -> zte_password:%s.\n", zte_password); /*lint !e26*/
+
+ if (NULL == zte_password) {
+ slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: psw is empty.\n");/*lint !e26*/
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+ //zte_password will long than zte_password_len, then strncpy zte_password_len data to zte_psw_admin
+ if(zte_password_len < sizeof(zte_psw_admin))
+ snprintf(zte_psw_admin,zte_password_len+1,"%s",zte_password);
+ else
+ snprintf(zte_psw_admin,sizeof(zte_psw_admin),"%s",zte_password);
+ //strncpy(zte_psw_admin, zte_password, zte_password_len);
+ free(zte_password);
+ slog(MISC_PRINT, SLOG_DEBUG,"[login] login3 -> zte_psw_admin:%s.\n", zte_psw_admin); /*lint !e26*/
+ psw_cheak_result = zte_password_check(wp, zte_psw_admin);
+
+ if (psw_cheak_result != PSW_OK) {
+ slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login psw_cheak_result != PSW_OK\n");
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+
+ //get request ip addr
+ ip_address = websGetRequestIpaddr(wp);
+#if 0 // kw 3
+ if (NULL == ip_address) {
+ slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: ip_address is null.\n");/*lint !e26*/
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+#endif
+ //memset(&buf, 0, sizeof(buf));
+ //cfg_get_item("admin_Password", buf, sizeof(buf));
+ //if (0 == strcmp(zte_psw_admin, buf)) {
+ if (0 == web_check_pwd(zte_psw_admin)) {
+ save_flag = websGetVar(wp, T("save_login"), T(""));
+ if (('\0' != (*save_flag)) && (IFSTREQUAL("1", save_flag))) {
+ cfg_set("psw_save", zte_psw_admin);
+ }
+ } else {
+ zte_reduct_login_times();
+ slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login: error pass.");/*lint !e26*/
+ zte_write_result_to_web(wp, LOGIN_BAD_PASSWORD);
+ security_log(MODULE_ID_WEB_CGI,"web login err pwd ip=%s",ip_address);
+ return;
+ }
+
+ if (zte_mgmt_login_timemark_set()) {
+ char id[COOKIE_SESSION_SIZE+1] = {0};
+ int ret = web_make_salt_base64(id, sizeof(id));
+ if(ret == 0)
+ {
+ slog(MISC_PRINT, SLOG_ERR,"[login] web_get_cookie_id fail\n");
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+ (void)zte_web_write(NV_USER_IP_ADDR, ip_address);
+ (void)zte_web_write(NV_LOGINFO, "ok");
+ (void)zte_web_write("save_login", save_flag);
+ (void)zte_web_write("psw_fail_num_str", LOGIN_FAIL_TIMES);
+ (void)zte_web_write(NV_COOKIE_ID, id);
+#ifdef WEBS_SECURITY
+ js_aes_wifi_encode();
+#endif
+ //zte_write_result_to_web(wp, LOGIN_SUCCESS);
+ websWrite(wp, T("HTTP/1.1 200 OK\n"));
+ websWrite(wp, T("Server: %s\r\n"), WEBS_NAME);
+#ifdef WEBINSPECT_FIX
+ websWrite(wp, T("X-Frame-Options: SAMEORIGIN\n"));
+#endif
+ websWrite(wp, T("Pragma: no-cache\n"));
+ websWrite(wp, T("Cache-control: no-cache\n"));
+ websWrite(wp, T("Content-Type: text/html\n"));
+#ifdef WEBS_SECURITY
+ websWrite(wp, T("Expires: 0\n"));
+ if (websSSLIsOpen())
+ websWrite(wp, T("Set-Cookie: id=%s; secure; HttpOnly; SameSite=Lax;\n"),id);
+ else
+ websWrite(wp, T("Set-Cookie: id=%s; HttpOnly; SameSite=Lax;\n"),id);
+#endif
+ websWrite(wp, T("\n"));
+ if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
+ zte_rest_result_write(wp, LOGIN_SUCCESS);
+ } else {
+ websWrite(wp, T("{\"result\":\"%s\"}"), LOGIN_SUCCESS);
+ }
+ security_log(MODULE_ID_WEB_CGI,"web login suc ip=%s",ip_address);
+ return;
+ } else {
+ slog(MISC_PRINT, SLOG_ERR,"[login] zte_mgmt_login_timemark_set fail\n");
+ zte_write_result_to_web(wp, LOGIN_FAIL);
+ return;
+ }
+}
+/******************************************************
+* Function: int zte_mgmt_login_timemark_set()
+* Description: save the setting operate time
+* Input:
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+*******************************************************/
+int zte_mgmt_login_timemark_set()
+{
+ char_t login_timemark[NV_ITEM_STRING_LEN_64] = {0};
+ long timemark = 0;
+ int sem_id = -1;
+
+ int rc = TRUE;
+
+ sem_id = get_sem(TIME_SEM_KEY_2);
+ if (sem_id != -1) {
+ sem_p(sem_id);
+ }
+
+ timemark = time(0);
+ sprintf(login_timemark, "%ld", timemark);
+ if(ZTE_NVIO_DONE != zte_web_write(NV_USER_LOGIN_TIMEMARK, login_timemark))
+ {
+ rc = FALSE; // kw 3
+ }
+
+ if (sem_id != -1) {
+ sem_v(sem_id);
+ }
+
+ return rc;
+}
+void zte_mgmt_login_timeout_check()
+{
+ char_t user_login_timemark[NV_ITEM_STRING_LEN_64] = {0};
+ char_t login_info[NV_ITEM_STRING_LEN_20] = {0};
+
+ long time_now = 0;
+ int sem_id = -1;
+ long luser_login_timemark = 0;
+
+ zte_web_read(NV_LOGINFO, login_info);
+
+ if (0 == strcmp(login_info, "ok")) {
+ zte_web_read(NV_USER_LOGIN_TIMEMARK, user_login_timemark);
+ luser_login_timemark = atol(user_login_timemark);
+ if(luser_login_timemark < 0 || luser_login_timemark > LONG_MAX-1){
+ luser_login_timemark = LONG_MAX;
+ slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login_timemark_check: user_login_timemark is out of range [0, LONG_MAX).");
+ }
+
+ sem_id = get_sem(TIME_SEM_KEY_2);
+ if (sem_id != -1) {
+ sem_p(sem_id);
+ }
+ //timemark_check = time(0) - luser_login_timemark;
+ time_now = time(0);
+ if (sem_id != -1) {
+ sem_v(sem_id);
+ }
+
+ if ((time_now - luser_login_timemark) > LOGIN_TIMEOUT) {
+ slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login_timemark_check: the login is timeout .");
+ (void)zte_web_write(NV_USER_IP_ADDR, "");
+ (void)zte_web_write(NV_LOGINFO, "timeout");
+ (void)zte_web_write(NV_COOKIE_ID, "");
+ (void)zte_web_write(NV_WEB_TOKEN, "");
+ (void)zte_web_write(NV_USER_LOGIN_TIMEMARK, "0");
+ security_log(MODULE_ID_WEB_CGI,"web logout timeout");
+ return;
+ }
+#ifdef WEBS_SECURITY
+ static long time_update_token = 0;
+ if ((time_now - time_update_token) > COOKIE_TOKEN_TIMEOUT) {
+ time_update_token = time_now;
+ (void)zte_web_write(NV_WEB_TOKEN, "");
+ }
+#endif
+ }
+
+}
+/******************************************************
+* Function: void zte_mgmt_logout(webs_t wp)
+* Description: deal with the logout goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_mgmt_logout(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User logout!\n"));
+
+ if (NULL == wp) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ cfg_set(NV_USER_IP_ADDR, "");
+ cfg_set(NV_LOGINFO, "");
+ cfg_set(NV_COOKIE_ID, "");
+ cfg_set(NV_WEB_TOKEN, "");
+ zte_write_result_to_web(wp, SUCCESS);
+ security_log(MODULE_ID_WEB_CGI,"web logout");
+}
+
+/******************************************************
+* Function: void zte_mgmt_set_language(webs_t wp)
+* Description: deal with the set language goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*2012/09/14 liuyingnan modification
+*******************************************************/
+void zte_mgmt_set_language(webs_t wp)
+{
+ char_t* language = websGetVar(wp, T("Language"), T("en"));
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set language!\n"));
+
+ cfg_set(NV_LANGUAGE, language);
+
+ //cfg_save();
+ if ('\0' == (*language)) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_language: web para:[language] is empty string.\n"); /*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+
+ zte_write_result_to_web(wp, SUCCESS);
+ return;
+
+
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_set_devicemode(webs_t wp)
+* Description: user/develop mode switch
+* Input: HTTP page info(debug_enable = 1 develop mode)
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* Feb 27, 2014 V1.0 jhy create
+*******************************************************/
+void zte_mgmt_set_devicemode(webs_t wp)
+{
+ char_t* debug_enable = websGetVar(wp, T("debug_enable"), T(""));
+ char_t* auth = websGetVar(wp, T("auth"), T(""));
+
+ char strCfgGetItem[16] = {0};
+ nv_get_item(NV_RO, "usb_modetype", strCfgGetItem, sizeof(strCfgGetItem));
+
+ slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->%s current->%s\n", debug_enable, strCfgGetItem);
+ if((strcmp(strCfgGetItem,"user")== 0)&&(atoi(debug_enable) != 0))
+ {
+/* if(verify_device_key(auth,strlen(auth),SEED,strlen(SEED)) != 1)
+ {
+ slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_devicemode: auth %s fail.\n",auth);
+ zte_write_result_to_web(wp, "set_devicemode fail:auth fail!");
+ return;
+ }*/
+ }
+
+ if ('\0' == (*debug_enable)) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_devicemode: web para:[debug_enable] is empty string.\n");
+ zte_write_result_to_web(wp, "set_devicemode fail:parameter debug_enable is empty!");
+ return;
+ }
+
+ if (atoi(debug_enable) < 0 || atoi(debug_enable) > 3) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_set_devicemode: web para:[debug_enable] is illegal string.\n");
+ zte_write_result_to_web(wp, "set_devicemode fail:parameter debug_enable is illegal!");
+ return;
+ }
+ char ss[20] = {0};
+ unsigned char bootmode[] = {0x54,0x4D};
+ switch (atoi(debug_enable)) {
+ case 0:
+ slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->user\n");
+ nv_set_item(NV_RO, "usb_modetype", "user", 1);
+ bootmode[1] =0x00;
+ amt_set_bootmode(bootmode);
+ break;
+ case 1:
+ slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->debug\n");
+ nv_set_item(NV_RO, "usb_modetype", "debug", 1);
+ bootmode[1] =0x01;
+ amt_set_bootmode(bootmode);
+ break;
+ case 2:
+ slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->factory\n");
+ nv_set_item(NV_RO, "usb_modetype", "factory", 1);
+ bootmode[1] =0x02;
+ amt_set_bootmode(bootmode);
+ break;
+ case 3:
+ slog(MISC_PRINT, SLOG_NORMAL,"[goahead]debug_enable->amt\n");
+ //nv_set_item(NV_RO, "usb_modetype", "amt", 1);
+ amt_set_bootmode(bootmode);
+ break;
+ default:
+ slog(MISC_PRINT, SLOG_NORMAL,"[goahead]error!\n");
+ zte_write_result_to_web(wp, "set_devicemode fail:parameter debug_enable is illegal!");
+ return;;
+ }
+ nv_commit(NV_RO);////default_parameter_roÖеÄNV±£´æ±ØÐëÓÃnv_commit²»ÄÜÓÃcfg_save
+ zte_write_result_to_web(wp, "set_devicemode successfully!");
+
+}
+
+/******************************************************
+* Function: void zte_mgmt_restore(webs_t wp)
+* Description: deal with the restore goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_mgmt_restore(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_NORMAL,"webui reset send message to blc\n");
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_REQUEST, 0, NULL, 0);
+ system("sleep 2");//WH:delete?
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_poweroff(webs_t wp)
+* Description: deal with the poweroff goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2015/5/26 V1.0 lsl create
+*******************************************************/
+void zte_mgmt_poweroff(webs_t wp)
+{
+ zte_write_result_to_web(wp, SUCCESS);
+ slog(MISC_PRINT, SLOG_NORMAL,"webui poweroff send message to blc\n");
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_POWEROFF_REQUEST, 0, NULL, 0);
+}
+
+/******************************************************
+* Function: void zte_mgmt_control_power_on_speed(webs_t wp)
+* Description: deal with the power_on_speed goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2015/5/26 V1.0 lsl create
+*******************************************************/
+void zte_mgmt_control_power_on_speed(webs_t wp)
+{
+ char_t* mgmt_quicken_power_on = websGetVar(wp, T("mgmt_quicken_power_on"), T(""));
+
+ if ('\0' == (*mgmt_quicken_power_on)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ } else if (strcmp(mgmt_quicken_power_on, "0") != 0 && strcmp(mgmt_quicken_power_on, "1") != 0) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ cfg_set("mgmt_quicken_power_on", mgmt_quicken_power_on);
+
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+/******************************************************
+* Function: void zte_goform_mgmt_reboot_process(webs_t wp)
+* Description: deal with the restore goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_goform_mgmt_reboot_process(webs_t wp)
+{
+ MSG_BUF stMsg = {0};
+ SINT32 iMsgSize = sizeof(MSG_BUF) - sizeof(SINT32);
+ char buf[NV_ITEM_STRING_LEN_20] = {0};
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User reboot!\n"));
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL, 0);
+}
+
+
+void zte_goform_mgmt_syslog_process(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_DEBUG, "zte_goform_mgmt_syslog_process coming\n"); /*lint !e26*/
+ char_t *syslog_mode = NULL;
+ /* get value from web page */
+ syslog_mode = websGetVar(wp, T("syslog_mode"), T("all"));
+
+ char_t *syslog_flag = NULL;
+ /* get value from web page */
+ syslog_flag = websGetVar(wp, T("syslog_flag"), T("close"));
+
+ if (strcmp(syslog_flag, "close") == 0) {
+ cfg_set("debug_level", "0");
+ zte_write_result_to_web(wp, SUCCESS);
+ } else if (strcmp(syslog_flag, "delete") == 0) {
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User delete syslog!\n"));
+ slog(MISC_PRINT, SLOG_DEBUG, "delete syslog====\n"); /*lint !e26*/
+ //system("cat /dev/null > /var/log/webshow_messages");
+ system("cat /dev/null > /usr/netlog/misc.log");
+ system("cat /dev/null > /etc_ro/web/webshow_messages");
+
+ zte_write_result_to_web(wp, SUCCESS);
+ } else {
+ //cfg_set("debug_level","7");/*added by jhy */
+ if (0 == strcmp("ufi", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("mkdir -p /etc_ro/web");
+ system("log.sh UFI");
+ cfg_set("syslog_mode", "ufi");
+ }/*added by jhy */
+ else if (0 == strcmp("wan_connect", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh wan_connect info");
+ cfg_set("syslog_mode", "wan_connect");
+ } else if (0 == strcmp("voip", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh voip info");
+ cfg_set("syslog_mode", "voip");
+ } else if (0 == strcmp("sms", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh sms info");
+ cfg_set("syslog_mode", "sms");
+ } else if (0 == strcmp("tr069", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh tr069 info");
+ cfg_set("syslog_mode", "tr069");
+ } else if (0 == strcmp("dlna", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh dlna info");
+ cfg_set("syslog_mode", "dlna");
+ } else if (0 == strcmp("wlan", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh wlan info");
+ cfg_set("syslog_mode", "wlan");
+ } else if (0 == strcmp("router", syslog_mode)) {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh router info");
+ cfg_set("syslog_mode", "router");
+ } else {
+ slog(MISC_PRINT, SLOG_DEBUG, "syslog_mode=====%s\n", syslog_mode); /*lint !e26*/
+ system("log.sh all info");
+ cfg_set("syslog_mode", "all");
+ }
+
+ zte_write_result_to_web(wp, SUCCESS);
+ }
+
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_change_password(webs_t wp)
+* Description: deal with the user account modify goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_mgmt_change_password(webs_t wp)
+{
+ char_t *old_pass = NULL;
+ char_t *new_pass = NULL;
+ char_t *current_psw = NULL;
+ char_t *new_psw = NULL;
+ int current_psw_len = 0;
+ int new_psw_len = 0;
+ char new_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+ char old_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+ //char admin_psw_buf[CONFIG_DEFAULT_LENGTH] = {0};
+
+ old_pass = websGetVar(wp, T("oldPassword"), T(""));
+ new_pass = websGetVar(wp, T("newPassword"), T(""));
+
+ if (0 == strlen(old_pass) || 0 == strlen(new_pass)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw_encode:%s\n", new_pass); /*lint !e26*/
+#ifdef WEBS_SECURITY
+ current_psw = js_aes_decode(old_pass, strlen(old_pass), (unsigned int *)¤t_psw_len);
+ new_psw = js_aes_decode(new_pass, strlen(new_pass), (unsigned int *)&new_psw_len);
+#else
+ current_psw = (char*)zte_base64_decode((const unsigned char *)old_pass, strlen(old_pass), (unsigned int *)¤t_psw_len);
+ new_psw = (char*)zte_base64_decode((const unsigned char *)new_pass, strlen(new_pass), (unsigned int *)&new_psw_len);
+#endif
+
+ if (NULL == current_psw || NULL == new_psw) {
+ slog(MISC_PRINT, SLOG_ERR, "current_psw or new_psw is NULL\n"); /*lint !e26*/
+ zte_write_result_to_web(wp, FAILURE);
+ free(current_psw);
+ free(new_psw);
+ return;
+ }
+ slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw:%s\n", new_psw); /*lint !e26*/
+ slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw_len:%d\n", new_psw_len); /*lint !e26*/
+ if(current_psw_len < sizeof(old_psw_admin))
+ snprintf(old_psw_admin,current_psw_len+1,"%s",current_psw);
+ else
+ snprintf(old_psw_admin,sizeof(old_psw_admin),"%s",current_psw);
+ //strncpy(old_psw_admin, current_psw, CONFIG_DEFAULT_LENGTH-1);
+ if(new_psw_len < sizeof(new_psw_admin))
+ snprintf(new_psw_admin,new_psw_len+1,"%s",new_psw);
+ else
+ snprintf(new_psw_admin,sizeof(new_psw_admin),"%s",new_psw);
+ //strncpy(new_psw_admin, new_psw, CONFIG_DEFAULT_LENGTH-1);
+ free(current_psw);
+ free(new_psw);
+ slog(MISC_PRINT, SLOG_DEBUG, "user_modify:new_psw_admin:%s\n", new_psw_admin); /*lint !e26*/
+
+ if (LOGIN_PSW_MIN_LEN > new_psw_len || LOGIN_PSW_MAX_LEN < new_psw_len) {
+ slog(MISC_PRINT, SLOG_ERR, "new_psw_len is too long\n"); /*lint !e26*/
+ cfg_set("data_safe", "failed");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ if (DATA_NO_SAFE == zte_Safe_noSpecialChar(old_psw_admin)
+ || DATA_NO_SAFE == zte_Safe_noSpecialChar(new_psw_admin)) {
+ slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:old_pass:%s,new_pass:%s\n", old_psw_admin, new_psw_admin); /*lint !e26*/
+ cfg_set("data_safe", "failed");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ //cfg_get_item("admin_Password", admin_psw_buf, sizeof(admin_psw_buf));
+ //if (0 != strcmp(old_psw_admin, admin_psw_buf)) {
+ if (0 != web_check_pwd(old_psw_admin)) {
+#ifdef WEBS_SECURITY
+ cfg_set(NV_USER_IP_ADDR, "");
+ cfg_set(NV_LOGINFO, "");
+ cfg_set(NV_COOKIE_ID, "");
+ cfg_set(NV_WEB_TOKEN, "");
+ security_log(MODULE_ID_WEB_CGI,"web changepwd fail logout");
+#endif
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User change passwd!\n"));
+
+ //cfg_set("admin_Password", new_psw_admin);
+ web_set_pwd(new_psw_admin);
+ //cfg_set("user_save", "");
+ cfg_set("psw_save", "");
+ cfg_set("save_login", "");
+ cfg_set("psw_changed", "1");/*³õʼÃÜÂëÐ޸ıêʶ*/
+/*
+ char cmd[82] = {0};
+ sprintf(cmd, "mksmbpasswd.sh \'%s\'", new_psw_admin);
+ system(cmd);
+ system("killall smbd");
+ system("killall nmbd");
+ system("smbd -D");
+ system("nmbd -D");
+*/
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+int zte_mgmt_check_password(webs_t wp)
+{
+ char_t *tmp_old_psw = NULL;
+ char_t *old_psw = NULL;
+ int old_psw_len = 0;
+ char old_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+ //char admin_psw_buf[CONFIG_DEFAULT_LENGTH] = {0};
+
+ tmp_old_psw = websGetVar(wp, T("oldPassword"), NULL);
+ if (NULL != tmp_old_psw) {
+ old_psw = (char*)zte_base64_decode((const unsigned char *)tmp_old_psw, strlen(tmp_old_psw), (unsigned int *)&old_psw_len);
+ if (NULL == old_psw) {
+ slog(MISC_PRINT, SLOG_DEBUG, "current_psw or new_psw is NULL\n"); /*lint !e26*/
+ return -1;
+ }
+ slog(MISC_PRINT, SLOG_NORMAL,"zte_mgmt_check_password old_psw:%s!\n", old_psw);
+ if(old_psw_len < sizeof(old_psw_admin))
+ snprintf(old_psw_admin,old_psw_len+1,"%s",old_psw);
+ else
+ snprintf(old_psw_admin,sizeof(old_psw_admin),"%s",old_psw);
+ //strncpy(old_psw_admin, old_psw, CONFIG_DEFAULT_LENGTH-1);
+ free(old_psw);
+
+ if (DATA_NO_SAFE == zte_Safe_noSpecialChar(old_psw_admin)) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_check_password old_psw_admin Get Data is no Safe!\n");
+ cfg_set("data_safe", "failed");
+ return -1;
+ }
+
+ //cfg_get_item("admin_Password", admin_psw_buf, sizeof(admin_psw_buf));
+ //if (0 != strcmp(old_psw_admin, admin_psw_buf)) {
+ if (0 != web_check_pwd(old_psw_admin)) {
+#ifdef WEBS_SECURITY
+ cfg_set(NV_USER_IP_ADDR, "");
+ cfg_set(NV_LOGINFO, "");
+ cfg_set(NV_COOKIE_ID, "");
+ cfg_set(NV_WEB_TOKEN, "");
+ security_log(MODULE_ID_WEB_CGI,"web checkpwd fail logout");
+#endif
+ slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_check_password admin_Password fail!\n");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+int zte_mgmt_handle_account(webs_t wp)
+{
+ char_t *tmp_new_user = NULL;
+ char_t *tmp_new_psw = NULL;
+ char_t *new_user = NULL;
+ char_t *new_psw = NULL;
+ int new_psw_len = 0;
+ int new_user_len = 0;
+ char new_user_admin[CONFIG_DEFAULT_LENGTH] = {0};
+ char new_psw_admin[CONFIG_DEFAULT_LENGTH] = {0};
+
+ tmp_new_psw = websGetVar(wp, T("newPassword"), NULL);
+ tmp_new_user = websGetVar(wp, T("newUserName"), NULL);
+
+ if (NULL == tmp_new_psw || NULL == tmp_new_user) {
+ return -1;
+ }
+
+ new_psw = (char*)zte_base64_decode((const unsigned char *)tmp_new_psw, strlen(tmp_new_psw), (unsigned int *)&new_psw_len);
+ if (NULL == new_psw) {
+ slog(MISC_PRINT, SLOG_ERR, "new_psw is NULL\n"); /*lint !e26*/
+ return -1;
+ }
+ new_user = (char*)zte_base64_decode((const unsigned char *)tmp_new_user, strlen(tmp_new_user), (unsigned int *)&new_user_len);
+
+ if (NULL == new_user) {
+ free(new_psw);
+ slog(MISC_PRINT, SLOG_ERR, "new_user is NULL\n"); /*lint !e26*/
+ return -1;
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_mgmt_handle_account new_psw:%s!\n", new_psw);
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_mgmt_handle_account new_user:%s!\n", new_user);
+ if(new_psw_len < sizeof(new_psw_admin))
+ snprintf(new_psw_admin,new_psw_len+1,"%s",new_psw);
+ else
+ snprintf(new_psw_admin,sizeof(new_psw_admin),"%s",new_psw);
+ //strncpy(new_psw_admin, new_psw, CONFIG_DEFAULT_LENGTH-1);
+ if(new_user_len < sizeof(new_user_admin))
+ snprintf(new_user_admin,new_user_len+1,"%s",new_psw);
+ else
+ snprintf(new_user_admin,sizeof(new_user_admin),"%s",new_psw);
+ //strncpy(new_user_admin, new_user, CONFIG_DEFAULT_LENGTH-1);
+ free(new_psw);
+ free(new_user);
+
+ if (LOGIN_PSW_MIN_LEN > new_psw_len || LOGIN_PSW_MAX_LEN < new_psw_len) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_handle_account new_psw_len is too long!\n");
+ cfg_set("data_safe", "failed");
+ return -1;
+ }
+
+ if (LOGIN_PSW_MIN_LEN > new_user_len || LOGIN_PSW_MAX_LEN < new_user_len) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_handle_account new_user_len is too long!\n");
+ cfg_set("data_safe", "failed");
+ return -1;
+ }
+
+ if (DATA_NO_SAFE == zte_Safe_noSpecialChar(new_psw_admin)
+ || DATA_NO_SAFE == zte_Safe_noSpecialChar(new_user_admin)) {
+ slog(MISC_PRINT, SLOG_ERR,"zte_mgmt_handle_account Get Data is no Safe!\n");
+ cfg_set("data_safe", "failed");
+ return -1;
+ }
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User change account!\n"));
+
+ cfg_set("admin_user", new_user_admin);
+ //cfg_set("admin_Password", new_psw_admin);
+ web_set_pwd(new_psw_admin);
+ //cfg_set("user_save", "");
+ cfg_set("psw_save", "");
+ cfg_set("save_login", "");
+ //cfg_save();
+/*
+ char cmd[82] = {0};
+ sprintf(cmd, "mksmbpasswd.sh \'%s\'", new_psw_admin);
+ system(cmd);
+ system("killall smbd");
+ system("killall nmbd");
+ system("smbd -D");
+ system("nmbd -D");
+*/
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_mgmt_handle_account success!\n");
+ return 0;
+}
+
+void zte_mgmt_change_account(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_NORMAL,"zte_mgmt_change_account ====================!\n");
+
+ if (0 != zte_mgmt_check_password(wp)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ if (0 != zte_mgmt_handle_account(wp)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/******************************************************
+* Function: void zte_mgmt_pin_input(webs_t wp)
+* Description: deal with the pin code input goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_mgmt_pin_input(webs_t wp)
+{
+ char *pPinCode = NULL;
+ UINT32 length = 0;
+ T_zAt_CpinPukSet para = {0};
+ UINT32 ret = 0;
+ char modem_main_state[NV_ITEM_STRING_LEN_50] = {0};
+
+ pPinCode = websGetVar(wp, T("PinNumber"), T(""));
+ length = strlen(pPinCode);
+ if (0 == length || length >= sizeof(para.pin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ strncpy(para.pin, pPinCode,sizeof(para.pin)-1);
+ cfg_set(NV_PIN_PUK_PROCESS, "begin");
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_VERIFY_PIN_REQ, sizeof(T_zAt_CpinPukSet), (UCHAR *)¶, 0);
+ if (0 != ret) {
+ cfg_set(NV_PIN_PUK_PROCESS, "");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ wait_verify(NV_PIN_PUK_PROCESS, "end");
+
+ (void)sleep(1);
+ (void)zte_web_read(NV_MODEM_MAIN_STATE, modem_main_state);
+
+ if (0 != strcmp(modem_main_state, "modem_waitpin")) {
+ zte_write_result_to_web(wp, SUCCESS);
+ } else {
+ zte_write_result_to_web(wp, FAILURE);
+ }
+}
+/******************************************************
+* Function: void zte_mgmt_puk_input(webs_t wp)
+* Description: deal with the puk code input goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_mgmt_puk_input(webs_t wp)
+{
+ char *pPukCode = NULL;
+ char *pNewPin = NULL;
+ int length = 0;
+ int ret = 0;
+ T_zAt_CpinPukSet para = {0};
+ CHAR modem_main_state[NV_ITEM_STRING_LEN_50] = {0};
+
+ pPukCode = websGetVar(wp, T("PUKNumber"), T(""));
+ pNewPin = websGetVar(wp, T("PinNumber"), T(""));
+
+ length = strlen(pPukCode);
+ if (0 == length || length >= sizeof(para.pin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ length = strlen(pNewPin);
+ if (0 == length || length >= sizeof(para.newpin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ strncpy(para.pin, pPukCode,sizeof(para.pin)-1);
+ strncpy(para.newpin, pNewPin,sizeof(para.newpin)-1);
+ cfg_set(NV_PIN_PUK_PROCESS, "begin");
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_VERIFY_PUK_REQ, sizeof(T_zAt_CpinPukSet), (UCHAR *)¶, 0);
+ if (0 != ret) {
+ cfg_set(NV_PIN_PUK_PROCESS, "");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ wait_verify(NV_PIN_PUK_PROCESS, "end");
+
+ (void)sleep(1);
+ (void)zte_web_read("pinset_result", modem_main_state);
+
+ if (0 != strcmp(modem_main_state, "fail")) {
+ zte_write_result_to_web(wp, SUCCESS);
+ } else {
+ zte_write_result_to_web(wp, FAILURE);
+ }
+}
+
+void zte_mgmt_auto_pin(webs_t wp)
+{
+ char *pPinEable = NULL;
+ char *pPinCode = NULL;
+ int length = 0;
+
+ pPinEable = websGetVar(wp, T("auto_simpin"), T(""));
+ pPinCode = websGetVar(wp, T("auto_simpin_code"), T(""));
+
+ length = strlen(pPinCode);
+ if (0 == length || length > 8) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ length = strlen(pPinEable);
+ if (1 != length) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ cfg_set("auto_simpin", pPinEable);
+ cfg_set("auto_simpin_code", pPinCode);
+ zte_write_result_to_web(wp, SUCCESS);
+
+}
+/******************************************************
+* Function: void zte_mgmt_unlock_network(webs_t wp)
+* Description: deal with the unlock code input goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_mgmt_unlock_network(webs_t wp)
+{
+ char *unlock_code = NULL;
+ UNLOCK_PARA_ST para;
+ int length = 0;
+ int ret = 0;
+
+ memset(¶, 0, sizeof(UNLOCK_PARA_ST));
+
+ unlock_code = websGetVar(wp, T("unlock_network_code"), T(""));
+ slog(MISC_PRINT, SLOG_DEBUG, "unlock_code=%s", unlock_code); /*lint !e26*/
+ length = strlen(unlock_code);
+ if (0 == length || length >= sizeof(para.unlock_code)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ strncpy(para.unlock_code, unlock_code,sizeof(para.unlock_code)-1);
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_UNLOCK_REQ, sizeof(UNLOCK_PARA_ST), (UCHAR *)¶, 0);
+ if (0 != ret) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ wait_verify("unlock_at_wait", "0");
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+
+/*PINÂë½ûÓÃ*/
+void zte_mgmt_disable_pin(webs_t wp)
+{
+ char *pOldPin = NULL;
+ T_zAt_PinManage para = {0};
+ int length = 0;
+ int ret = 0;
+ char pin_manage_result[NV_ITEM_STRING_LEN_5] = {0};
+
+ pOldPin = websGetVar(wp, T("OldPinNumber"), T(""));
+ length = strlen(pOldPin);
+ if (0 == length || length >= sizeof(para.oldPin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ strncpy(para.oldPin, pOldPin,sizeof(para.oldPin)-1);
+ para.action = PIN_MANAGE_DISABLE;
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User disable pin!\n"));
+
+ (void)zte_web_write("pin_manage_process", "begin");
+ slog(MISC_PRINT, SLOG_NORMAL, "zte_goform_mgmt_pin_mgmt_process send message: ZUFI_MODULE_ID_AT_MAIN, MSG_CMD_WEB_REQ_PIN_MANAGE");
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PIN_MANAGE_REQ, sizeof(T_zAt_PinManage), (UCHAR *)¶, 0);
+ if (0 != ret) {
+ cfg_set("pin_manage_process", "");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ /*ÉèÖõȴýpinÂë¹ÜÀí¶¯×÷AT´¦Àí½áÊø*/
+ wait_verify("pin_manage_process", "end");
+
+ (void)zte_web_read("pin_manage_result", pin_manage_result);
+ (void)zte_web_write("pin_manage_result", "");
+
+ if (0 == strcmp(pin_manage_result, "0")) {
+ zte_write_result_to_web(wp, SUCCESS);
+ } else {
+ zte_write_result_to_web(wp, FAILURE);
+ }
+}
+
+/*PINÂëÆôÓûòÐÞ¸Ä*/
+void zte_mgmt_pin_enable_or_modify(webs_t wp)
+{
+ CHAR *pOldPin = NULL;
+ CHAR *pNewPin = NULL;
+
+ if (NULL == wp) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ pOldPin = websGetVar(wp, T("OldPinNumber"), T(""));
+ pNewPin = websGetVar(wp, T("NewPinNumber"), T(""));
+
+ slog(MISC_PRINT, SLOG_DEBUG, "web para:[OldPinNumber] is [%s].", pOldPin);
+ slog(MISC_PRINT, SLOG_DEBUG, "web para:[NewPinNumber] is [%s].", pNewPin);
+
+ if ('\0' == (*pOldPin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ if (0 == strcmp(pNewPin, "")) {
+ zte_mgmt_enable_pin(wp, pOldPin);
+ } else {
+ zte_mgmt_modify_pin(wp, pOldPin, pNewPin);
+ }
+
+
+}
+static void zte_mgmt_enable_pin(webs_t wp, CHAR *pOldPin)
+{
+ T_zAt_PinManage para = {0};
+ int ret = 0;
+ char pin_manage_result[NV_ITEM_STRING_LEN_5] = {0};
+
+
+ if ((NULL == wp) || (NULL == pOldPin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ strncpy(para.oldPin, pOldPin,sizeof(para.oldPin)-1);
+ para.action = PIN_MANAGE_ENABLE;
+ if ('\0' == (*pOldPin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User enable pin!\n"));
+
+ (void)zte_web_write("pin_manage_process", "begin");
+ slog(MISC_PRINT, SLOG_NORMAL, "zte_mgmt_enable_pin send message : ZUFI_MODULE_ID_AT_MAIN, MSG_CMD_WEB_REQ_PIN_MANAGE.");
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PIN_MANAGE_REQ, sizeof(T_zAt_PinManage), (UCHAR *)¶, 0);
+ if (0 != ret) {
+ cfg_set("pin_manage_process", "");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ /*ÉèÖõȴýpinÂë¹ÜÀí¶¯×÷AT´¦Àí½áÊø*/
+ wait_verify("pin_manage_process", "end");
+
+ (void)zte_web_read("pin_manage_result", pin_manage_result);
+ (void)zte_web_write("pin_manage_result", "");
+
+ if (0 == strcmp(pin_manage_result, "0")) {
+ zte_write_result_to_web(wp, SUCCESS);
+ } else {
+ zte_write_result_to_web(wp, FAILURE);
+ }
+}
+
+/**********************************************************************
+* Function: zte_mgmt_modify_pin
+* Description: to modify pin
+* Input: wp: the web para;old_pin: old pin number; new_pin:new pin number
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* -----------------------------------------------
+* 2011/11/16 V1.0 chenyi first version
+**********************************************************************/
+
+static void zte_mgmt_modify_pin(webs_t wp, CHAR *pOldPin, CHAR *pNewPin)
+{
+ int length = 0;
+ int ret = 0;
+ T_zAt_PinManage para = {0};
+ char pin_manage_result[NV_ITEM_STRING_LEN_5] = {0};
+
+ if ((NULL == wp) || (NULL == pOldPin) || (NULL == pNewPin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ if (('\0' == (*pOldPin)) || ('\0' == (*pNewPin))) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ length = strlen(pNewPin);
+ if (0 == length || length >= sizeof(para.newPin)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User modify pin!\n"));
+
+ para.action = PIN_MANAGE_MODIFY;
+ strncpy(para.oldPin, pOldPin,sizeof(para.oldPin)-1);
+ strncpy(para.newPin, pNewPin,sizeof(para.newPin)-1);
+ (void)zte_web_write("pin_manage_process", "begin");
+ slog(MISC_PRINT, SLOG_NORMAL, "zte_mgmt_modify_pin send message : ZUFI_MODULE_ID_AT_MAIN, MSG_CMD_WEB_REQ_PIN_MANAGE.");
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PIN_MANAGE_REQ, sizeof(T_zAt_PinManage), (UCHAR *)¶, 0);
+ if (0 != ret) {
+ cfg_set("pin_manage_process", "");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ /*ÉèÖõȴýpinÂë¹ÜÀí¶¯×÷AT´¦Àí½áÊø*/
+ wait_verify("pin_manage_process", "end");
+
+
+ (void)zte_web_read("pin_manage_result", pin_manage_result);
+ (void)zte_web_write("pin_manage_result", "");
+
+ if (0 == strcmp(pin_manage_result, "0")) {
+ zte_write_result_to_web(wp, SUCCESS);
+ } else {
+ zte_write_result_to_web(wp, FAILURE);
+ }
+}
+/******************************************************
+* Function: void zte_quick_setup(webs_t wp)
+* Description: deal with the quick setup goform
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void zte_quick_setup(webs_t wp)
+{
+ int iFunc = 0;
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User quick setup!\n"));
+
+ for (iFunc = 0; iFunc < MAX_QUICK_SET_NUM; iFunc++) {
+ if (G_ZQUICK_SET[iFunc] != NULL) {
+ G_ZQUICK_SET[iFunc](wp);
+ }
+ }
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+int save_data_to_file(char *file_path, unsigned char *data, int len)
+{
+ int file_fd = -1;
+ int ret = -1;
+
+
+ if (NULL == file_path || NULL == data) {
+ slog(MISC_PRINT, SLOG_ERR,"Input para is invalid, null point!");
+ return -1;
+ }
+
+ // O_TRUNC:½«Îļþ³¤¶È½Ø¶ÏΪ0£¬×öΪÐÂÎļþдÈë
+ file_fd = open(file_path, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 777);
+ if (file_fd < 0) {
+ slog(MISC_PRINT, SLOG_ERR,"Open file fail, error:%s, file path:%s", strerror(errno), file_path);
+ return -1;
+ }
+
+ ret = write(file_fd, (void *)data, len);
+ if (ret != len) {
+ slog(MISC_PRINT, SLOG_ERR,"Write data to file fail, error:%s, file path:%s", strerror(errno), file_path);
+ goto error;
+ }
+
+ ret = fsync(file_fd);
+ if (ret < 0) {
+ slog(MISC_PRINT, SLOG_ERR,"Sync Failed:%s, file path:%s", strerror(errno), file_path);
+ goto error;
+ }
+
+
+ ret = 0;
+ goto end;
+
+error:
+ ret = -1;
+
+end:
+ close(file_fd);
+
+ file_fd = -1;
+
+ return ret;
+
+}
+
+void zte_goform_mgmt_schedule_setting_process(webs_t wp)
+{
+ char *schedule_enable = NULL;
+ char *schedule_hour = NULL;
+ char *schedule_minute = NULL;
+
+ schedule_enable = websGetVar(wp, T("scheduleEnabled"), T(""));
+
+ if(0 == strcmp("1", schedule_enable))
+ {
+ schedule_hour = websGetVar(wp, T("scheduleHour"), T(""));
+ schedule_minute = websGetVar(wp, T("scheduleMinute"), T(""));
+ cfg_set("schedule_restart_enable", schedule_enable);
+ cfg_set("schedule_restart_hour", schedule_hour);
+ cfg_set("schedule_restart_minute", schedule_minute);
+
+ zte_write_result_to_web(wp, SUCCESS);
+ return;
+ }
+ else if(0 == strcmp("0", schedule_enable))
+ {
+ cfg_set("schedule_restart_enable", schedule_enable);
+ cfg_set("schedule_restart_hour", "0");
+ cfg_set("schedule_restart_minute", "0");
+
+ zte_write_result_to_web(wp, SUCCESS);
+ return;
+ }
+
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+}
+
+/******************************************************
+* Function: void zte_goform_mgmt_sntp_process(webs_t wp)
+* Description: deal with the sntp
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2011/04/13 V1.0 mengyuan create
+*******************************************************/
+void zte_goform_mgmt_sntp_process(webs_t wp)
+{
+ MSG_BUF msg;
+ int lTgtMsgID = 0;
+ char *mode = NULL;
+ char *sntp_server0 = NULL;
+ char *sntp_server1 = NULL;
+ char *sntp_server2 = NULL;
+ char *sntp_timezone = NULL;
+ int result = 0;
+ LONG msgSize = sizeof(MSG_BUF) - sizeof(LONG);
+ char *ntp_server = NULL;
+ int sem_id = 0;
+ char state[NV_ITEM_STRING_LEN_20] = {0};
+ char sntp_timezone_tmp[NV_ITEM_STRING_LEN_64] = {0};
+ //char cmd[100] = {0};
+
+ memset(&msg, 1, sizeof(MSG_BUF));
+ mode = websGetVar(wp, T("manualsettime"), T(""));
+ cfg_set("sntp_time_set_mode", mode);
+
+ sntp_server0 = websGetVar(wp, T("sntp_server1_ip"), T(""));
+ sntp_server1 = websGetVar(wp, T("sntp_server2_ip"), T(""));
+ sntp_server2 = websGetVar(wp, T("sntp_server3_ip"), T(""));
+ cfg_set("sntp_server0", sntp_server0);
+ cfg_set("sntp_server1", sntp_server1);
+ cfg_set("sntp_server2", sntp_server2);
+
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set sntp time!\n"));
+
+ if (strcmp(sntp_server0, "Other") == 0) {
+ cfg_set("sntp_other_server0", websGetVar(wp, T("sntp_other_server0"), T("")));
+ }
+ if (strcmp(sntp_server1, "Other") == 0) {
+ cfg_set("sntp_other_server1", websGetVar(wp, T("sntp_other_server1"), T("")));
+ }
+ if (strcmp(sntp_server2, "Other") == 0) {
+ cfg_set("sntp_other_server2", websGetVar(wp, T("sntp_other_server2"), T("")));
+ }
+ cfg_set("sntp_timezone_index", websGetVar(wp, T("sntp_timezone_index"), T("")));
+ //cfg_set("sntp_timezone", websGetVar(wp, T("timezone"), T("")));
+ cfg_set("sntp_dst_enable", websGetVar(wp, T("DaylightEnabled"), T("")));
+
+ cfg_set("manual_time_year", websGetVar(wp, T("time_year"), T("")));
+ cfg_set("manual_time_month", websGetVar(wp, T("time_month"), T("")));
+ cfg_set("manual_time_day", websGetVar(wp, T("time_day"), T("")));
+ cfg_set("manual_time_hour", websGetVar(wp, T("time_hour"), T("")));
+ cfg_set("manual_time_minute", websGetVar(wp, T("time_minute"), T("")));
+ cfg_set("manual_time_second", websGetVar(wp, T("time_second"), T("")));
+ //ÉèÖÃÊ±Çø
+ sntp_timezone = websGetVar(wp, T("timezone"), T(""));
+ cfg_set("sntp_timezone", sntp_timezone);
+
+ //memset(cmd, 0, 100);
+ //sprintf(cmd, "echo \"%s\" > /etc_rw/TZ", sntp_timezone);
+ //system(cmd);
+ snprintf(sntp_timezone_tmp,sizeof(sntp_timezone_tmp),"%s\n",sntp_timezone);
+ save_data_to_file("/etc_rw/TZ",sntp_timezone_tmp,strlen(sntp_timezone_tmp));
+
+ if (strcmp(mode, "manual") == 0) {
+ sem_id = get_sem(TIME_SEM_KEY_1);
+ if (sem_id != -1) {
+ sem_p(sem_id);
+ slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_p, sem_id = %d\r\n", sem_id);
+ }
+
+ result = manual_set_time();
+
+ if (sem_id != -1) {
+ sem_v(sem_id);
+ slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_v, sem_id = %d\r\n", sem_id);
+ }
+
+ cfg_set("sntp_year", websGetVar(wp, T("time_year"), T("")));
+ cfg_set("sntp_month", websGetVar(wp, T("time_month"), T("")));
+ cfg_set("sntp_day", websGetVar(wp, T("time_day"), T("")));
+ cfg_set("sntp_hour", websGetVar(wp, T("time_hour"), T("")));
+ cfg_set("sntp_minute", websGetVar(wp, T("time_minute"), T("")));
+ cfg_set("sntp_second", websGetVar(wp, T("time_second"), T("")));
+ cfg_set("sntp_process_result", "success");
+ if (result < 0) {
+ zte_write_result_to_web(wp, FAILURE);
+ } else {
+ if (!zte_mgmt_login_timemark_set()) {
+ slog(MISC_PRINT, SLOG_ERR, "[ERROR]zte_goform_whitelist_check -> timemark set error .\n"); /*lint !e26*/
+ }
+ zte_write_result_to_web(wp, SUCCESS);
+ }
+ } else if (strcmp(mode, "auto") == 0) {
+ cfg_get_item("sntp_process_state", state, sizeof(state));
+ if (strcmp(state, "over") != 0) {
+ zte_write_result_to_web(wp, PROCESSING);
+ slog(MISC_PRINT, SLOG_DEBUG,"[SNTP] already runing return \n");
+ return;
+ }
+ cfg_set("sntp_process_state", "idle");
+ //cfg_set("systime_mode", "auto");
+ //cfg_set("sntp_cmd_from", "WEBUI");
+ cfg_set("sntp_process_result", "");
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SNTP, MSG_CMD_SNTP_START, 0, NULL, 0);
+ zte_write_result_to_web(wp, SUCCESS);
+ } else {
+ sem_id = get_sem(TIME_SEM_KEY_1);
+ if (sem_id != -1) {
+ sem_p(sem_id);
+ slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_p, sem_id = %d\r\n", sem_id);
+ }
+
+ result = manual_set_time();
+
+ if (sem_id != -1) {
+ sem_v(sem_id);
+ slog(MISC_PRINT, SLOG_DEBUG,"[MANUAL] manual_set_time, sem_v, sem_id = %d\r\n", sem_id);
+ }
+
+ cfg_set("sntp_year", websGetVar(wp, T("time_year"), T("")));
+ cfg_set("sntp_month", websGetVar(wp, T("time_month"), T("")));
+ cfg_set("sntp_day", websGetVar(wp, T("time_day"), T("")));
+ cfg_set("sntp_hour", websGetVar(wp, T("time_hour"), T("")));
+ cfg_set("sntp_minute", websGetVar(wp, T("time_minute"), T("")));
+ cfg_set("sntp_second", websGetVar(wp, T("time_second"), T("")));
+
+ if (result < 0) {
+ zte_write_result_to_web(wp, FAILURE);
+ } else {
+ if (!zte_mgmt_login_timemark_set()) {
+ slog(MISC_PRINT, SLOG_ERR, "[ERROR]zte_goform_whitelist_check -> timemark set error .\n"); /*lint !e26*/
+ }
+ zte_write_result_to_web(wp, SUCCESS);
+ }
+ }
+}
+
+static void wait_verify(char *wait_name, char *wait_value)
+{
+ int i = 0;
+ char buf[NV_ITEM_STRING_LEN_200] = {0};
+
+ if (NULL == wait_name || NULL == wait_value) {
+ return;
+ }
+
+ for (i = 0; i < 10; i++) {
+ sleep(2);
+ cfg_get_item(wait_name, buf, sizeof(buf));
+ if (0 == strcmp(wait_value, buf)) {
+ break;
+ }
+ }
+ return;
+}
+
+
+void deal_quick_setup_wifi_basic(webs_t wp)
+{
+ deal_quick_setup_wifi_basic_mgmt(wp);
+}
+static int deal_quick_setup_auto_apn_set()
+{
+ APN_PROFILE newProfile = { 0 };
+ char ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+
+ get_autoapn_profile(&newProfile);
+ set_apn_to_cfg(&newProfile, NULL);
+ cfg_set("ipv6_wan_apn", newProfile.apn_name);
+
+ cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+ if (0 == strcmp("ppp_disconnected", ppp_status) || 0 == strcmp("ppp_ready", ppp_status)) {
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+ }
+ return 0;
+}
+static void set_apn_to_cfg(APN_PROFILE *apn_profile, IPV6_APN_PROFILE *ipv6_apn_profile)
+{
+ if (apn_profile != NULL) {
+ cfg_set("m_profile_name", apn_profile->profile_name);
+ cfg_set("wan_apn", apn_profile->apn_name);
+ cfg_set("apn_select", apn_profile->apn_select);
+ cfg_set("wan_dial", apn_profile->dial_num);
+ cfg_set("ppp_auth_mode", apn_profile->ppp_auth_mode);
+ cfg_set("ppp_username", apn_profile->ppp_username);
+ cfg_set("ppp_passtmp", apn_profile->ppp_passwd);
+ cfg_set("pdp_type", apn_profile->pdp_type);
+ cfg_set("ipv6_pdp_type", apn_profile->pdp_type);
+ cfg_set("pdp_select", apn_profile->pdp_select);
+ cfg_set("pdp_addr", apn_profile->pdp_addr);
+ apn_encrypt_code();
+ }
+
+ if (ipv6_apn_profile != NULL) {
+ cfg_set("m_profile_name", ipv6_apn_profile->profile_name);
+ cfg_set("ipv6_wan_apn", ipv6_apn_profile->apn_name);
+ cfg_set("apn_select", ipv6_apn_profile->apn_select);
+ cfg_set("wan_dial", ipv6_apn_profile->dial_num);
+ cfg_set(NV_IPV6_PPP_AUTH_MODE, ipv6_apn_profile->ppp_auth_mode);
+ cfg_set("ipv6_ppp_username", ipv6_apn_profile->ppp_username);
+ cfg_set("ipv6_ppp_passtmp", ipv6_apn_profile->ppp_passwd);
+ cfg_set("pdp_type", ipv6_apn_profile->pdp_type);
+ cfg_set("ipv6_pdp_type", ipv6_apn_profile->pdp_type);
+ cfg_set("pdp_select", ipv6_apn_profile->pdp_select);
+ cfg_set("pdp_addr", ipv6_apn_profile->pdp_addr);
+ ipv6apn_encrypt_code();
+ }
+}
+
+
+static void deal_quick_setup_manual_apn_set(webs_t wp)
+{
+ IPV6_APN_PROFILE newIpv6Profile = { 0 };
+ APN_PROFILE newProfile = { 0 };
+ int index_apn = atoi(websGetVar(wp, "index", T("")));
+ char *pdp_type = websGetVar(wp, "pdp_type", T(""));
+ char *apn_name = websGetVar(wp, "wan_apn", T(""));
+ char *ipv6_wan_apn = websGetVar(wp, "ipv6_wan_apn", T(""));
+ char ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+ char *ppp_auth_mode = websGetVar(wp, "ppp_auth_mode", T(""));
+ char *ppp_username = websGetVar(wp, "ppp_username", T(""));
+ char *ppp_passwd = websGetVar(wp, "ppp_passtmp", T(""));
+ char *ipv6_pdp_auth_mode = websGetVar(wp, NV_IPV6_PPP_AUTH_MODE, T(""));
+ char *ipv6_ppp_username = websGetVar(wp, "ipv6_ppp_username", T(""));
+ char *ipv6_ppp_passwd = websGetVar(wp, "ipv6_ppp_passtmp", T(""));
+
+ slog(MISC_PRINT, SLOG_NORMAL,"[goahead] deal_quick_setup_manual_apn_set wan_apn %s. %s.\n", apn_name,ppp_username);
+
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User manual apn set!\n"));
+ if (0 == strcmp(pdp_type, "IPv6")) {
+ get_ipv6apn_profile_by_index(index_apn, &newIpv6Profile);
+ strncpy(newIpv6Profile.apn_name, ipv6_wan_apn,sizeof(newIpv6Profile.apn_name)-1);
+ strncpy(newIpv6Profile.ppp_auth_mode, ipv6_pdp_auth_mode,sizeof(newIpv6Profile.ppp_auth_mode)-1);
+ strncpy(newIpv6Profile.ppp_username, ipv6_ppp_username,sizeof(newIpv6Profile.ppp_username)-1);
+ strncpy(newIpv6Profile.ppp_passwd, ipv6_ppp_passwd,sizeof(newIpv6Profile.ppp_passwd)-1);
+ set_ipv6_apn_profile_by_index(index_apn, &newIpv6Profile);
+ set_ipv6_apn_prof_aes_by_index(index_apn, &newIpv6Profile);
+
+ set_apn_to_cfg(NULL, &newIpv6Profile);
+ } else if (0 == strcmp(pdp_type, "IPv4v6")) {
+ get_ipv4v6apn_profile_by_index(index_apn, &newProfile, &newIpv6Profile);
+ strncpy(newProfile.apn_name, apn_name,sizeof(newProfile.apn_name)-1);
+ strncpy(newProfile.ppp_auth_mode, ppp_auth_mode,sizeof(newProfile.ppp_auth_mode)-1);
+ strncpy(newProfile.ppp_username, ppp_username,sizeof(newProfile.ppp_username)-1);
+ strncpy(newProfile.ppp_passwd, ppp_passwd,sizeof(newProfile.ppp_passwd)-1);
+
+ strncpy(newIpv6Profile.apn_name, ipv6_wan_apn,sizeof(newIpv6Profile.apn_name)-1);
+ strncpy(newIpv6Profile.ppp_auth_mode, ipv6_pdp_auth_mode,sizeof(newIpv6Profile.ppp_auth_mode)-1);
+ strncpy(newIpv6Profile.ppp_username, ipv6_ppp_username,sizeof(newIpv6Profile.ppp_username)-1);
+ strncpy(newIpv6Profile.ppp_passwd, ipv6_ppp_passwd,sizeof(newIpv6Profile.ppp_passwd)-1);
+ set_ipv4v6_apn_profile_by_index(index_apn, &newProfile, &newIpv6Profile);
+ set_ipv4v6_apn_prof_aes_by_index(index_apn, &newProfile, &newIpv6Profile);
+
+ set_apn_to_cfg(&newProfile, &newIpv6Profile);
+ } else {
+ get_apn_profile_by_index(index_apn, &newProfile);
+ strncpy(newProfile.apn_name, apn_name,sizeof(newProfile.apn_name)-1);
+ strncpy(newProfile.ppp_auth_mode, ppp_auth_mode,sizeof(newProfile.ppp_auth_mode)-1);
+ strncpy(newProfile.ppp_username, ppp_username,sizeof(newProfile.ppp_username)-1);
+ strncpy(newProfile.ppp_passwd, ppp_passwd,sizeof(newProfile.ppp_passwd)-1);
+ set_apn_profile_by_index(index_apn, &newProfile);
+ set_apn_prof_aes_by_index(index_apn, &newProfile);
+
+ set_apn_to_cfg(&newProfile, NULL);
+ }
+
+ cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+ if (0 == strcmp("ppp_disconnected", ppp_status) || 0 == strcmp("ppp_ready", ppp_status)) {
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_APN_SET_REQ, 0, NULL, 0);
+ }
+}
+
+void deal_quick_setup_apn_ex(webs_t wp)
+{
+ if (strcmp(ZTE_WEB_ACT_MANUAL, websGetVar(wp, "apn_mode", T(""))) == 0) {
+ zte_web_write("apn_mode", ZTE_WEB_ACT_MANUAL);
+ deal_quick_setup_manual_apn_set(wp);
+ } else {
+ zte_web_write("apn_mode", ZTE_WEB_ACT_AUTO);
+ deal_quick_setup_auto_apn_set(); // cov low, deal_quick_setup_auto_apn_set does not need parameter
+ }
+}
+
+void deal_quick_setup_wifi_security(webs_t wp)
+{
+ deal_quick_setup_wifi_security_mgmt(wp);
+}
+
+static void deal_quick_setup_wps(webs_t wp)
+{
+ deal_quick_setup_wps_mgmt(wp);
+}
+/******************************************************
+* Function: void get_apn_profile_by_index(int index, APN_PROFILE *profile)
+* Description: get a apn profile by index from config
+* Input: index:the index of apn profile which to get
+* Output: profile:the result of apn profile config after splited
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void get_apn_profile_by_index(int index, APN_PROFILE *profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+ char *pos_begin = NULL;
+
+ if (NULL == profile) {
+ return;
+ }
+ //È¡Ã÷ÎÄAPN_configtmp,Õâʱ²»ÓÃÈ¡ÃÜÎÄ
+ sprintf(cfg_name, "APN_configtmp%d", index);
+
+ cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+ pos_begin = cfg_value;
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+ return;
+}
+
+void get_ipv6apn_profile_by_index(int index, IPV6_APN_PROFILE *profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+ char *pos_begin = NULL;
+
+ if (NULL == profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "ipv6_APN_configtmp%d", index);
+
+ cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+ slog(MISC_PRINT, SLOG_DEBUG, "get_ipv6apn_profile_by_index cfg_value=%s", cfg_value); /*lint !e26*/
+
+ pos_begin = cfg_value;
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+ slog(MISC_PRINT, SLOG_DEBUG, "========= profile->profile_name=%s=======", profile->profile_name); /*lint !e26*/
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+ slog(MISC_PRINT, SLOG_DEBUG, "=========profile->apn_name=%s=======", profile->apn_name); /*lint !e26*/
+
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+ return;
+}
+
+
+void get_ipv4v6apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+ char *pos_begin = NULL;
+
+ char ipv6_cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char ipv6_cfg_value[APNCONFIG_MEMORY] = {0};
+ char *ipv6_pos_begin = NULL;
+
+
+ if (NULL == profile) {
+ return;
+ }
+ if (NULL == ipv6profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "APN_configtmp%d", index);
+ cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+ pos_begin = cfg_value;
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+
+
+ sprintf(ipv6_cfg_name, "ipv6_APN_configtmp%d", index);
+ cfg_get_item(ipv6_cfg_name, ipv6_cfg_value, sizeof(ipv6_cfg_value));
+ ipv6_pos_begin = ipv6_cfg_value;
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->profile_name, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->apn_name, PROFILE_APN_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->apn_select, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->dial_num, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->ppp_username, PROFILE_APN_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->ppp_passwd, PROFILE_APN_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->pdp_type, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->pdp_select, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->pdp_addr, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->dns_mode, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+ ipv6_pos_begin = split_str_by_sep(ipv6_pos_begin, "($)", ipv6profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+
+
+ return;
+}
+
+
+
+void get_autoapn_profile(APN_PROFILE *profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+ char *pos_begin = NULL;
+ char buf[NV_ITEM_STRING_LEN_20] = {0};
+
+ int auto_apn_index = 0;
+ slog(MISC_PRINT, SLOG_DEBUG, "get_autoapn_profile\n"); /*lint !e26*/
+
+ cfg_get_item("auto_apn_index", buf, sizeof(buf));
+ auto_apn_index = atoi(buf);
+ slog(MISC_PRINT, SLOG_DEBUG, "auto_apn_index=%d\n", auto_apn_index); /*lint !e26*/
+ if (NULL == profile) {
+ return;
+ }
+
+ if (0 != auto_apn_index) {
+ sprintf(cfg_name, "apn_auto_config%d", auto_apn_index);
+ } else {
+ sprintf(cfg_name, "apn_auto_config");
+ }
+ slog(MISC_PRINT, SLOG_DEBUG, "cfg_name=%s\n", cfg_name); /*lint !e26*/
+
+ cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+ pos_begin = cfg_value;
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->profile_name, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_name, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->apn_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dial_num, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_auth_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_username, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->ppp_passwd, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_type, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->pdp_addr, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->dns_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->prefer_dns_manual, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile->standby_dns_manual, PROFILE_MEMBER_LEN);
+ return;
+}
+
+/******************************************************
+* Function: void set_apn_profile_by_index(int index, APN_PROFILE *profile)
+* Description: set a apn profile into config by index
+* Input: index:the index of apn profile which to set
+* profile:the struct of apn profile.
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+* 2010/11/26 V1.0 zyt create
+*******************************************************/
+void set_apn_profile_by_index(int index, APN_PROFILE *profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+
+ if (NULL == profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "APN_configtmp%d", index);
+ if (0 == strcmp(profile->pdp_type, "IPv6")) {
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "");
+ } else {
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ profile->apn_name,
+ profile->apn_select,
+ profile->dial_num,
+ profile->ppp_auth_mode,
+ profile->ppp_username,
+ profile->ppp_passwd,
+ profile->pdp_type,
+ profile->pdp_select,
+ profile->pdp_addr,
+ profile->dns_mode,
+ profile->prefer_dns_manual,
+ profile->standby_dns_manual);
+ }
+ cfg_set(cfg_name, cfg_value);
+
+ return;
+}
+
+void set_ipv6_apn_profile_by_index(int index, IPV6_APN_PROFILE *profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+
+ if (NULL == profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "ipv6_APN_configtmp%d", index);
+ if (0 == strcmp(profile->pdp_type, "IP")) {
+ slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=IP cpsnprintf "); /*lint !e26*/
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "");
+ } else {
+ slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=else cpsnprintf "); /*lint !e26*/
+ slog(MISC_PRINT, SLOG_DEBUG, "profile->profile_name=%s ", profile->profile_name); /*lint !e26*/
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ profile->apn_name,
+ profile->apn_select,
+ profile->dial_num,
+ profile->ppp_auth_mode,
+ profile->ppp_username,
+ profile->ppp_passwd,
+ profile->pdp_type,
+ profile->pdp_select,
+ profile->pdp_addr,
+ profile->dns_mode,
+ profile->prefer_dns_manual,
+ profile->standby_dns_manual);
+ }
+ slog(MISC_PRINT, SLOG_DEBUG, "cfg_value=%s", cfg_value); /*lint !e26*/
+ cfg_set(cfg_name, cfg_value);
+
+ return;
+}
+
+void set_ipv4v6_apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+
+ if (NULL == profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "APN_configtmp%d", index);
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ profile->apn_name,
+ profile->apn_select,
+ profile->dial_num,
+ profile->ppp_auth_mode,
+ profile->ppp_username,
+ profile->ppp_passwd,
+ profile->pdp_type,
+ profile->pdp_select,
+ profile->pdp_addr,
+ profile->dns_mode,
+ profile->prefer_dns_manual,
+ profile->standby_dns_manual);
+
+ cfg_set(cfg_name, cfg_value);
+
+ memset(cfg_name, 0, sizeof(cfg_name));
+ memset(cfg_value, 0, sizeof(cfg_value));
+ sprintf(cfg_name, "ipv6_APN_configtmp%d", index);
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ ipv6profile->profile_name,
+ ipv6profile->apn_name,
+ ipv6profile->apn_select,
+ ipv6profile->dial_num,
+ ipv6profile->ppp_auth_mode,
+ ipv6profile->ppp_username,
+ ipv6profile->ppp_passwd,
+ ipv6profile->pdp_type,
+ ipv6profile->pdp_select,
+ ipv6profile->pdp_addr,
+ ipv6profile->dns_mode,
+ ipv6profile->prefer_dns_manual,
+ ipv6profile->standby_dns_manual);
+
+ cfg_set(cfg_name, cfg_value);
+
+ return;
+}
+
+static char *split_str_by_sep(char *src, char *sep, char *dst, int len)
+{
+ char *pos_begin = NULL;
+ char *pos_end = NULL;
+
+ if (NULL == src || NULL == sep || NULL == dst || 0 == len) {
+ return NULL;
+ }
+
+ pos_begin = src;
+ pos_end = strstr(pos_begin, sep);
+
+ if (NULL == pos_end) {
+ return NULL;
+ }
+
+ if (len <= (pos_end - pos_begin)) {
+ return NULL;
+ }
+
+ strncpy(dst, pos_begin, pos_end - pos_begin);
+ pos_end += strlen(sep);
+ return pos_end;
+}
+
+void zte_mgmt_set_login_timemark()
+{
+ char login_timemark[NV_ITEM_STRING_LEN_20] = {0};
+ long now_timemark = time(0);
+
+ sprintf(login_timemark, "%ld", now_timemark);
+ zte_web_write(NV_USER_LOGIN_TIMEMARK, login_timemark);
+ slog(MISC_PRINT, SLOG_NORMAL,"[SNTP] [manual] timemark, user_login_timemark=%ld\n", now_timemark);
+}
+
+int manual_set_time()
+{
+ struct timeval tp;
+ time_t nowtime;
+ time_t SynBeforeTime = 0;
+ int ltime = 0, mtime = 0, ntime = 0;
+ char SynSystemTotal[16] = {0};
+ char SynPppTotal[16] = {0};
+ char SynSecond[16] = {0};
+ int year = 0, month = 0, day = 0;
+ int hour = 0, minute = 0, second = 0;
+ int days = 0;
+ int LeapYear = 0;
+ int CommonYear = 0;
+ int YearTotal = 0;
+ int count;
+ int flag = 0;
+ int i;
+ int ret = 0;
+ char buf[NV_ITEM_STRING_LEN_10] = {0};
+ char ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+ struct tm timeToSet = {0};
+ int dataLen = 0;
+ cfg_get_item("manual_time_year", buf, sizeof(buf));
+ year = atoi(buf);
+ if(year < 1970 || year > 2100)//for kw
+ {
+ return -1;
+ }
+
+ memset(&buf, 0, sizeof(buf));
+ cfg_get_item("manual_time_month", buf, sizeof(buf));
+ month = atoi(buf);
+ if(month<1 || month>12)
+ {
+ month = 1;
+ }
+
+ memset(&buf, 0, sizeof(buf));
+ cfg_get_item("manual_time_day", buf, sizeof(buf));
+ day = atoi(buf);
+ if(day<1 || day>31)
+ {
+ day = 1;
+ }
+
+ memset(&buf, 0, sizeof(buf));
+ cfg_get_item("manual_time_hour", buf, sizeof(buf));
+ hour = atoi(buf);
+ if(hour<0 || hour>24)
+ {
+ hour = 0;
+ }
+
+ memset(&buf, 0, sizeof(buf));
+ cfg_get_item("manual_time_minute", buf, sizeof(buf));
+ minute = atoi(buf);
+ if(minute<0 || minute>60)
+ {
+ minute = 0;
+ }
+
+ memset(&buf, 0, sizeof(buf));
+ cfg_get_item("manual_time_second", buf, sizeof(buf));
+ second = atoi(buf);
+ if(second<0 || second>60)
+ {
+ second = 0;
+ }
+
+ YearTotal = year - 1970;
+ for (count = 0; count < YearTotal; count++) {
+ i = 1971 + count;
+ if (i % 4 == 0 && i % 100 != 0) {
+ if (YearTotal == count + 1) {
+ CommonYear++;
+ } else {
+ LeapYear++;
+ }
+ continue;
+ } else if (i % 400 == 0) {
+ if (YearTotal == count + 1) {
+ CommonYear++;
+ } else {
+ LeapYear++;
+ }
+ continue;
+ } else {
+ CommonYear++;
+ }
+ }
+
+ /****************flag==1±íʾµ±ÄêΪÈòÄê*************************/
+ if (year % 4 == 0 && year % 100 != 0) {
+ flag = 1;
+ } else if (year % 400 == 0) {
+ flag = 1;
+ } else {
+ flag = 0;
+ }
+
+ switch (month - 1) {
+ case 0:
+ days = day;
+ break;
+ case 1:
+ days = 31 + day;
+ break;
+ case 2:
+ days = 31 + 28 + day;
+ break;
+ case 3:
+ days = 31 + 28 + 31 + day;
+ break;
+ case 4:
+ days = 31 + 28 + 31 + 30 + day;
+ break;
+ case 5:
+ days = 31 + 28 + 31 + 30 + 31 + day;
+ break;
+ case 6:
+ days = 31 + 28 + 31 + 30 + 31 + 30 + day;
+ break;
+ case 7:
+ days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;
+ break;
+ case 8:
+ days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;
+ break;
+ case 9:
+ days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
+ break;
+ case 10:
+ days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
+ break;
+ case 11:
+ days = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
+ break;
+ }
+ if ((month - 1) >= 2 && 1 == flag) {
+ days++;
+ }
+
+
+ nowtime = COMMONYEARSEC * CommonYear + LEAPYEARSEC * LeapYear + (days - 1) * DAYSEC + hour * 3600 + minute * 60 + second;
+ tp.tv_usec = 0;
+ tp.tv_sec = nowtime;
+
+ time(&SynBeforeTime);
+ slog(MISC_PRINT, SLOG_DEBUG, "Now time is %d", SynBeforeTime); /*lint !e26*/
+
+ cfg_get_item("syn_after_time", SynSecond, sizeof(SynSecond));
+ sscanf(SynSecond, "%d", <ime);
+ if(ltime < 0 || ltime > INT_MAX-1) // kw 3
+ {
+ ltime = 0;
+ }
+
+ cfg_get_item("syn_system_total", SynSystemTotal, sizeof(SynSystemTotal));
+
+ sscanf(SynSystemTotal, "%d", &mtime);
+ if(mtime < 0 || mtime > INT_MAX-1) // kw 3
+ {
+ mtime = 0;
+ }
+
+ if (0 != mtime) {
+ mtime += (SynBeforeTime - ltime);
+ } else {
+ mtime = (SynBeforeTime - JAN_2000);
+ }
+ sprintf(SynSystemTotal, "%d", mtime);
+ cfg_set("syn_system_total", SynSystemTotal);
+
+ cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+ if ((0 == strcmp(ppp_status, "ppp_connected")) || (0 == strcmp(ppp_status, "ipv6_connected")) || (0 == strcmp(ppp_status, "ipv4_ipv6_connected"))) {
+ cfg_get_item("syn_ppp_total", SynPppTotal, sizeof(SynPppTotal));
+
+ sscanf(SynPppTotal, "%d", &mtime);
+ if(mtime < 0 || mtime > INT_MAX-1) // kw 3
+ {
+ mtime = 0;
+ }
+ if (0 != mtime) {
+ mtime += (SynBeforeTime - ltime);
+ } else {
+ memset(&SynSecond, 0, sizeof(SynSecond));
+ cfg_get_item("ppp_start_time", SynSecond, sizeof(SynSecond));
+
+ sscanf(SynSecond, "%d", &ntime);
+ if(ntime < 0 || ntime > INT_MAX-1) // kw 3
+ {
+ ntime = 0;
+ }
+
+ mtime = SynBeforeTime - ntime;
+ }
+ sprintf(SynPppTotal, "%d", mtime);
+ cfg_set("syn_ppp_total", SynPppTotal);
+ cfg_set("syn_order_flag", "ppp_on");
+ } else {
+ cfg_set("syn_order_flag", "ppp_off");
+ cfg_set("syn_ppp_total", "0");
+ }
+
+ timeToSet.tm_year = year-1900;
+ timeToSet.tm_mon = month-1;
+ timeToSet.tm_mday = day;
+ timeToSet.tm_hour = hour;
+ timeToSet.tm_min = minute;
+ timeToSet.tm_sec = second;
+ dataLen = sizeof(struct tm);
+ slog(MISC_PRINT, SLOG_DEBUG, "SetTime:year:%d, mon:%d, day:%d, hour:%d, min:%d, sec:%d \n",
+ timeToSet.tm_year, timeToSet.tm_mon, timeToSet.tm_mday,
+ timeToSet.tm_hour, timeToSet.tm_min, timeToSet.tm_sec );
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SNTP, MSG_CMD_SNTP_SET_TIME,
+ dataLen, &timeToSet, 0);
+ if (0 != ret) {
+ slog(MISC_PRINT, SLOG_ERR, "send MSG_CMD_SNTP_SET_TIME to sntp fail!");
+ }
+
+ ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_SYCTIME_SET_REQ, 0, NULL, 0);
+ if (0 != ret) {
+ slog(MISC_PRINT, SLOG_ERR, "sync time to cp fail!");
+ }
+
+ memset(&buf, 0, sizeof(buf));
+ cfg_get_item("outdate_delete", buf, sizeof(buf));
+ if (0 == strcmp(buf, "1")) {
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SMS, MSG_CMD_SMS_OUTDATE_CHECK, 0, NULL, 0);
+ }
+
+ sprintf(SynSecond, "%d", (int)(time((time_t *)NULL)));
+ cfg_set("syn_after_time", SynSecond);
+ //cfg_set("systime_mode", "manual");
+ cfg_set("need_clear_traffic_data", "yes");
+ zte_mgmt_set_login_timemark();
+ return 0;
+}
+char * timei2s(int itime)
+{
+ static char buf[64];
+ int hours, min, sec;
+ memset(buf, 0, 64);
+
+ hours = itime / 3600;
+ min = (itime / 60) % 60;
+ sec = itime % 60;
+
+ sprintf(buf, "%d:%02d:%02d", hours, min, sec);
+ return buf ;
+}
+void timeen2ch(char *time)
+{
+ char timetmp[128] = {0};
+ char year[5] = {0};
+ char month[4] = {0};
+ char day[3] = {0};
+ char weekday[4] = {0};
+ char nowtime[16] = {0};
+ char hour[4] = {0};
+ char second[4] = {0};
+ char minute[4] = {0};
+ //int imonth;
+ char imonth[4] = {0};
+ strncpy(timetmp, time,sizeof(timetmp)-1);
+ char *loc = timetmp;
+ char *tmp = NULL;
+ memset(time, 0, 128);
+ char str_buf[10] = {0};
+ int temp;
+ int month_temp;
+
+ while (*loc == ' ') {
+ loc++;
+ }
+ tmp = strtok(loc, " ");
+ if(tmp == NULL) return;
+ strncpy(weekday, tmp, sizeof(weekday)-1);
+ tmp = strtok(NULL, " ");
+ if(tmp == NULL) return;
+ strncpy(month, tmp, sizeof(month)-1);
+ tmp = strtok(NULL, " ");
+ if(tmp == NULL) return;
+ strncpy(day, tmp, sizeof(day)-1);
+ slog(MISC_PRINT, SLOG_DEBUG, "strlen(tmp)=%d", strlen(tmp)); /*lint !e26*/
+ if (strlen(tmp) == 1) {
+ temp = atoi(tmp);
+ slog(MISC_PRINT, SLOG_DEBUG, "====temp=%d", temp); /*lint !e26*/
+ if(temp < 10 && temp > 0)
+ snprintf(day,sizeof(day), "0%d", temp);
+ slog(MISC_PRINT, SLOG_DEBUG, "====day=%s", day); /*lint !e26*/
+ } else {
+ strncpy(day, tmp,sizeof(day)-1);
+ }
+ tmp = strtok(NULL, " ");
+ if(tmp == NULL) return;
+ strncpy(nowtime, tmp, sizeof(nowtime)-1);
+ tmp = strtok(NULL, " ");
+ if(tmp == NULL) return;
+ strncpy(year, tmp, sizeof(year)-1);
+ if (0 == strcmp("Jan", month)) {
+ strncpy(imonth, "01", sizeof(imonth)-1);
+ } else if (0 == strcmp("Feb", month)) {
+ strncpy(imonth, "02", sizeof(imonth)-1);
+ } else if (0 == strcmp("Mar", month)) {
+ strncpy(imonth, "03", sizeof(imonth)-1);
+ } else if (0 == strcmp("Apr", month)) {
+ strncpy(imonth, "04", sizeof(imonth)-1);
+ } else if (0 == strcmp("May", month)) {
+ strncpy(imonth, "05", sizeof(imonth)-1);
+ } else if (0 == strcmp("Jun", month)) {
+ strncpy(imonth, "06", sizeof(imonth)-1);
+ } else if (0 == strcmp("Jul", month)) {
+ strncpy(imonth, "07", sizeof(imonth)-1);
+ } else if (0 == strcmp("Aug", month)) {
+ strncpy(imonth, "08", sizeof(imonth)-1);
+ } else if (0 == strcmp("Sep", month)) {
+ strncpy(imonth, "09", sizeof(imonth)-1);
+ } else if (0 == strcmp("Oct", month)) {
+ strncpy(imonth, "10", sizeof(imonth)-1);
+ } else if (0 == strcmp("Nov", month)) {
+ strncpy(imonth, "11", sizeof(imonth)-1);
+ } else if (0 == strcmp("Dec", month)) {
+ strncpy(imonth, "12", sizeof(imonth)-1);
+ }
+ sprintf(time, "%s-%s-%s %s", year, imonth, day, nowtime);
+ slog(MISC_PRINT, SLOG_DEBUG, "====nowtime=%s", nowtime); /*lint !e26*/
+
+
+ tmp = strtok(nowtime, ":");
+ if(tmp == NULL) return;
+ strncpy(hour, tmp,sizeof(hour)-1);
+ slog(MISC_PRINT, SLOG_DEBUG, "====hour=%s", hour); /*lint !e26*/
+ tmp = strtok(NULL, ":");
+ if(tmp == NULL) return;
+ strncpy(minute, tmp,sizeof(minute)-1);
+ slog(MISC_PRINT, SLOG_DEBUG, "====minute=%s", minute); /*lint !e26*/
+ tmp = strtok(NULL, ":");
+ if(tmp == NULL) return;
+ strncpy(second, tmp,sizeof(second)-1);
+ slog(MISC_PRINT, SLOG_DEBUG, "====second=%s", second); /*lint !e26*/
+ cfg_set("sntp_hour", hour);
+ cfg_set("sntp_minute", minute);
+ cfg_set("sntp_second", second);
+
+ cfg_set("sntp_year", year);
+ cfg_set("sntp_month", imonth);
+ cfg_set("sntp_day", day);
+}
+void datastatic(char *rec, char *send, char *onlinetime, char *runtime, char *localtime)
+{
+ char Receive_Amount[20] = {0};
+ char Transmit_Amount[20] = {0};
+ char syn_system_total[20] = {0};
+ char syn_after_time[20] = {0};
+ char syn_ppp_total[20] = {0};
+ char ppp_start_time[20] = {0};
+ char timestr[128] = {0};
+ int mtime;
+ int ltime;
+ int ntime;
+ int otime;
+ time_t timenow;
+ char ppp_status[NV_ITEM_STRING_LEN_50] = {0};
+ char buf[NV_ITEM_STRING_LEN_20] = {0};
+
+ cfg_get_item("syn_system_total", syn_system_total, sizeof(syn_system_total));
+
+ sscanf(syn_system_total, "%d", <ime);
+ if(ltime < 0 || ltime > INT_MAX-1) // kw 3
+ {
+ ltime = 0;
+ }
+ cfg_get_item("syn_after_time", syn_after_time, sizeof(syn_after_time));
+
+ sscanf(syn_after_time, "%d", &ntime);
+ if(ntime < 0 || ntime > INT_MAX-1) // kw 3
+ {
+ ntime = 0;
+ }
+ cfg_get_item("ppp_start_time", ppp_start_time, sizeof(ppp_start_time));
+
+ sscanf(ppp_start_time, "%d", &otime);
+ if(otime < 0 || otime > INT_MAX-1) // kw 3
+ {
+ otime = 0;
+ }
+
+ cfg_get_item("ppp_status", ppp_status, sizeof(ppp_status));
+ if ((0 != strcmp(ppp_status, "ppp_connected")) && (0 != strcmp(ppp_status, "ipv6_connected")) && (0 != strcmp(ppp_status, "ipv4_ipv6_connected"))) {
+ cfg_set("syn_ppp_total", "0");
+ }
+
+ cfg_get_item("syn_ppp_total", syn_ppp_total, sizeof(syn_ppp_total));
+
+ sscanf(syn_ppp_total, "%d", &mtime);
+ if(mtime < 0 || mtime > INT_MAX-1) // kw 3
+ {
+ mtime = 0;
+ }
+
+ time(&timenow);
+ if (ntime == 0) {
+ strncpy(onlinetime, timei2s(timenow - otime), 63);
+ strncpy(runtime, timei2s(timenow - JAN_2000), 63);
+ } else {
+ cfg_get_item("syn_order_flag", buf, sizeof(buf));
+ if (0 == strcmp(buf, "ppp_on")) {
+ strncpy(onlinetime, timei2s(timenow - ntime + mtime), 63);
+ } else {
+ strncpy(onlinetime, timei2s(timenow - otime), 63);
+ }
+ strncpy(runtime, timei2s(timenow - ntime + ltime), 63);
+ }
+ slog(MISC_PRINT, SLOG_DEBUG, "----runtime=%s", runtime); /*lint !e26*/
+ strncpy(timestr, ctime(&timenow),sizeof(timestr)-1);
+ slog(MISC_PRINT, SLOG_DEBUG, "----timestr=%s", timestr); /*lint !e26*/
+ timeen2ch(timestr);
+ strncpy(localtime, timestr,sizeof(localtime)-1);
+ slog(MISC_PRINT, SLOG_DEBUG, "----localtime=%s", localtime); /*lint !e26*/
+
+}
+
+void zte_goform_sntp_getdatastatic_process(webs_t wp)
+{
+ char receive[30], send[30], onlinetime[64], runtime[64], localtime[128];
+
+ memset(receive, 0, 30);
+ memset(send, 0, 30);
+ memset(onlinetime, 0, 64);
+ memset(runtime, 0, 64);
+ memset(localtime, 0, 128);
+
+ datastatic(receive, send, onlinetime, runtime, localtime);
+
+ websWrite(wp, T("{\"receive\":\"%s\",\"send\":\"%s\",\"onlinetime\":\"%s\",\"runtime\":\"%s\",\"localtime\":\"%s\"}"), receive, send, onlinetime, runtime, localtime);
+}
+
+
+typedef struct LOG_FILES {
+ char filename[64];
+} LOG_FILES;
+
+int start_diaglog()
+{
+ int ret = 0;
+ slog(MISC_PRINT, SLOG_NORMAL, "start_diaglog"); /*lint !e26*/
+ system("/sbin/diaglog &");
+ return ret;
+}
+
+int stop_diaglog()
+{
+ int ret = 0;
+ slog(MISC_PRINT, SLOG_NORMAL, "get killall SIGINT"); /*lint !e26*/
+ system("killall -9 diaglog");//SIGINT=2
+ return ret;
+}
+#if 0
+int del_diaglog(char *fllename)
+{
+ slog(MISC_PRINT, SLOG_NORMAL, "del log name=%s", fllename); /*lint !e26*/
+ int ret = 0;
+ char cmd[128];
+ sprintf(cmd, "rm %s", fllename);
+ system(cmd);
+ return ret;
+}
+#endif
+
+int getDiaglogFile(LOG_FILES *files, int n_files)
+{
+ char ext[] = ".dlf";
+ int i = 0;
+
+ DIR *dp;
+ struct dirent *entry;
+
+ dp = opendir(DIAGLOG_DATA_PATH);
+ if (dp == NULL) {
+ slog(MISC_PRINT, SLOG_ERR, "dp==NULL");
+ return 0;
+ }
+
+ i = 0;
+ while ((entry = readdir(dp)) != NULL && (i < n_files)) {
+ {
+ int len = strlen(entry->d_name);
+ if ((len > strlen(ext)) && !strcmp(entry->d_name + len - strlen(ext), ext)) { //*.dlf *.zm
+ strncpy(files[i].filename, entry->d_name, sizeof(files[i].filename)-1);
+ slog(MISC_PRINT, SLOG_DEBUG, "entry->d_name=%s", entry->d_name);
+ i++;
+ }
+ }
+ }
+ closedir(dp);
+
+ return i;
+
+}
+
+
+void getdialog_url(int eid, webs_t wp, int argc, char_t **argv)
+{
+ char filename[128] = {0};
+ LOG_FILES files[10];
+ int n, i;
+ char *p = filename;
+ n = getDiaglogFile(files, 10);
+ i = 0;
+ if (n > 0) {
+ while (i < n) {
+ slog(MISC_PRINT, SLOG_DEBUG, "i=%d", i); /*lint !e26*/
+ strcpy(p, files[i].filename);
+ p += strlen(files[i].filename);
+ *p = ';';
+ p++;
+ slog(MISC_PRINT, SLOG_DEBUG, "filename=%s", files[i].filename); /*lint !e26*/
+ i++;
+ }
+ websWrite(wp, T(filename));
+ } else {
+ websWrite(wp, T(""));
+ }
+}
+
+/******************************************************
+* Function: zte_fota_get_upgrade_result
+* Description: get fota upgrade result
+* Input: http request info
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2013/03/14 V1.0 chenyi create
+*******************************************************/
+void zte_fota_get_upgrade_result(webs_t wp)
+{
+ zte_topsw_state_e_type nv_result = ZTE_NVIO_MAX;
+
+ char nv_upgrade_result[NV_ITEM_STRING_LEN_50] = {0};
+
+ nv_result = zte_web_read(NV_FOTA_UPGRADE_RESULT, nv_upgrade_result);
+ if (ZTE_NVIO_DONE != nv_result) {
+ slog(MISC_PRINT, SLOG_ERR,"read nv [%s] fail.\n", NV_FOTA_UPGRADE_RESULT);
+ }
+
+ web_feedback_header(wp);
+ (void)websWrite(wp, T("{\"%s\":\"%s\"}"), FOTA_UPGRADE_RESULT, nv_upgrade_result);
+
+ if ((0 == strcmp("success", nv_upgrade_result)) || (0 == strcmp("fail", nv_upgrade_result))) {
+ (void)zte_web_write(NV_FOTA_UPGRADE_RESULT, ""); //reset
+
+ // ÖØÖÃNVºó±£´æ¸ÃNV²ÎÊý£¬±ÜÃâÒò¿ìËÙÖØÆô£¬NVÐÂֵδ±£´æµ¼Öµĸüнá¹ûÖØ¸´Éϱ¨ÎÊÌâ
+ //cfg_save();
+ slog(MISC_PRINT, SLOG_ERR,"reset nv [%s]. nv_upgrade_result:%s\n", NV_FOTA_UPGRADE_RESULT, nv_upgrade_result);
+ }
+}
+
+#if 0
+/******************************************************
+* Function: zte_fota_get_dp_pack_info
+* Description: get fota dp info
+* Input: http request info
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2013/01/06 V1.0 chenyi create
+*******************************************************/
+void zte_fota_get_dp_pack_info(webs_t wp)
+{
+ char dp_total_size[NV_ITEM_STRING_LEN_50] = {0};
+ char dp_download_size[NV_ITEM_STRING_LEN_50] = {0};
+
+ //get dp pack info
+ (void)zte_web_read(NV_FOTA_PKG_TOTAL_SIZE, dp_total_size);
+ (void)zte_web_read(NV_FOTA_PKG_DL_SIZE, dp_download_size);
+
+ web_feedback_header(wp);
+ (void)websWrite(wp, T("{\"%s\":\"%s\",\"%s\":\"%s\"}"), \
+ NV_FOTA_PKG_TOTAL_SIZE, dp_total_size, NV_FOTA_PKG_DL_SIZE, dp_download_size);
+}
+#endif
+/**********************************************************************
+* Function: zte_fota_update
+* Description: send msg to fota update module
+* Input: wp:the web para;
+* Output:
+* Return:
+* Others: add from uFi
+* Modify Date Version Author Modification
+* -----------------------------------------------
+*
+**********************************************************************/
+int zte_fota_SendMsg2DM(int cmd)
+{
+ slog(MISC_PRINT, SLOG_NORMAL,"goahead send cmd=%d to fota\n", cmd);
+ return ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_DM_WEBUI_AT, cmd, 0, NULL, 0);
+}
+
+void zte_fota_update(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User check new version!\n"));
+ char *update_action = NULL;
+ zte_topsw_state_e_type nv_result = ZTE_NVIO_MAX;
+ char new_version_state[NV_ITEM_STRING_LEN_150] = {0};
+ BOOL new_state_version_check = FALSE;
+ int iDlPara = -1;
+
+ if (NULL == wp) {
+ return;
+ }
+
+ update_action = websGetVar(wp, T("select_op"), T(""));
+ slog(MISC_PRINT, SLOG_DEBUG,"websGetVar FOTA upgrade action[%s].\n", update_action);
+
+ if ('\0' == *update_action) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+
+ //ÓëdeviceUiµÄ»¥³â±£»¤´¦Àí
+ zte_web_read(NV_FOTA_NEW_VERSION_STATE, new_version_state);
+
+ if ((0 == strcmp(update_action, FOTA_ACTION_CONFIRM_DOWNLOAD)) || (0 == strcmp(update_action, FOTA_ACTION_CANCEL_DOWNLOAD))) {
+ if ((0 == strcmp(new_version_state, HAS_OPTIONAL)) || (0 == strcmp(new_version_state, HAS_CRITICAL))) {
+ new_state_version_check = TRUE;
+ }
+ if (!new_state_version_check) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ }
+
+ if (0 == strcmp(update_action, FOTA_ACTION_CONFIRM_DOWNLOAD)) {
+ zte_web_write(NV_FOTA_UPGRADE_SELECTOR, "accept");
+ //zte_web_write(NV_FOTA_NEED_USER_CONFIRM,"0");
+ slog(MISC_PRINT, SLOG_DEBUG,"web :zte_fota_update. update_action = FOTA_ACTION_CONFIRM_DOWNLOAD, set NV_FOTA_UPGRADE_SELECTOR accept!\n");
+ //zte_fota_SendMsg2DM(MSG_CMD_FOTA_WEBUI_START_DOWNLOAD);
+ //ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_DM_WEBUI_AT,MSG_CMD_FOTA_WEBUI_START_DOWNLOAD, 2, "1", 0);
+ iDlPara = 1;
+ ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_DM_WEBUI_AT, MSG_CMD_FOTADL_REQ, sizeof(iDlPara), (UCHAR *)(&iDlPara), 0);
+ } else if (0 == strcmp(update_action, FOTA_ACTION_CANCEL_DOWNLOAD)) {
+ (void)zte_web_write(NV_FOTA_UPGRADE_SELECTOR, "cancel");
+ zte_web_write(NV_FOTA_NEW_VERSION_STATE, IDLE);
+ zte_web_write(NV_FOTA_CURR_UPGRADE_STATE, IDLE);
+
+ slog(MISC_PRINT, SLOG_DEBUG,"web :zte_fota_update. update_action = FOTA_ACTION_CANCEL_DOWNLOAD, set NV_FOTA_UPGRADE_SELECTOR cancel!\n");
+ zte_write_result_to_web(wp, SUCCESS);
+ return; //no need to send msg to ota module
+ } else if (0 == strcmp(update_action, "check")) {
+ slog(MISC_PRINT, SLOG_DEBUG,"goahead :zte_fota_update. begin to check!!\n");
+ zte_fota_SendMsg2DM(MSG_CMD_FOTA_WEBUI_START_FOTA);
+ }
+
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+/**********************************************************************
+* Function: zte_fota_settings
+* Description: to set fota settings
+* Input: wp:the web para;dm_nextpollingtime;dm_pollingcycle;pollingswitch;
+* Output:
+* Return:
+* Others: add from uFi
+* Modify Date Version Author Modification
+* -----------------------------------------------
+*
+**********************************************************************/
+void zte_fota_settings(webs_t wp)
+{
+ char_t *updateMode = NULL;
+ char_t *allowRoamingUpdate = NULL;
+ zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+
+ if (NULL == wp) {
+ return;
+ }
+
+ updateMode = websGetVar(wp, T("UpgMode"), T(""));
+ allowRoamingUpdate = websGetVar(wp, T("UpgRoamPermission"), T(""));
+
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_fota_settings web para:[updateMode] is [%s].\n", updateMode);
+ slog(MISC_PRINT, SLOG_DEBUG,"zte_fota_settings web para:[allowRoamingUpdate] is [%s].\n", allowRoamingUpdate);
+
+ if ('\0' == (*updateMode)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ status = zte_web_write("fota_allowRoamingUpdate", allowRoamingUpdate);
+ if (ZTE_NVIO_DONE != status) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+
+ status = zte_web_write("fota_updateMode", updateMode);
+ if (ZTE_NVIO_DONE != status) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ zte_fota_SendMsg2DM(MSG_CMD_FOTA_WEBUI_CHANGE_PARAMETER);
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+#if 0
+
+/**********************************************************************
+* Function: zte_get_fota_settings
+* Description: to get fota settings
+* Input: wp:the web para;
+* Output:
+* Return:
+* Others: add from uFi
+* Modify Date Version Author Modification
+* -----------------------------------------------
+*
+**********************************************************************/
+void zte_get_fota_settings(webs_t wp)
+{
+ zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+
+ char_t updateMode[NV_ITEM_STRING_LEN_20] = {0};
+ char_t updateIntervalDay[NV_ITEM_STRING_LEN_20] = {0};
+ char_t allowRoamingUpdate[NV_ITEM_STRING_LEN_20] = {0};
+
+ status = zte_web_read("fota_allowRoamingUpdate", allowRoamingUpdate);
+ if (ZTE_NVIO_DONE != status) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ status = zte_web_read("fota_updateIntervalDay", updateIntervalDay);
+ if (ZTE_NVIO_DONE != status) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ status = zte_web_read("fota_updateMode", updateMode);
+ if (ZTE_NVIO_DONE != status) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ WEBLOG("zte_get_fota_settings:[updateMode] is [%s].\n", updateMode);
+ WEBLOG("zte_get_fota_settings:[updateIntervalDay] is [%s].\n", updateIntervalDay);
+ WEBLOG("zte_get_fota_settings:[allowRoamingUpdate] is [%s].\n", allowRoamingUpdate);
+
+ web_feedback_header(wp);
+ zte_rest_cmd_write_head(wp);
+
+ if ('\0' != *updateMode)
+ zte_rest_cmd_write(wp, "UpgMode", updateMode, 1);
+ else
+ zte_rest_cmd_write(wp, "UpgMode", "0", 1);
+
+ if ('\0' != *updateIntervalDay)
+ zte_rest_cmd_write(wp, "UpgIntervalDay", updateIntervalDay, 1);
+ else
+ zte_rest_cmd_write(wp, "UpgIntervalDay", "1", 1);
+
+ if ('\0' != *allowRoamingUpdate)
+ zte_rest_cmd_write(wp, "UpgRoamPermission", allowRoamingUpdate, 0);
+ else
+ zte_rest_cmd_write(wp, "UpgRoamPermission", "0", 0);
+
+ zte_rest_cmd_write_foot(wp);
+}
+
+
+/******************************************************
+* Function: zte_fota_get_update_info
+* Description: get fota update info
+* Input: http request info
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2013/01/06 V1.0 chenyi create
+*******************************************************/
+void zte_fota_get_update_info(webs_t wp)
+{
+ char version[NV_ITEM_STRING_LEN_64 + 1] = {0};
+
+ (void)zte_web_read(NV_FOTA_VERSION, version);
+
+ web_feedback_header(wp);
+ (void)websWrite(wp, T("{\"%s\":\"%s\"}"), FOTA_UPDATE_VERSION, version);
+}
+#endif
+
+void zte_wan_lock_frequency_process(webs_t wp)
+{
+ slog(MISC_PRINT, SLOG_NORMAL, "zte_wan_lock_frequency_process coming");
+ CHAR *actionlte = NULL;
+ CHAR *uarfcnlte = NULL;
+ CHAR *cellParaIdlte = NULL;
+
+ /* get value from web page */
+ actionlte = websGetVar(wp, T("actionlte"), T(""));
+ uarfcnlte = websGetVar(wp, T("uarfcnlte"), T(""));
+ cellParaIdlte = websGetVar(wp, T("cellParaIdlte"), T(""));
+
+ cfg_set("actionlte", actionlte);
+ cfg_set("uarfcnlte", uarfcnlte);
+ cfg_set("cellParaIdlte", cellParaIdlte);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_CELL_LOCK_REQ, 0, NULL, 0);
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+void zte_setLastLoginTime()
+{
+ int curr_time = 0;
+ char login_time[LOGIN_RECORD_TIME] = {0};
+ curr_time = zte_web_getCurrentTime();
+ sprintf(login_time, "%d", curr_time);
+ (void)zte_web_write(NV_LAST_LOGIN_TIME, login_time);
+}
+
+int zte_checkLoginTime()
+{
+ char last_record_time[LOGIN_RECORD_TIME] = {0};
+ int last_record_time_num = 0;
+ int curr_record_time_num = 0;
+ int lock_time = 0;
+ zte_web_read(NV_LAST_LOGIN_TIME, last_record_time);
+ last_record_time_num = atoi(last_record_time);
+ if(last_record_time_num < 0 || last_record_time_num > INT_MAX-1) // kw 3
+ {
+ last_record_time_num = 0;
+ }
+
+ curr_record_time_num = zte_web_getCurrentTime();
+ lock_time = curr_record_time_num - last_record_time_num;
+ if (lock_time < LOGIN_FAIL_LOCK_TIME) {
+ return -1;
+ } else {
+ return 1;
+ }
+}
+
+void zte_reduct_login_times()
+{
+ char psw_fail_num_str[12] = {0};
+ int login_times = 0;
+ zte_web_read("psw_fail_num_str", psw_fail_num_str);
+ login_times = atoi(psw_fail_num_str);
+ if(login_times < 0 || login_times > INT_MAX-1) // kw 3
+ {
+ login_times = 0;
+ }
+
+ login_times--;
+ sprintf(psw_fail_num_str, "%d", login_times);
+ (void)zte_web_write("psw_fail_num_str", psw_fail_num_str);
+}
+/******************************************************
+* Function: void zte_password_check(webs_t wp)
+* Description: password check when login
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+*
+*******************************************************/
+psw_check_result_type_t zte_password_check(webs_t wp, char* psw)
+{
+ int psw_len = 0;
+ int psw_fail_num = 0;
+ char psw_fail_num_str[10] = {0};
+ int check_lock = 0;
+
+ if (NULL == psw) {
+ slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login: psw is empty.");
+ return PSW_EMPTY;
+ }
+
+ slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login:psw:%s", psw);
+ //don't foget add the nv psw_fail_num_str
+ zte_web_read("psw_fail_num_str", psw_fail_num_str);
+ psw_fail_num = atoi(psw_fail_num_str);
+ psw_len = strlen(psw);
+
+ if (0 == psw_len) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_login: psw is empty.");
+ return PSW_EMPTY;
+ }
+
+ if (psw_fail_num <= 0) {
+ check_lock = zte_checkLoginTime(); // check the current time if it is time out
+ if (check_lock < 0) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_login: psw number use out.");
+ return PSW_TIME_OUT;
+// } else if (check_lock > 0) { // kw 3
+ }else{
+ slog(MISC_PRINT, SLOG_DEBUG, "zte_mgmt_login: login time out, can login.");
+ (void)zte_web_write("psw_fail_num_str", LOGIN_FAIL_TIMES);
+ }
+ }
+ zte_setLastLoginTime(); //record current time to nv
+ if (LOGIN_PSW_MIN_LEN > psw_len || LOGIN_PSW_MAX_LEN < psw_len) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_mgmt_login: psw is too long.");
+ return PSW_TOO_LONG;
+ } else {
+ return PSW_OK;
+ }
+}
+
+void zte_get_ddns_status(webs_t wp)
+{
+ char * line = NULL;
+ size_t len = 0;
+ int lsize = 0; //klocwork
+ char path_conf[100] = {0};
+ char path_file[500] = {0};
+ cfg_get_item("path_conf", path_conf, sizeof(path_conf));
+ sprintf(path_file, "%s/inadyn.status", path_conf);
+ FILE *proc_file = fopen(path_file, "r");
+
+ if (proc_file == NULL) {
+ //websWrite(wp, T("4"));
+ websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "4");
+ return;
+ }
+ if ((lsize = getline(&line, &len, proc_file)) != -1 && line) {
+ if (strstr(line, "RC_IP_INVALID_REMOTE_ADDR")) {
+ //websWrite(wp, T("2"));
+ websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "2");
+ } else if (strstr(line, "RC_DYNDNS_RSP_NOTOK")) {
+ //websWrite(wp, T("1"));
+ websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "1");
+ } else if (strstr(line, "RC_OK")) {
+ //websWrite(wp, T("0"));
+ websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "0");
+ } else if (strstr(line, "RC_REGISTERING")) {
+ //websWrite(wp, T("3"));
+ websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "3");
+ } else {
+ //websWrite(wp, T("5"));
+ websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "5");
+ }
+ } else {
+ //websWrite(wp, T("-1"));
+ websWrite(wp, T("{\"%s\":\"%s\"}"), "getddns_status", "-1");
+ }
+ if (line) {
+ free(line);
+ }
+ fclose(proc_file);
+ return;
+
+}
+
+void zte_goform_set_work_type(webs_t wp)
+{
+ char_t *work_type = NULL;
+ work_type = websGetVar(wp, T("work_type"), T(""));
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[zyl]zte_goform_set_work_type:work_type->%s\n", work_type);
+
+ if (work_type == NULL) {
+ slog(MISC_PRINT, SLOG_ERR,"[zyl]zte_goform_set_work_type:empty!\n");
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+ if ((strncmp(work_type, "0", 1) == 0) || (strncmp(work_type, "1", 1) == 0)) {
+ char LanEnable[5] = {0};
+ (void)zte_web_read("LanEnable", LanEnable);
+ if (strncmp(LanEnable, work_type, 1) == 0) {
+ return zte_write_result_to_web(wp, SUCCESS);
+ }
+ (void)zte_web_write("LanEnable", work_type);
+ slog(MISC_PRINT, SLOG_DEBUG,"[zyl]zte_goform_set_work_type:work_type->%s\n", work_type);
+ ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL, 0);
+ slog(MISC_PRINT, SLOG_NORMAL,"[zyl]zte_goform_set_work_type:device reboot now\n");
+ zte_write_result_to_web(wp, SUCCESS);
+ return;
+ } else {
+ slog(MISC_PRINT, SLOG_ERR,"[zyl]zte_goform_set_work_type:work_type->%s error!\n", work_type);
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+}
+
+/******************************************************
+* Function: void zte_goform_set_sample(webs_t wp)
+* Description: example function
+* Input: HTTP page info
+* Output:
+* Return: none
+* Others:
+* Modify Date Version Author Modification
+*
+*******************************************************/
+void zte_goform_set_sample(webs_t wp)
+{
+ //´ÓWEBÇëÇóÖлñÈ¡²ÎÊý,ûÓвÎÊýÔò²»ÐèÒªÕâÒ»²½
+
+ // ÉèÖÃNV»ò·¢ÏûÏ¢¸øÏàӦģ¿é
+ //ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_AT_CTL, MSG_CMD_PDP_ACT_REQ, 0, NULL, 0);
+
+ //·µ»ØJSON ¸ñʽ½á¹û£¬Èç¹ûÐèÒª²éѯÉèÖýá¹ûÔòÐèÒªwebuiͨ¹ý»ñÈ¡ppp_statusÕâ¸öNVÖµÀ´»ñÈ¡
+ zte_write_result_to_web(wp, SUCCESS);
+ return;
+}
+
+//bsim
+static int bs_string2bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i = 0; i < nSrcLength; i += 2)
+ {
+ // Êä³ö¸ß4λ
+ if(*pSrc >= '0' && *pSrc <= '9')
+ {
+ *pDst = (*pSrc - '0') << 4;
+ }
+ else
+ {
+ *pDst = ((toupper(*pSrc) - 'A') + 10) << 4;
+ }
+
+ pSrc++;
+
+ // Êä³öµÍ4λ
+ if(*pSrc >= '0' && *pSrc <= '9')
+ {
+ *pDst |= *pSrc - '0';
+ }
+ else
+ {
+ *pDst |= (toupper(*pSrc) - 'A') + 10;
+ }
+
+ pSrc++;
+ pDst++;
+ }
+
+ // ·µ»ØÄ¿±êÊý¾Ý³¤¶È
+ return nSrcLength / 2;
+}
+
+static int bs_bytes2string(const unsigned char* pSrc, char* pDst, int nSrcLength)
+{
+ const char tab[]="0123456789ABCDEF"; // 0x0-0xfµÄ×Ö·û²éÕÒ±í
+ int i = 0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i=0; i<nSrcLength; i++)
+ {
+ *pDst++ = tab[*pSrc >> 4]; // Êä³öµÍ4λ
+ *pDst++ = tab[*pSrc & 0x0f]; // Êä³ö¸ß4λ
+ pSrc++;
+ }
+
+ // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+ return nSrcLength * 2;
+}
+
+static int bs_aes_init_key(unsigned char *aes_key, int k_len)
+{
+ int efuse_fd = -1;
+ T_ZDrvEfuse_Secure efuse = {0};
+
+ memset(&efuse, 0, sizeof(efuse));
+ efuse_fd = open("/dev/efuse", O_RDWR);
+ if (efuse_fd < 0) {
+ printf("wifi_aes_init_key efuse open errno=%d\n", errno);
+ return 0;
+ }
+ if(ioctl(efuse_fd , EFUSE_GET_DATA, &efuse) != 0) {
+ printf("wifi_aes_init_key efuse ioctl errno=%d\n", errno);
+ close(efuse_fd);
+ return 0;
+ }
+ close(efuse_fd);
+ memcpy(aes_key, efuse.pubKeyHash, k_len);
+
+ return 1;
+}
+
+static int bs_aes_encrypt(char* in, int len, char* out, unsigned char* key, int key_len)
+{
+ if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+ printf("bs_aes_encrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+ return 0;
+ }
+
+ AES_KEY aes = {0}; //cov h
+ if (AES_set_encrypt_key(key, key_len*8, &aes) < 0) {
+ printf("bs_aes_encrypt AES_set_encrypt_key err\n");
+ return 0;
+ }
+
+ int en_len = 0;
+ while (en_len < len) {
+ AES_encrypt((unsigned char*)in, (unsigned char*)out, &aes);
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ en_len += AES_BLOCK_SIZE;
+ }
+
+ return 1;
+}
+
+static int bs_aes_decrypt(char* in, int len, char* out, char* key, int key_len)
+{
+ if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+ printf("bs_aes_decrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+ return 0;
+ }
+
+ AES_KEY aes = {0}; //cov h
+ if (AES_set_decrypt_key((unsigned char*)key, key_len*8, &aes) < 0) {
+ printf("bs_aes_decrypt AES_set_decrypt_key err\n");
+ return 0;
+ }
+
+ int en_len = 0;
+ while (en_len < len) {
+ AES_decrypt((unsigned char*)in, (unsigned char*)out, &aes);
+ in += AES_BLOCK_SIZE;
+ out += AES_BLOCK_SIZE;
+ en_len += AES_BLOCK_SIZE;
+ }
+
+ return 1;
+}
+
+static int bs_aes_cbc_encrypt(char* in, int len, char* out, unsigned char* key, int key_len)
+{
+ if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+ printf("bs_aes_encrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+ return 0;
+ }
+
+ AES_KEY aes = {0}; //cov h
+ if (AES_set_encrypt_key(key, key_len*8, &aes) < 0) {
+ printf("bs_aes_encrypt AES_set_encrypt_key err\n");
+ return 0;
+ }
+
+ unsigned char iv[AES_BLOCK_SIZE] = {0};
+ memcpy(iv, key, AES_BLOCK_SIZE);
+
+ AES_cbc_encrypt((unsigned char*)in, (unsigned char*)out, len,
+ &aes, iv, AES_ENCRYPT);
+
+
+ return 1;
+}
+
+static int bs_aes_cbc_decrypt(char* in, int len, char* out, char* key, int key_len)
+{
+ if (!in || !out || !key || len <=0 || (len%AES_BLOCK_SIZE)!=0 || (key_len!=16 && key_len!=24 && key_len!=32)) {
+ printf("bs_aes_decrypt err in=%p out=%p key=%p len=%d key_len=%d\n",in,key,out,len,key_len);
+ return 0;
+ }
+
+ AES_KEY aes = {0}; //cov h
+ if (AES_set_decrypt_key((unsigned char*)key, key_len*8, &aes) < 0) {
+ printf("bs_aes_decrypt AES_set_decrypt_key err\n");
+ return 0;
+ }
+
+ unsigned char iv[AES_BLOCK_SIZE] = {0};
+ memcpy(iv, key, AES_BLOCK_SIZE);
+
+ AES_cbc_encrypt((unsigned char*)in, (unsigned char*)out, len,
+ &aes, iv, AES_DECRYPT);
+
+ return 1;
+}
+
+
+static int apn_profile_encrypt_code(char *w_code, int len, char *b_aes, char *s_aes)
+{
+ bs_aes_encrypt(w_code, len, b_aes, web_aes_key, sizeof(web_aes_key));
+ bs_bytes2string(b_aes, s_aes, len);
+
+ printf("encrypt apn_profile w_code=%s, s_aes=%s\n", w_code, s_aes);
+
+ return 1;
+}
+
+void set_apn_prof_aes_by_index(int index, APN_PROFILE *profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+
+ if (NULL == profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "APN_config%d", index);
+ if (0 == strcmp(profile->pdp_type, "IPv6")) {
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "");
+ } else {
+ char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+ char ppp_aes_b[PROFILE_APN_LEN - 1] = {0};
+ apn_profile_encrypt_code(profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ profile->apn_name,
+ profile->apn_select,
+ profile->dial_num,
+ profile->ppp_auth_mode,
+ profile->ppp_username,
+ ppp_aes,//profile->ppp_passwd,
+ profile->pdp_type,
+ profile->pdp_select,
+ profile->pdp_addr,
+ profile->dns_mode,
+ profile->prefer_dns_manual,
+ profile->standby_dns_manual);
+ }
+ cfg_set(cfg_name, cfg_value);
+
+ return;
+}
+
+void set_ipv6_apn_prof_aes_by_index(int index, IPV6_APN_PROFILE *profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+
+ if (NULL == profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "ipv6_APN_config%d", index);
+ if (0 == strcmp(profile->pdp_type, "IP")) {
+ slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=IP cpsnprintf "); /*lint !e26*/
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "");
+ } else {
+ char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+ char ppp_aes_b[PROFILE_APN_LEN - 1] = {0};
+ apn_profile_encrypt_code(profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);
+ slog(MISC_PRINT, SLOG_DEBUG, "pdp_type=else cpsnprintf "); /*lint !e26*/
+ slog(MISC_PRINT, SLOG_DEBUG, "profile->profile_name=%s ", profile->profile_name); /*lint !e26*/
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ profile->apn_name,
+ profile->apn_select,
+ profile->dial_num,
+ profile->ppp_auth_mode,
+ profile->ppp_username,
+ ppp_aes,//profile->ppp_passwd,
+ profile->pdp_type,
+ profile->pdp_select,
+ profile->pdp_addr,
+ profile->dns_mode,
+ profile->prefer_dns_manual,
+ profile->standby_dns_manual);
+ }
+ slog(MISC_PRINT, SLOG_DEBUG, "cfg_value=%s", cfg_value); /*lint !e26*/
+ cfg_set(cfg_name, cfg_value);
+
+ return;
+}
+
+void set_ipv4v6_apn_prof_aes_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+ char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+ char ppp_aes_b[PROFILE_APN_LEN - 1] = {0};
+
+ if (NULL == profile) {
+ return;
+ }
+
+ sprintf(cfg_name, "APN_config%d", index);
+ apn_profile_encrypt_code(profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ profile->profile_name,
+ profile->apn_name,
+ profile->apn_select,
+ profile->dial_num,
+ profile->ppp_auth_mode,
+ profile->ppp_username,
+ ppp_aes,//profile->ppp_passwd,
+ profile->pdp_type,
+ profile->pdp_select,
+ profile->pdp_addr,
+ profile->dns_mode,
+ profile->prefer_dns_manual,
+ profile->standby_dns_manual);
+ cfg_set(cfg_name, cfg_value);
+
+ memset(cfg_name, 0, sizeof(cfg_name));
+ memset(cfg_value, 0, sizeof(cfg_value));
+ memset(ppp_aes, 0, sizeof(ppp_aes));
+ memset(ppp_aes_b, 0, sizeof(ppp_aes_b));
+ sprintf(cfg_name, "ipv6_APN_config%d", index);
+ apn_profile_encrypt_code(ipv6profile->ppp_passwd, PROFILE_APN_LEN - 1 , ppp_aes_b, ppp_aes);
+ snprintf(cfg_value, APNCONFIG_MEMORY,
+ "%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)%s($)",
+ ipv6profile->profile_name,
+ ipv6profile->apn_name,
+ ipv6profile->apn_select,
+ ipv6profile->dial_num,
+ ipv6profile->ppp_auth_mode,
+ ipv6profile->ppp_username,
+ ppp_aes,//ipv6profile->ppp_passwd,
+ ipv6profile->pdp_type,
+ ipv6profile->pdp_select,
+ ipv6profile->pdp_addr,
+ ipv6profile->dns_mode,
+ ipv6profile->prefer_dns_manual,
+ ipv6profile->standby_dns_manual);
+ cfg_set(cfg_name, cfg_value);
+
+ return;
+}
+
+//APN_config0~n
+static void apn_decode_profile_by_index(int index)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+ char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+ char b_aes[PROFILE_APN_LEN] = {0};
+ //char ppp_s[PROFILE_APN_LEN] = {0};
+ char *pos_begin = NULL;
+ APN_PROFILE profile = {0};
+
+ sprintf(cfg_name, "APN_config%d", index);
+ cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+ if (strlen(cfg_value) == 0)
+ return;
+ pos_begin = cfg_value;
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.profile_name, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_name, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.dial_num, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_auth_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_username, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", ppp_aes, PROFILE_APN_AES_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_type, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_addr, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.dns_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.prefer_dns_manual, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.standby_dns_manual, PROFILE_MEMBER_LEN);
+
+ if (strlen(ppp_aes) == (PROFILE_APN_AES_LEN - 1)) {
+ bs_string2bytes(ppp_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+ bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, profile.ppp_passwd, web_aes_key, sizeof(web_aes_key));
+// printf("decrypt ppp_tmp[%d]=%s\n", index, profile.ppp_passwd);
+ } else if (strlen(ppp_aes) > 0){
+ //fotaÉý¼¶À´µÄÃ÷ÎÄ
+ strncpy(profile.ppp_passwd, ppp_aes,sizeof(profile.ppp_passwd)-1);
+ set_apn_prof_aes_by_index(index, &profile);
+// printf("decrypt fota ppp_tmp[%d]=%s\n", index, profile.ppp_passwd);
+ }
+
+ set_apn_profile_by_index(index, &profile);
+
+ return;
+}
+
+static void ipv6apn_decode_profile_by_index(int index)
+{
+ char cfg_name[PROFILE_MEMBER_LEN] = {0};
+ char cfg_value[APNCONFIG_MEMORY] = {0};
+ char ppp_aes[PROFILE_APN_AES_LEN] = {0};
+ char b_aes[PROFILE_APN_LEN] = {0};
+ char *pos_begin = NULL;
+ IPV6_APN_PROFILE profile = {0};
+
+
+ sprintf(cfg_name, "ipv6_APN_config%d", index);
+ cfg_get_item(cfg_name, cfg_value, sizeof(cfg_value));
+ if (strlen(cfg_value) == 0)
+ return;
+ pos_begin = cfg_value;
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.profile_name, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_name, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.apn_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.dial_num, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_auth_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.ppp_username, PROFILE_APN_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", ppp_aes, PROFILE_APN_AES_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_type, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_select, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.pdp_addr, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.dns_mode, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.prefer_dns_manual, PROFILE_MEMBER_LEN);
+ pos_begin = split_str_by_sep(pos_begin, "($)", profile.standby_dns_manual, PROFILE_MEMBER_LEN);
+
+ if (strlen(ppp_aes) == (PROFILE_APN_AES_LEN - 1)) {
+ bs_string2bytes(ppp_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+ bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, profile.ppp_passwd, web_aes_key, sizeof(web_aes_key));
+// printf("decrypt ppp_v6tmp[%d]=%s\n", index, profile.ppp_passwd);
+ } else if (strlen(ppp_aes) > 0){
+ //fotaÉý¼¶À´µÄÃ÷ÎÄ
+ strncpy(profile.ppp_passwd, ppp_aes,sizeof(profile.ppp_passwd)-1);
+ set_ipv6_apn_prof_aes_by_index(index, &profile);
+// printf("decrypt fota ppp_v6tmp[%d]=%s\n", index, profile.ppp_passwd);
+ }
+ set_ipv6_apn_profile_by_index(index, &profile);
+
+ return;
+}
+
+static int apn_profile_decrypt_code(void)
+{
+ int index = 0;//APN_config0ÊÇDefault,¿É²»´¦Àí?
+
+ for (index = 0; index < APNCONFIG_NUM_MAX; index++) {
+ apn_decode_profile_by_index(index);
+ ipv6apn_decode_profile_by_index(index);
+ }
+
+ return 1;
+}
+
+int apn_encrypt_code(void)
+{
+ char w_code[PROFILE_APN_LEN] = {0};
+ char b_aes[PROFILE_APN_LEN] = {0};
+ char s_aes[PROFILE_APN_AES_LEN] = {0};
+
+ cfg_get_item("ppp_passtmp", w_code, sizeof(w_code));
+ bs_aes_encrypt(w_code, PROFILE_APN_LEN - 1, b_aes, web_aes_key, sizeof(web_aes_key));
+ bs_bytes2string(b_aes, s_aes, PROFILE_APN_LEN - 1);
+ cfg_set("ppp_passwd", s_aes);
+ printf("apn_encrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+
+ return 1;
+}
+
+int ipv6apn_encrypt_code(void)
+{
+ char w_code[PROFILE_APN_LEN] = {0};
+ char b_aes[PROFILE_APN_LEN] = {0};
+ char s_aes[PROFILE_APN_AES_LEN] = {0};
+
+ cfg_get_item("ipv6_ppp_passtmp", w_code, sizeof(w_code));
+ bs_aes_encrypt(w_code, PROFILE_APN_LEN - 1, b_aes, web_aes_key, sizeof(web_aes_key));
+ bs_bytes2string(b_aes, s_aes, PROFILE_APN_LEN - 1);
+ cfg_set("ipv6_ppp_passwd", s_aes);
+ printf("ipv6apn_encrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+
+ return 1;
+}
+#if 0
+//2±íʾfota´ÓÀϰ汾ÍùÉÏÉý¼¶£¬ppp_password´æµÄÊÇÃ÷ÎÄÃÜÂ룬а汾ÊÇÃÜÎÄ
+static int apn_decrypt_code(void)
+{
+ char w_code[PROFILE_APN_LEN]= {0};
+ char b_aes[PROFILE_APN_LEN] = {0};
+ char s_aes[PROFILE_APN_AES_LEN] = {0};
+ int flag = 0;
+
+ cfg_get_item("ppp_passwd", s_aes, sizeof(s_aes));
+ if (strlen(s_aes) == (PROFILE_APN_AES_LEN - 1)) {
+ bs_string2bytes(s_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+ bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, w_code, web_aes_key, sizeof(web_aes_key));
+ cfg_set("ppp_passtmp", w_code);
+ printf("apn_decrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+ } else if (strlen(s_aes) > 0){
+ cfg_set("ppp_passtmp", s_aes);
+ return 2;
+ }
+
+ return 1;
+}
+
+static int ipv6apn_decrypt_code(void)
+{
+ char w_code[PROFILE_APN_LEN]= {0};
+ char b_aes[PROFILE_APN_LEN] = {0};
+ char s_aes[PROFILE_APN_AES_LEN] = {0};
+ int flag = 0;
+
+ cfg_get_item("ipv6_ppp_passwd", s_aes, sizeof(s_aes));
+ if (strlen(s_aes) == (PROFILE_APN_AES_LEN - 1)) {
+ bs_string2bytes(s_aes, b_aes, PROFILE_APN_AES_LEN - 1);
+ bs_aes_decrypt(b_aes, PROFILE_APN_LEN - 1, w_code, web_aes_key, sizeof(web_aes_key));
+ cfg_set("ipv6_ppp_passtmp", w_code);
+ printf("apn_decrypt_code w_code=%s, s_aes=%s\n", w_code, s_aes);
+ } else if (strlen(s_aes) > 0){
+ cfg_set("ipv6_ppp_passtmp", s_aes);
+ return 2;
+ }
+
+ return 1;
+}
+#endif
+#ifdef WEBS_SECURITY
+static void js_aes_wifi_encode(void)
+{
+ char js_aes_key[24 + 1]={0};
+ char imei_buf[15 + 1] = {0};
+ char rnum_buf[9 + 1] = {0};
+
+ char wificode[WIFI_PSW_DEFAULT_LENGTH] = {0};
+ char b_aes[WIFI_PSW_DEFAULT_LENGTH] = {0};
+ char *basestr = NULL;
+
+ cfg_get_item("imei", imei_buf, sizeof(imei_buf));
+ cfg_get_item("rnum_js", rnum_buf, sizeof(rnum_buf));
+ snprintf(js_aes_key, sizeof(js_aes_key), "%s%sFFFFFFFFFFFFFFF", rnum_buf, imei_buf);
+
+ cfg_get_item("WPAPSK1", wificode, sizeof(wificode));
+ bs_aes_cbc_encrypt(wificode, sizeof(wificode)-1, b_aes, js_aes_key, sizeof(js_aes_key)-1);
+ basestr = zte_base64_encode(b_aes, sizeof(b_aes)-1);
+ if (NULL == basestr) {
+ slog(MISC_PRINT, SLOG_ERR, "basestr is NULL.\n");/*lint !e26*/
+ return;
+ }
+ (void)zte_web_write("WPAPSK1_enaes", basestr);
+ free(basestr);
+ basestr = NULL;
+
+ memset(wificode, 0, sizeof(wificode));
+ cfg_get_item("m_WPAPSK1", wificode, sizeof(wificode));
+ bs_aes_cbc_encrypt(wificode, sizeof(wificode)-1, b_aes, js_aes_key, sizeof(js_aes_key)-1);
+ basestr = zte_base64_encode(b_aes, sizeof(b_aes)-1);
+ if (NULL == basestr) {
+ slog(MISC_PRINT, SLOG_ERR, "basestr-m is NULL.\n");/*lint !e26*/
+ return;
+ }
+ (void)zte_web_write("m_WPAPSK1_enaes", basestr);
+ free(basestr);
+ basestr = NULL;
+
+}
+
+
+static void js_aes_rand(void)
+{
+ char rstr[10] = {0};
+ unsigned int rnum = 0;
+
+ srand( (unsigned)time( NULL ) );
+ rnum = rand();
+ rnum %= 1000000000;
+
+ snprintf((char *)rstr, sizeof(rstr), "%09ld", rnum);
+ cfg_set("rnum_js", rstr);
+}
+//cbc
+char *js_aes_decode(char *src, size_t len, size_t *out_len)
+{
+ unsigned char *aes_password = NULL;
+ size_t aes_len = 0;
+
+ char *out = NULL;
+
+ char js_aes_key[24 + 1]={0};
+ char imei_buf[15 + 1] = {0};
+ char rnum_buf[9 + 1] = {0};
+
+ aes_password = (char *)zte_base64_decode((const unsigned char *)src, len, (unsigned int*)&aes_len);
+ if (aes_password == NULL)
+ return NULL;
+
+
+ out = malloc(aes_len + 1);
+ if (out == NULL) {
+ free(aes_password);
+ return NULL;
+ }
+ memset(out, 0, aes_len + 1);
+
+ cfg_get_item("imei", imei_buf, sizeof(imei_buf));
+ cfg_get_item("rnum_js", rnum_buf, sizeof(rnum_buf));
+ snprintf(js_aes_key, sizeof(js_aes_key), "%s%sFFFFFFFFFFFFFFF", rnum_buf, imei_buf);
+
+ bs_aes_cbc_decrypt(aes_password, aes_len, out, js_aes_key, sizeof(js_aes_key)-1);
+ //printf("decrypt js_aes_decode[%d]=%s\n", aes_len, out);
+
+ free(aes_password);
+
+ if (strlen(out) > aes_len) {
+ free(out);
+ return NULL;
+ }
+
+ *out_len = strlen(out);
+
+ return out;
+}
+#endif
+int web_aes_init(void)
+{
+ bs_aes_init_key(web_aes_key, sizeof(web_aes_key));
+ apn_profile_decrypt_code();
+#ifdef WEBS_SECURITY
+ js_aes_rand();
+#endif
+ return 1;
+}
+
diff --git a/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.h b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.h
new file mode 100755
index 0000000..7ffc4c7
--- /dev/null
+++ b/lynq/R305/ap/app/goahead/interface5.0/zte_web_mgmt.h
@@ -0,0 +1,125 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º zte_web_mgmt.h
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷ Õߣº zyt
+* Íê³ÉÈÕÆÚ£º 2010-11-24
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
+
+#ifndef ZTE_WEB_MGMT_H
+#define ZTE_WEB_MGMT_H
+
+#define APNCONFIG_MEMORY 1024
+#define PROFILE_MEMBER_LEN 32
+#define PROFILE_APN_LEN 65
+#define PROFILE_APN_AES_LEN 129
+#define DAYSEC 86400
+#define COMMONYEARSEC 31536000
+#define LEAPYEARSEC 31622400
+#define JAN_2000 946684791
+typedef struct tag_APN_PROFILE {
+ char profile_name[PROFILE_MEMBER_LEN];
+ char apn_name[PROFILE_APN_LEN];
+ char apn_select[PROFILE_MEMBER_LEN];
+ char dial_num[PROFILE_MEMBER_LEN];
+ char ppp_auth_mode[PROFILE_MEMBER_LEN];
+ char ppp_username[PROFILE_APN_LEN];
+ char ppp_passwd[PROFILE_APN_LEN];
+ char pdp_type[PROFILE_MEMBER_LEN];
+ char pdp_select[PROFILE_MEMBER_LEN];
+ char pdp_addr[PROFILE_MEMBER_LEN];
+ char dns_mode[PROFILE_MEMBER_LEN];
+ char prefer_dns_manual[PROFILE_MEMBER_LEN];
+ char standby_dns_manual[PROFILE_MEMBER_LEN];
+} APN_PROFILE;
+
+
+typedef struct tag_IPv6_APN_PROFILE {
+ char profile_name[PROFILE_MEMBER_LEN];
+ char apn_name[PROFILE_APN_LEN];
+ char apn_select[PROFILE_MEMBER_LEN];
+ char dial_num[PROFILE_MEMBER_LEN];
+ char ppp_auth_mode[PROFILE_MEMBER_LEN];
+ char ppp_username[PROFILE_APN_LEN];
+ char ppp_passwd[PROFILE_APN_LEN];
+ char pdp_type[PROFILE_MEMBER_LEN];
+ char pdp_select[PROFILE_MEMBER_LEN];
+ char pdp_addr[PROFILE_MEMBER_LEN];
+ char dns_mode[PROFILE_MEMBER_LEN];
+ char prefer_dns_manual[PROFILE_MEMBER_LEN];
+ char standby_dns_manual[PROFILE_MEMBER_LEN];
+} IPV6_APN_PROFILE;
+
+
+/* management */
+extern void zte_mgmt_login(webs_t wp);//11
+extern void zte_mgmt_logout(webs_t wp);//11
+extern void zte_mgmt_set_language(webs_t wp);//11
+extern void zte_mgmt_restore(webs_t wp);//11
+extern void zte_mgmt_poweroff(webs_t wp);
+extern void zte_mgmt_control_power_on_speed(webs_t wp);
+extern void zte_mgmt_change_password(webs_t wp);//11
+extern void zte_mgmt_change_account(webs_t wp);//
+extern void zte_goform_mgmt_set_not_login_process(webs_t wp);
+extern void zte_mgmt_disable_pin(webs_t wp);//11
+extern void zte_mgmt_pin_input(webs_t wp);//11
+extern void zte_mgmt_puk_input(webs_t wp);//11
+extern void zte_mgmt_auto_pin(webs_t wp);
+extern void zte_mgmt_pin_enable_or_modify(webs_t wp);//11
+extern void zte_mgmt_unlock_network(webs_t wp);//11
+extern void zte_goform_mgmt_pin_mgmt_process(webs_t wp);
+extern void zte_quick_setup(webs_t wp);//11
+//extern void zte_quick_set_first(webs_t wp);//11
+void deal_quick_setup_apn_ex(webs_t wp);
+extern void zte_mgmt_set_devicemode(webs_t wp);
+
+extern void zte_goform_mgmt_schedule_setting_process(webs_t wp);
+
+extern void zte_goform_mgmt_sntp_process(webs_t wp);
+
+
+extern void zte_goform_mgmt_reboot_process(webs_t wp);
+extern void zte_goform_mgmt_syslog_process(webs_t wp);
+
+extern void get_autoapn_profile(APN_PROFILE *apn_profile);
+extern void get_apn_profile_by_index(int index, APN_PROFILE *profile);
+extern void get_ipv6apn_profile_by_index(int index, IPV6_APN_PROFILE *ipv6profile);
+extern void get_ipv4v6apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile);
+extern void get_autoapn_profile(APN_PROFILE *profile);
+extern void set_apn_profile_by_index(int index, APN_PROFILE *profile);
+extern void set_ipv6_apn_profile_by_index(int index, IPV6_APN_PROFILE *ipv6profile);
+extern void set_ipv4v6_apn_profile_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile);
+extern void set_apn_prof_aes_by_index(int index, APN_PROFILE *profile);
+extern void set_ipv6_apn_prof_aes_by_index(int index, IPV6_APN_PROFILE *profile);
+extern void set_ipv4v6_apn_prof_aes_by_index(int index, APN_PROFILE *profile, IPV6_APN_PROFILE *ipv6profile);
+extern int apn_encrypt_code(void);
+extern int ipv6apn_encrypt_code(void);
+
+extern void zte_wan_lock_frequency_process(webs_t wp);
+
+extern int manual_set_time();
+
+extern void getdialog_url(int eid, webs_t wp, int argc, char_t **argv);
+extern void getddns_status(int eid, webs_t wp, int argc, char_t **argv);
+extern char * timei2s(int);
+extern void timeen2ch(char *);
+extern void datastatic(char *, char *, char *, char *, char *);
+
+extern int zte_fota_notifyPushMsg(int cmd);
+
+extern void zte_fota_get_upgrade_result(webs_t wp);
+extern void zte_fota_get_dp_pack_info(webs_t wp);
+extern void zte_fota_get_update_info(webs_t wp);
+//extern void zte_fota_get_dm_last_check_time(webs_t wp);
+#ifdef WEBS_SECURITY
+extern char *js_aes_decode(char *src, size_t len, size_t *out_len);
+#endif
+#endif
+
diff --git a/lynq/R305/ap/app/goahead/interface5.0/zte_web_util.c b/lynq/R305/ap/app/goahead/interface5.0/zte_web_util.c
new file mode 100755
index 0000000..c2eb7eb
--- /dev/null
+++ b/lynq/R305/ap/app/goahead/interface5.0/zte_web_util.c
@@ -0,0 +1,861 @@
+/**
+ * @file zte_web_util.c
+ * @brief goform mesage processing
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * @author Hong Wu <wu.hong@sanechips.com.cn>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+
+/*******************************************************************************
+ * Include header files *
+ ******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+#include <net/route.h>
+#ifdef CONFIG_DEFAULTS_KERNEL_2_6_21
+#include <linux/types.h>
+#include <linux/socket.h>
+#endif
+#include <string.h>
+#include <dirent.h>
+#include "webs.h"
+//#include "linux/autoconf.h"
+#include <sys/time.h>
+#include <signal.h>
+#include "zte_web_interface.h"
+#include "zte_web_get_fw_para.h"
+
+/*******************************************************************************
+ * Macro definitions *
+ ******************************************************************************/
+
+#define MAX_MOBILE_KEY_WORD_SIZE 20 /*¹Ø¼ü×Ö³¤¶ÈÔݶ¨20*/
+#define MAX_PAGE_PATH_SIZE 128
+//#define MAX_GOFORM_TABLE_SIZE 256
+
+/*******************************************************************************
+ * Local function declarations *
+ ******************************************************************************/
+static int getSysUptime(int eid, webs_t wp, int argc, char_t **argv);
+static int zte_goform_whitelist_check(webs_t wp);
+static int zte_goform_blacklist_check(webs_t wp);
+/*******************************************************************************
+ * Local variable definitions *
+ ******************************************************************************/
+/****Define the HEADER and FOOTER of web page****/
+static const char * const zte_web_page_header =
+ "<head>"
+ "<title>-</title>"
+ "</head>"
+ "<body bgcolor=white>"
+ "<p>"
+ "<font size=3 face=arial>"
+ "<p>"
+ "<font size=2 face=arial>"
+ ;
+
+static const char * const zte_web_page_footer =
+ "<p>"
+ "<p>"
+ "<font face=arial></b></font><br>"
+ "<script> "
+ " timer = setTimeout('location.replace(\"%s\")', 100) "
+ "</script> "
+ "<p>"
+ "</body>"
+ ;
+
+static const char * const zte_web_page_top =
+ "<p>"
+ "<p>"
+ "<font face=arial></b></font><br>"
+ "<script> "
+ " timer = setTimeout('top.location.replace(\"%s\")', 100) "
+ "</script> "
+ "<p>"
+ "</body>"
+ ;
+//multi_dataΪ¿Õ£¬ÇÒÒѵǽ²ÅÄÜ»ñÈ¡µ½,¸ÃÁÐ±í²»¿ÉËæÒâÔö¼Ó¾¡Á¿ÓÃNV
+static web_goform_type web_goform_get_cmd_table[] = {
+ /********** ¹²Í¬ ***********/
+ //{CMD_GET_DEVICE_MODE, zte_get_device_mode},//debug_enable
+ //{CMD_GET_POWERON_TIME, zte_get_poweron_time},//¿ª»úʱ¼ä
+ //{CMD_GET_LAN_DEV_INFO, zte_get_lan_dev_info},//»ñÈ¡ÄÚÍøÐÅÏ¢
+ {CMD_GET_USER_MAC_ADDR, zte_lan_user_mac_get},
+ {CMD_CONNECTION_MODE, zte_get_connection_mode},
+ /********** PBM module ***********/
+ {CMD_PBM_DATA_INFO, zte_get_pbm_data},
+ {CMD_PBM_DATA_TOTAL, zte_get_pbm_data_total},
+ {CMD_PBM_CAPACITY_INFO, zte_get_pbm_parameter_info},
+ /********** sms module ***********/
+ {CMD_SMS_PAGE_DATA, zte_get_sms_data},
+ {CMD_SMS_DATA_TOTAL, zte_get_sms_data_total},
+ {CMD_SMS_PARAMETER_INFO, zte_get_sms_parameter_info},
+ {CMD_SMS_STATUS_INFO, zte_get_sms_cmd_status_info},
+ {CMD_SMS_CAPACITY_INFO, zte_get_sms_capacity_info},
+ {CMD_SMS_STATUS_RPT_DATA, zte_get_sms_status_rpt_data},
+ {CMD_SMS_UNREAD_COUNT, zte_get_sms_unread_count},
+ {CMD_BROADCAST_DATA, zte_get_boradcast_data},
+ /********** wifi module ***********/
+ {CMD_WIFI_STATION_LIST, zte_wlan_get_station_list},
+ {CMD_WIFI_WPS_AP_PIN, zte_wlan_get_wps_pin},
+ {CMD_WIFI_WPS_AP_DEF_PIN, zte_wlan_get_wps_defpin},
+ /********** net module ***********/
+ {CMD_HOSTNAME_LIST, zte_get_hostnamelist},
+ {CMD_CURRENT_STATICADDR_LIST, zte_get_current_static_addr_list},
+ {CMD_LAN_STATION_LIST, zte_get_lan_station_list},
+ {CMD_CHILDREN_DEVICE_LIST, zte_get_children_device_list},
+ {CMD_WHITE_SITE_LIST, zte_get_white_site_list},
+ /********** DDNS ***********/
+ //{CMD_GETDDNS_STATUS, zte_get_ddns_status},
+ /********** USSD ***********/
+ {CMD_USSD_DATA_INFO, zte_get_ussd_data_info},
+ /********** FOTA ***********/
+ {FOTA_UPGRADE_RESULT, zte_fota_get_upgrade_result}, //¶ÁÈ¡ºóÐèÒªÌØÊâ´¦Àí £¬ËùÒÔ²»ÄܸijÉÖ±½Ó¶ÁNV
+
+ /********** httpshare ***********/
+ {CMD_HTTPSHARE_GETCARD_VAULE, zte_httpShare_getcard_value},
+ {CMD_HTTPSHARE_GETCARD_NMEA, zte_httpShare_getcard_name},
+ {CMD_HTTPSHARE_AUTH_GET, zte_httpShare_auth_get},
+};
+
+
+/*******************************************************************************
+* Global variable definitions *
+******************************************************************************/
+//extern web_goform_type web_goform_set_cmd_table[MAX_GOFORM_TABLE_SIZE];
+web_goform_type web_goform_set_cmd_table[] = {
+ /********** management module ***********/
+ {GOFORM_MGMT_SET_WEB_LANGUAGE, zte_mgmt_set_language}, //webuiÓïÑÔÏÔʾÉèÖÃ
+#ifndef WEBS_SECURITY
+ {GOFORM_MGMT_SET_DEVICEMODE, zte_mgmt_set_devicemode}, //¹¤×÷ģʽ
+#endif
+ {GOFORM_MGMT_LOGIN_IP, zte_mgmt_login}, //怫
+ {GOFORM_MGMT_LOGOUT_IP, zte_mgmt_logout}, //µÇ³ö
+ {GOFORM_MGMT_CHANGE_PASSWORD, zte_mgmt_change_password}, //ÃÜÂëÐÞ¸Ä
+ {GOFORM_MGMT_CHANGE_ACCOUNT, zte_mgmt_change_account}, //Õ˺ÅÐÞ¸Ä
+ {GOFORM_MGMT_QUICK_SETUP, zte_quick_setup}, //¿ìËÙÉèÖÃ
+ {GOFORM_MGMT_RESTORE_FACTORY_SETTINGS, zte_mgmt_restore}, //»Ö¸´³ö³¡ÉèÖÃ
+ {GOFORM_MGMT_REBOOT, zte_goform_mgmt_reboot_process}, //REBOOT
+ {GOFORM_MGMT_POWEROFF, zte_mgmt_poweroff}, //poweroff
+ {GOFORM_MGMT_POWER_ON_SPEED, zte_mgmt_control_power_on_speed}, //¿ìËÙ¿ª¹Ø»úÉèÖÃ
+ //{GOFORM_MGMT_SET_EXTERNAL_NV, zte_goform_set_external_nv},
+ {GOFORM_MGMT_SCHEDULE_SETTING, zte_goform_mgmt_schedule_setting_process},
+ {GOFORM_MGMT_SNTP, zte_goform_mgmt_sntp_process}, //SNTPÉèÖÃ
+ {GOFORM_SNTP_GETDATASTATIC, zte_goform_sntp_getdatastatic_process}, //´¥·¢serverУ׼ʱ¼ä
+ //{GOFORM_MGMT_SYSLOG, zte_goform_mgmt_syslog_process}, //ϵͳLOG
+
+ /********** wan module start***********/
+ {GOFORM_WAN_SET_NETWORK, zte_wan_set_network}, //ÊÖ¶¯ËÑÍø×¢²á
+ {GOFORM_WAN_SET_CONNECTION_MODE, zte_wan_set_connection_mode}, //ÉèÖò¦ºÅģʽ
+ {GOFORM_WAN_CONNECT_NETWORK, zte_wan_connect_network}, //PDP ²¦ºÅÇëÇó
+ {GOFORM_WAN_DISCONNECT_NETWORK, zte_wan_disconnect_network}, //PDP ²¦ºÅ¶Ï¿ªÇëÇó
+ {GOFORM_WAN_SET_BEARER_PREFERENCE, zte_wan_network_select}, //ÉèÖÃÕÒÍø·½Ê½MSG_CMD_NET_SELECT_REQ
+ {GOFORM_WAN_SCAN_NETWORK, zte_wan_scan_network}, //ÊÖ¶¯ËÑÍø
+ {GOFORM_WAN_UNLOCK_NETWORK, zte_mgmt_unlock_network}, //½âËøÍøÂç
+ //{GOFORM_WAN_LOCK_FREQUENCY, zte_wan_lock_frequency_process}, //LTEÏÂËø»ò½âËøÆµÇëÇó£¬ATÔÝδ´¦Àí
+ /********** apn module ***********/
+ {GOFORM_WAN_APN_PROC_EX, zte_form_multi_apn_proc_ex}, //APNÉèÖÃ
+ /********** pin,puk module ***********/
+ {GOFORM_MGMT_ENTER_PIN, zte_mgmt_pin_input}, //ÑéÖ¤PINÂëÊäÈë
+ {GOFORM_MGMT_DISABLE_PIN, zte_mgmt_disable_pin}, //¹Ø±ÕPIN
+ {GOFORM_MGMT_ENABLE_PIN, zte_mgmt_pin_enable_or_modify}, //¿ªÆô»òÐÞ¸ÄPIN
+ {GOFORM_MGMT_ENTER_PUK, zte_mgmt_puk_input}, //PUK
+ {GOFORM_MGMT_AUTO_PIN, zte_mgmt_auto_pin}, //×Ô¶¯PIN
+ /********** statistics module ***********/
+ {GOFORM_WAN_DATA_LIMIT_SETTING, zte_wan_data_limit_setting}, //Á÷Á¿¹ÜÀíÉèÖÃ
+ {GOFORM_WAN_DATA_FLOW_CALIBRATION_MANUAL, zte_wan_data_flow_calibration_manual},//ÊÖ¶¯Ð£×¼Á÷Á¿
+ {GOFORM_WAN_RESET_DATA_COUNTER, zte_wan_data_statistics_clear_process}, //Çå³ýÁ÷Á¿ÐÅÏ¢
+ /********** ussd module ***********/
+ {GOFORM_USSD_PROCESS, zte_goform_ussd_process}, //USSDÉèÖÃ
+ /********** wan module end***********/
+
+ /********** wifi module ***********/
+ {GOFORM_WLAN_SET, zte_wlan_basic_set}, //WIFI »ù´¡ÉèÖÃ
+ {GOFORM_WLAN_MAC_FILTER, zte_wlan_mac_filter_set}, //ÉèÖÃmac¹ýÂ˹¦ÄÜ
+ {GOFORM_WLAN_WPS_SET, zte_wlan_wps_mode_set}, //WPS
+ {GOFORM_WLAN_SSID1_SET, zte_wlan_web_ssid1_set}, //SSID1
+ {GOFORM_WLAN_SSID2_SET, zte_wlan_ssid2_set}, //SSID2
+ {GOFORM_WLAN_WIFI_SLEEP_SET, zte_wlan_sleep_set}, //ÐÝÃß
+ {GOFORM_WLAN_SET_TSW, zte_wlan_set_tsw}, //¶¨Ê±ÐÝÃß»½ÐÑ
+ {GOFORM_WLAN_WIFI_COVERAGE_SET, zte_wlan_coverage_set}, //¸²¸Ç·¶Î§
+ {GOFORM_WLAN_WIFI_STA_CONTROL, zte_wlan_station_set}, //wifi station
+ {GOFORM_WLAN_WIFI_SPOT_PROFILE_UPDATE, zte_wlan_station_spot_profile_update}, //wifi station
+ {GOFORM_WLAN_SET_STA_CON, zte_wlan_station_connect}, //wifi station
+ {GOFORM_WLAN_SET_STA_DISCON, zte_wlan_station_disconnect}, //wifi station
+ {GOFORM_WLAN_SET_STA_REFRESH, zte_wlan_station_refresh}, //wifi station
+
+ /********** router module ***********/
+ {GOFORM_ROUTER_DEL_IP_PORT_FILETER, zte_fw_ipport_filter_del},
+ {GOFORM_ROUTER_ADD_IP_PORT_FILETER_V4V6, zte_fw_ipport_filter_add}, /*for v4 and v6*/
+ {GOFORM_ROUTER_DEL_IP_PORT_FILETER_V4V6, zte_fw_ipport_filter_del_v4_v6}, /*for v4 and v6*/
+ {GOFORM_ROUTER_ADD_PORT_FORWARE, zte_fw_port_forward_add},
+ {GOFORM_ROUTER_DEL_PORT_FORWARE, zte_fw_port_forward_del},
+ {GOFORM_ROUTER_ADD_PORT_MAP, zte_fw_port_map_add},
+ {GOFORM_ROUTER_DEL_PORT_MAP, zte_fw_port_map_del},
+ {GOFORM_ROUTER_BASIC_SETTING, zte_fw_basic_setting},
+ {GOFORM_ROUTER_FORWARD_SETTING, zte_fw_forward_setting},
+ {GOFORM_ROUTER_SYSTEM_SECURITY, zte_fw_sys_security_setting},
+ {GOFORM_ROUTER_DHCP_SETTING, zte_dhcp_set},
+ {GOFORM_ROUTER_STATIC_DHCP_SETTING, zte_static_dhcp_set},
+ {GOFORM_ROUTER_UPNP_SETTING, zte_fw_upnp_set}, //CPEÈÚºÏÔÚ·ÓÉÉèÖÃÖÐ
+ {GOFORM_ROUTER_DMZ_SETTING, zte_fw_dmz},
+ {GOFORM_ROUTER_EDIT_HOSTNAME, zte_edit_hostname},
+ {GOFORM_URL_FILTER_DELETE, zte_goform_url_filter_delete_process}, //URL ¹ýÂË
+ {GOFORM_URL_FILTER_ADD, zte_goform_url_filter_add_process},
+ {GOFORM_BIND_STATIC_ADDRESS_SET, zte_set_bind_static_address},
+ {GOFORM_BIND_STATIC_ADDRESS_ADD, zte_bind_static_address_add},
+ {GOFORM_BIND_STATIC_ADDRESS_DEL, zte_bind_static_address_del},
+ {GOFORM_ADD_CHILDREN_DEVICE, zte_add_children_device}, //¼Ò³¤¿ØÖÆ
+ {GOFORM_DEL_CHILDREN_DEVICE, zte_del_children_device},
+ {GOFORM_ADD_WHITE_SITE, zte_add_white_site},
+ {GOFORM_REMOVE_WHITE_SITE, zte_remove_white_site},
+ {GOFORM_PARENT_CONTROL_SET, zte_parent_control_set},
+ //{GOFORM_DDNS, zte_goform_ddns},
+ //{GOFORM_DNS_MODE_SET, zte_dns_mode_set}, //ÉèÖÃÊÖ¶¯DNS mode
+ //{GOFORM_DNS_SERVER_SET, zte_dns_server_set}, //ÉèÖÃÊÖ¶¯DNS server
+ /********** wan pppoe ***********/
+ {GOFORM_SET_OPERATION_MODE, zte_goform_set_operation_mode}, //RJ45ģʽÇл»ÉèÖÃ
+ {GOFORM_SET_WAN_GATEWAYMODE_PPPOE, zte_goform_set_wan_gatewaymode_PPPOE},
+ {GOFORM_SET_WAN_GATEWAYMODE_DHCP, zte_goform_set_wan_gatewaymode_DHCP},
+ {GOFORM_SET_WAN_GATEWAYMODE_STATIC, zte_goform_set_wan_gatewaymode_STATIC},
+ {GOFORM_SET_WAN_GATEWAYMODE_AUTO, zte_goform_set_wan_gatewaymode_AUTO},
+
+ /********** httpShare module ***********/
+ {GOFORM_HTTPSHARE_ENTERFOLD, zte_httpShare_enterFold}, //get SD's filelist
+ {GOFORM_HTTPSHARE_NEW, zte_httpShare_new}, //creat a new folder
+ {GOFORM_HTTPSHARE_DEL, zte_httpShare_del}, //delete file or folder
+ {GOFORM_HTTPSHARE_AUTH_SET, zte_httpShare_auth_set}, //httpshare setting
+ {GOFORM_HTTPSHARE_MODE_SET, zte_httpShare_modeset}, //set SD card's mode:usb mode or httpshare mode
+ {GOFORM_HTTPSHARE_FILE_RENAME, zte_httpShare_rename}, //rename the file
+ {GOFORM_HTTPSHARE_CHECK_FILE, zte_httpShare_check_file}, //check file exists
+
+ /********** PBM module ***********/
+ {GOFORM_PBM_CONTACT_ADD, zte_goform_pbm_contact_add_process},
+ {GOFORM_PBM_CONTACT_DEL, zte_goform_pbm_contact_del_process},
+
+ /********** sms module ***********/
+ {GOFORM_SMS_SET_MSG_CENTER, zte_sms_set_message_center},
+ {GOFORM_SMS_DELETE_SMS, zte_sms_delete_msg_process},
+ {GOFORM_SMS_DELETE_SMS_ALL, zte_goform_sms_alldel_msg_process},
+ {GOFORM_SMS_MOVE_TO_SIM, zte_sms_move_to_sim_msg_process},
+ {GOFORM_SMS_SAVE_SMS, zte_sms_save_msg_process},
+ {GOFORM_SMS_SEND_SMS, zte_sms_send_msg_process},
+ {GOFORM_SMS_SET_MSG_READ, zte_sms_view_msg_process},
+
+ /********** fota module ***********/
+ {GOFORM_SET_FOTAAUTOUPDATE, zte_fota_update}, //Óû§Ñ¡ÔñÊÇ·ñ½øÐÐÉý¼¶ºÍÉý¼¶ÖÐÈ¡Ïû
+ {GOFORM_SET_FOTASETTINGS, zte_fota_settings}, //×Ô¶¯¼ì²â
+
+ /********** ping test ***********/
+ //{GOFORM_PING_DIAGNOSTICS_START, zte_ping_diagnostics_start}, // ping°ü¼ì²â¹¦ÄÜ¿ªÆô
+ //{GOFORM_PING_DIAGNOSTICS_STOP, zte_ping_diagnostics_stop}, // ping°ü¼ì²â¹¦ÄܹرÕ
+
+ /********** ¿Í»§¶þ´Î¿ª·¢½Ó¿ÚÇëÔÚÏÂÃæÌí¼Ó ***********/
+ {GOFORM_SET_SAMPLE, zte_goform_set_sample}, //¿Í»§¶þ´Î¿ª·¢½Ó¿ÚʾÀý
+};
+
+/*******************************************************************************
+ * Local function implementations *
+ ******************************************************************************/
+
+//WH://»ñȡϵͳ×î½üÒ»´ÎÉϵçºó³ÖÐøÔËÐÐʱ¼ä
+static int getSysUptime(int eid, webs_t wp, int argc, char_t **argv)
+{
+ struct tm *utime;
+ time_t usecs;
+
+ char syn_system_total[20] = {0};
+ char syn_after_time[20] = {0};
+ int ltime = 0;
+ int ntime = 0;
+
+ cfg_get_item("syn_system_total", syn_system_total, sizeof(syn_system_total));
+
+ sscanf(syn_system_total, "%d", <ime);
+ if(ltime < 0 || ltime > INT_MAX-1) // kw 3
+ {
+ ltime = 0;
+ }
+ ltime += JAN_2000;
+
+ cfg_get_item("syn_after_time", syn_after_time, sizeof(syn_after_time));
+
+ sscanf(syn_after_time, "%d", &ntime);
+ if(ntime < 0 || ntime > INT_MAX-1) // kw 3
+ {
+ ntime = 0;
+ }
+ time(&usecs);
+ if (ntime == 0) {
+ utime = localtime(&usecs);
+ } else {
+ time_t use;
+ use = (time_t)(usecs - ntime + ltime);
+ utime = localtime(&use);
+ }
+ if(utime == NULL)
+ return -1;
+ if (utime->tm_yday > 0) {
+ return websWrite(wp, T("%d day%s, %d hour%s, %d min%s, %d sec%s"),
+ utime->tm_yday, (utime->tm_yday == 1) ? "" : "s",
+ utime->tm_hour, ((utime->tm_hour == 1) || (utime->tm_hour == 0)) ? "" : "s",
+ utime->tm_min, ((utime->tm_min == 1) || (utime->tm_min == 0)) ? "" : "s",
+ utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+ } else if (utime->tm_hour > 0) {
+ return websWrite(wp, T("%d hour%s, %d min%s, %d sec%s"),
+ utime->tm_hour, (utime->tm_hour == 1) ? "" : "s",
+ utime->tm_min, ((utime->tm_min == 1) || (utime->tm_min == 0)) ? "" : "s",
+ utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+ } else if (utime->tm_min > 0) {
+ return websWrite(wp, T("%d min%s, %d sec%s"),
+ utime->tm_min, (utime->tm_min == 1) ? "" : "s",
+ utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+ } else {
+ return websWrite(wp, T("%d sec%s"),
+ utime->tm_sec, ((utime->tm_sec == 1) || (utime->tm_sec == 0)) ? "" : "s");
+ }
+
+}
+
+static int zte_goform_whitelist_check(webs_t wp)
+{
+
+ char login_info[NV_ITEM_STRING_LEN_20] = {0};
+ char_t nv_ipaddr[40] = {0};
+ //zte_topsw_state_e_type status = ZTE_NVIO_MAX;
+ char_t *ip_address = NULL;
+
+ int result = FALSE;
+
+ zte_web_read(NV_LOGINFO, login_info);
+
+ //get request ip addr
+ ip_address = websGetRequestIpaddr(wp);
+#if 0 // kw 3 NVARIANT_CONDITION.UNREACH
+ if (NULL == ip_address) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_goform_whitelist_check: ip_address is null.\n"); /*lint !e26*/
+ return FALSE;
+ }
+#endif
+ (void)zte_web_read(NV_USER_IP_ADDR, nv_ipaddr);
+ if ((0 == strncmp(login_info, "ok", sizeof(login_info))) && (0 == strncmp(ip_address, nv_ipaddr, sizeof(nv_ipaddr)))) {
+ result = TRUE; //to update the timemark
+ }
+ if (result == TRUE) {
+ if (!zte_mgmt_login_timemark_set()) {
+ slog(MISC_PRINT, SLOG_ERR, "[ERROR]zte_goform_whitelist_check -> timemark set error .\n"); /*lint !e26*/
+ }
+ }
+
+ return result;
+}
+
+/******************************************************
+* Function: zte_goform_blacklist_check
+* Description:goform entry for handling set cmd
+* Input: HTTP Request Info
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2013/01/21 V1.0 Liuyingnan create
+*******************************************************/
+static int zte_goform_blacklist_check(webs_t wp)
+{
+ //char login_info[NV_ITEM_STRING_LEN_20] = {0};
+ char_t *zte_goform_id = NULL;
+ //zte_web_read(NV_LOGINFO, login_info);
+
+ zte_goform_id = websGetVar(wp, T("goformId"), T(""));
+ if (zte_goform_id == NULL) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_goform_whitelist_check: zte_goform_id is null.\n"); /*lint !e26*/
+ return -1;
+ }
+
+ if ((0 == strncmp(GOFORM_MGMT_SET_WEB_LANGUAGE, zte_goform_id, strlen(GOFORM_MGMT_SET_WEB_LANGUAGE)))
+ || (0 == strncmp(GOFORM_MGMT_LOGIN_IP, zte_goform_id, strlen(GOFORM_MGMT_LOGIN_IP)))
+ || (0 == strncmp(GOFORM_MGMT_ENTER_PIN, zte_goform_id, strlen(GOFORM_MGMT_ENTER_PIN)))
+ || (0 == strncmp(GOFORM_MGMT_ENTER_PUK, zte_goform_id, strlen(GOFORM_MGMT_ENTER_PUK)))
+ || (0 == strncmp(GOFORM_HTTPSHARE_CHECK_FILE, zte_goform_id, strlen(GOFORM_HTTPSHARE_CHECK_FILE)))
+ || (0 == strncmp(GOFORM_HTTPSHARE_ENTERFOLD, zte_goform_id, strlen(GOFORM_HTTPSHARE_ENTERFOLD)))
+ || (0 == strncmp(GOFORM_HTTPSHARE_FILE_RENAME, zte_goform_id, strlen(GOFORM_HTTPSHARE_FILE_RENAME)))
+ || (0 == strncmp(GOFORM_HTTPSHARE_NEW, zte_goform_id, strlen(GOFORM_HTTPSHARE_NEW)))
+ || (0 == strncmp(GOFORM_HTTPSHARE_DEL, zte_goform_id, strlen(GOFORM_HTTPSHARE_DEL)))
+#ifndef WEBS_SECURITY
+ || (0 == strncmp(GOFORM_MGMT_LOGOUT_IP, zte_goform_id, strlen(GOFORM_MGMT_LOGOUT_IP)))
+ || (0 == strncmp(GOFORM_MGMT_SET_DEVICEMODE, zte_goform_id, strlen(GOFORM_MGMT_SET_DEVICEMODE)))
+ || (0 == strncmp(GOFORM_MGMT_REBOOT, zte_goform_id, strlen(GOFORM_MGMT_REBOOT)))
+#endif
+ ) {
+ slog(MISC_PRINT, SLOG_DEBUG, "zte_goform_whitelist_check: zte_goform_id:[%s] is OK.\n", zte_goform_id); /*lint !e26*/
+ return 1;
+ } else {
+ slog(MISC_PRINT, SLOG_ERR, "zte_goform_whitelist_check: zte_goform_id:[%s] is black.\n", zte_goform_id); /*lint !e26*/
+ return -1;
+ }
+
+}
+
+static int isMobileReq(webs_t wp)
+{
+ int iMobileKW = 0;
+ const char MOBILE_KEYWORD[][MAX_MOBILE_KEY_WORD_SIZE] = {"Mobile", "mobile", "MOBILE"};
+
+ if (wp->userAgent == NULL) {
+ return 0;
+ }
+ for (iMobileKW = 0; iMobileKW < sizeof(MOBILE_KEYWORD) / MAX_MOBILE_KEY_WORD_SIZE; iMobileKW++) {
+ if (strstr(wp->userAgent, MOBILE_KEYWORD[iMobileKW]) != NULL) {
+ return 1;
+ }
+ }
+ return 0;
+}
+static int isPageExist(char *page)
+{
+ char *defaultDir = websGetDefaultDir();
+ char *fullPagePath = NULL;
+ int fullPathSize = 0;
+ int hasPageExist = 0;
+
+ if (defaultDir == NULL || page == NULL) {
+ return 0;
+ }
+ fullPathSize = strlen(defaultDir) + strlen(page) + 2;
+ fmtAlloc(&fullPagePath, fullPathSize, T("%s/%s"), defaultDir, page);
+ hasPageExist = (access(fullPagePath, F_OK) == 0);
+ bfreeSafe(B_L, fullPagePath);
+ return hasPageExist;
+}
+
+int is_print_str(char *str, int len)
+{
+ int i = 0;
+ if (str == NULL || len <= 0 || strlen(str) < len) {
+ return 0;
+ }
+ for (i = 0; i < len; i++) {
+ if (!isprint(str[i])) {
+ return 0;
+ }
+ if(str[i] == '%' && (i+2) < len && isxdigit(str[i+1]) && isxdigit(str[i+2]))
+ {
+ if(str[i+1] < '2' || str[i+1] > '7' ||(str[i+1] == '7' && (str[i+2] == 'f' || str[i+2] == 'F')))
+ {
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+
+/*******************************************************************************
+ * Global function implementations *
+ ******************************************************************************/
+
+/******************************************************
+* Function: void zte_web_init()
+* Description: the entry of zte code in goahead
+* Input:
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2010/8/5 V1.0 LiuWei create
+* 2010/11/4 V1.1 ZYT modify
+*******************************************************/
+void zte_web_init()
+{
+ cfg_set(NV_LOGINFO, "");
+ websFormDefine(T("proc_get"), zte_goform_get_cmd_process);
+ websFormDefine(T("proc_post"), zte_goform_set_cmd_process);
+ zte_init_login_psw_time(); //WH:³õʼ»¯×î´óµÇ½´ÎÊý
+}
+
+/*
+ * description: parse va and do system
+ */
+#if 0
+int doSystem(char_t *fmt, ...)
+{
+ va_list vargs;
+ char_t *cmd = NULL;
+ int rc = 0;
+
+ va_start(vargs, fmt);/*lint !e530*/
+ if (fmtValloc(&cmd, WEBS_BUFSIZE, fmt, vargs) >= WEBS_BUFSIZE) {
+ trace(0, T("doSystem: lost data, buffer overflow\n"));
+ }
+ va_end(vargs);
+
+ if (cmd) {
+ trace(0, T("%s\n"), cmd);
+ rc = system(cmd);
+ bfree(B_L, cmd);
+ }
+ return rc;
+}
+#endif
+/******************************************************
+* Function: void zte_webs_feedback_top(webs_t wp, char *fileName)
+* Description: feed back web page at top location
+* Input:
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2010/9/10 V1.0 LiuWei create
+* 2010/11/15 V1.1 zyt modify
+*******************************************************/
+void zte_webs_feedback_top(webs_t i_wp, char *i_pageName)
+{
+ char dest_page[64] = {0};
+ char language[64] = {0};
+
+ if (NULL == i_pageName) {
+ slog(MISC_PRINT, SLOG_ERR, "zte_webs_feedback_top para null.\n"); /*lint !e26*/
+ return;
+ }
+
+ cfg_get_item(NV_LANGUAGE, language, sizeof(language));
+ websWrite(i_wp, T("HTTP/1.1 200 OK\n"));
+ websWrite(i_wp, T("Pragma: no-cache\n"));
+ websWrite(i_wp, T("Cache-control: no-cache\n"));
+ websWrite(i_wp, T("Connection: Close\n"));
+ websWrite(i_wp, T("Content-Type: text/html\n"));
+ websWrite(i_wp, T("Set-Cookie: mLangage=%s;"" path=/;"" Expires=Mon, 1 Jan 2050 00:00:00 GMT\n"), language);
+ websWrite(i_wp, T("\n"));
+ websWrite(i_wp, T("<html>\n"));
+ websWrite(i_wp, T(zte_web_page_header));
+ websWrite(i_wp, T(zte_web_page_top), i_pageName);
+ websWrite(i_wp, T("</html>"));
+}
+
+
+
+/******************************************************
+* Function: zte_goform_get_cmd_process()
+* Description:goform entry from web pages to get fw para, call the related functions according to the cmd
+* Input: HTTP Request Info
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2012/08/08 V1.0 liuyingnan create
+*******************************************************/
+void zte_goform_get_cmd_process(webs_t wp, char *path, char *query)
+{
+ char_t *cmd = NULL;
+ char_t *multi_data = NULL;
+ char login_info[NV_ITEM_STRING_LEN_20] = {0};
+ UINT32 ticks = 0;
+ int goform_index = 0;
+ int max_goform_index = (int)(sizeof(web_goform_get_cmd_table) / sizeof(web_goform_type));
+
+ zte_get_login_status_value(wp, login_info);
+
+ cmd = websGetVar(wp, T("cmd"), T(""));
+ multi_data = websGetVar(wp, T("multi_data"), T(""));
+
+ slog(MISC_PRINT, SLOG_DEBUG, "[goahead] zte_goform_get_cmd_process multi_data = %s, cmd = %s\n", multi_data, cmd);
+
+ zte_mgmt_login_timeout_check();
+
+ if (0 == strcmp(cmd, "")) {
+ websDone(wp, 0);
+ return;
+ }
+#ifdef WEBINSPECT_FIX
+ if (query && (strstr(query, "%3d%2f")
+ || strstr(query, "%3c%2f")
+ || strstr(query, "=/")
+ || strstr(query, "</")
+ || strstr(query, "%27")
+ || strstr(query, "'")
+#ifdef WEBS_SECURITY
+ || strstr(query, "%2f")
+ || strstr(query, "/")
+ || strstr(query, "%5c")
+ || strstr(query, "\\")
+ || strstr(query, "%3c")
+ || strstr(query, "<")
+ || strstr(query, "%3e")
+ || strstr(query, ">")
+ || strstr(query, "%28")
+ || strstr(query, "(")
+ || strstr(query, "%29")
+ || strstr(query, ")")
+ || strstr(query, "%25")
+#endif
+ )) {
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e qry:%s\n",query);
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]e 1\n");
+ websDone(wp, 0);
+ return;
+ }
+ if (strstr(cmd, "=/") || strstr(cmd, "</")
+#ifdef WEBS_SECURITY
+ || strstr(cmd, "/") || strstr(cmd, "\\") || strstr(cmd, "<") || strstr(cmd, ">")
+#endif
+ || strstr(cmd, "'")) {
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e cmd:%s\n",cmd);
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]e 2\n");
+ websDone(wp, 0);
+ return;
+ }
+#ifdef WEBS_SECURITY
+ char token[COOKIE_SESSION_SIZE+1] = {0};
+ char cook_id[COOKIE_SESSION_SIZE+1] = {0};
+ (void)zte_web_read(NV_COOKIE_ID, cook_id);
+ (void)zte_web_read(NV_WEB_TOKEN, token);
+ if (strlen(cook_id) && wp->cookie && strlen(wp->cookie) > strlen(token)
+ && (strstr(wp->cookie, token) == NULL)) {
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e cmd:%s\n",cmd);
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e token:%s\n",token);
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e cookie:%s\n",wp->cookie);
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]e 3\n");
+ websDone(wp, 0);
+ cfg_set(NV_WEB_TOKEN, "");
+ return;
+ }
+ if(query && !is_print_str(query,strlen(query)))
+ {
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]g print_str\n");
+ websDone(wp, 0);
+ return;
+ }
+#endif
+#endif
+ if ((0 == strcmp("ok", login_info)) || (0 == strcmp(GOFORM_HTTPSHARE_GETCARD_VAULE, cmd))) {
+ if (0 == strcmp(multi_data, "")) {
+ for (goform_index = 0; goform_index < max_goform_index; goform_index++) {
+ if (0 == strcmp(web_goform_get_cmd_table[goform_index].goform_id, cmd)) {
+ (*(web_goform_get_cmd_table[goform_index].proc_func))(wp);
+ websDone(wp, 200);
+ return;
+ }
+ }
+ zte_web_get_para_xml(wp, (char_t *)cmd);
+ } else {
+ zte_get_request_process_xml(wp, cmd);
+ }
+ } else {
+ if (0 == strcmp(multi_data, "")) {
+ zte_web_get_para_nologin(wp, (char_t *)cmd);
+ } else {
+ zte_get_request_process_nologin(wp, (char_t *)cmd);
+ }
+ }
+ websDone(wp, 0);
+ return;
+
+}
+
+/******************************************************
+* Function: zte_goform_set_cmd_process()
+* Description:goform entry from web pages to set firmware para
+* Input: HTTP Request Info
+* Output:
+* Return:
+* Others:
+* Modify Date Version Author Modification
+* 2012/08/08 V1.0 liuyingnan create
+*******************************************************/
+
+void zte_goform_set_cmd_process(webs_t wp, char *path, char *query)
+{
+ char_t *zte_goform_id = NULL;
+ int goform_index = 0;
+ int max_goform_index = (int)(sizeof(web_goform_set_cmd_table) / sizeof(web_goform_type));
+ int blacklist_result = 0;
+ char login_info[NV_ITEM_STRING_LEN_20] = {0};
+
+ zte_get_login_status_value(wp, login_info);
+ zte_goform_id = websGetVar(wp, T("goformId"), T(""));
+
+ slog(MISC_PRINT, SLOG_DEBUG,"[goahead] zte_goform_set_cmd_process zte_goform_id = %s,login_info=%s!\n", zte_goform_id, login_info);
+#ifdef WEBINSPECT_FIX
+ if (query && (strstr(query, ")(")
+/* || strstr(query, "%26%26")
+ || strstr(query, "&&")
+ || strstr(query, "%7C%7C")
+ || strstr(query, "||")
+ || strstr(query, "%3B")
+ || strstr(query, ";")*/
+ )) {
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e sqry:%s\n",query);
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]e 4\n");
+ websDone(wp, 0);
+ return;
+ }
+#ifdef WEBS_SECURITY
+ if (!(wp->flags & WEBS_POST_REQUEST)||(query && (strstr(query, "%2f")
+ || strstr(query, "/")
+ || strstr(query, "%5c")
+ || strstr(query, "\\")
+ || strstr(query, "%3c")
+ || strstr(query, "<")
+ || strstr(query, "%3e")
+ || strstr(query, ">")
+ || strstr(query, "%27")
+ || strstr(query, "'")
+ || strstr(query, "%28")
+ || strstr(query, "(")
+ || strstr(query, "%29")
+ || strstr(query, ")")
+ || strstr(query, "%25")
+ ))) {
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e qry:%s\n",query);
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]e 5\n");
+ websDone(wp, 0);
+ return;
+ }
+ char token[COOKIE_SESSION_SIZE+1] = {0};
+ char cook_id[COOKIE_SESSION_SIZE+1] = {0};
+ (void)zte_web_read(NV_COOKIE_ID, cook_id);
+ (void)zte_web_read(NV_WEB_TOKEN, token);
+ if (strlen(cook_id) && wp->cookie && strlen(wp->cookie) > strlen(token)
+ && (strstr(wp->cookie, token) == NULL)) {
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e goform:%s\n",zte_goform_id);
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e token:%s\n",token);
+ //slog(MISC_PRINT, SLOG_ERR,"[goahead]e cookie:%s\n",wp->cookie);
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]e 6\n");
+ websDone(wp, 0);
+ cfg_set(NV_WEB_TOKEN, "");
+ return;
+ }
+ if(query && !is_print_str(query,strlen(query)))
+ {
+ slog(MISC_PRINT, SLOG_ERR,"[goahead]s print_str\n");
+ zte_write_result_to_web(wp, FAILURE);
+ websDone(wp, 200);
+ return;
+ }
+#endif
+#endif
+
+ if (0 != strcmp("ok", login_info)) {
+ blacklist_result = zte_goform_blacklist_check(wp);
+ if (blacklist_result < 0) {
+ slog(MISC_PRINT, SLOG_ERR,"[ERROR]zte_goform_blacklist_check -> black goform id:[%s].\n", zte_goform_id);
+ zte_write_result_to_web(wp, FAILURE);
+ websDone(wp, 200);
+ return;
+ }
+ }
+
+ zte_mgmt_login_timemark_set();
+
+ for (goform_index = 0; goform_index < max_goform_index; goform_index++) {
+ if (0 == strcmp(web_goform_set_cmd_table[goform_index].goform_id, zte_goform_id)) {
+ (void)zte_goform_whitelist_check(wp);//not to check the return value, only A has logged in,then update the timemark
+ (*(web_goform_set_cmd_table[goform_index].proc_func))(wp);
+ break;
+ }
+ }
+
+ if (goform_index == max_goform_index) {
+ slog(MISC_PRINT, SLOG_ERR,"[ERROR]zte_goform_set_cmd_process -> unknown goform id:[%s].\n", zte_goform_id);
+ zte_write_result_to_web(wp, FAILURE);
+ }
+
+ websDone(wp, 200);
+ return;
+}
+
+zte_topsw_state_e_type zte_nvconfig_read(char *item, char *data, int dataLen)
+{
+ if (NULL == item || NULL == data) {
+ slog(MISC_PRINT, SLOG_ERR, "input is NULL."); /*lint !e26*/
+ return ZTE_NVIO_FAIL;
+ }
+
+ if (dataLen > NV_ITEM_VALUE_MAX_LEN) {
+ slog(MISC_PRINT, SLOG_ERR, "data of [%s] too long.", item); /*lint !e26*/
+ return ZTE_NVIO_FAIL;
+ }
+ // kw 3
+ if(0 == cfg_get_item(item, data, dataLen))
+ {
+ return ZTE_NVIO_DONE;
+ }
+
+ return ZTE_NVIO_FAIL;
+}
+
+zte_topsw_state_e_type zte_nvconfig_write(char *item, char *data, int dataLen)
+{
+ if (NULL == item || NULL == data) {
+ slog(MISC_PRINT, SLOG_ERR, "input is NULL."); /*lint !e26*/
+ return ZTE_NVIO_FAIL;
+ }
+
+ if ((strlen(data) + 1) > NV_ITEM_VALUE_MAX_LEN || dataLen > NV_ITEM_VALUE_MAX_LEN) {
+ slog(MISC_PRINT, SLOG_ERR, "value is too long, name=%s.", item); /*lint !e26*/
+ return ZTE_NVIO_FAIL;
+ }
+
+ if(0 == cfg_set(item, data))
+ {
+ return ZTE_NVIO_DONE;
+ }
+
+ return ZTE_NVIO_FAIL;
+}
+
+void zte_init_login_psw_time(void)
+{
+ (void)zte_web_write("psw_fail_num_str", LOGIN_FAIL_TIMES);
+}
+
+void zte_goform_set_external_nv(webs_t wp)
+{
+ char_t *nv_name = NULL;
+ char_t *nv_value = NULL;
+ nv_name = websGetVar(wp, T("external_nv_name"), T(""));
+ nv_value = websGetVar(wp, T("external_nv_value"), T(""));
+
+ if (nv_value == NULL || nv_name == NULL) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ if (0 != strncmp(nv_name, "external", 8)) {
+ zte_write_result_to_web(wp, FAILURE);
+ return;
+ }
+
+ cfg_set(nv_name, nv_value);
+ zte_write_result_to_web(wp, SUCCESS);
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: zte_web_get_login_page
+* ¹¦ÄÜÃèÊö: ×ÔÊÊÓ¦ÖÕ¶Ëä¯ÀÀÆ÷
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ:
+* ÆäËü˵Ã÷:
+**************************************************************************/
+const char* zte_web_get_login_page(webs_t wp)
+{
+ if (isMobileReq(wp) && isPageExist(ZTE_WEB_MOBILE_PAGE_LOGIN_NAME)) {
+ return ZTE_WEB_MOBILE_PAGE_LOGIN_NAME;
+ } else {
+ return ZTE_WEB_PAGE_LOGIN_NAME;
+ }
+}
+
+
+
diff --git a/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c b/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
new file mode 100755
index 0000000..8dde93f
--- /dev/null
+++ b/lynq/R305/ap/app/zte_comm/at_ctl/src/atconfig/extat_softap_register.c
@@ -0,0 +1,491 @@
+/*******************************************************************************
+*À©Õ¹ATÃüÁîʵÏַǵçÐÅÏà¹ØÒµÎñ ʵÀý
+*À©Õ¹ATÃüÁ¼ÈÖ§³ÖsoftapÖ®ÉϵÄÓû§½ø³Ìͨ¹ýptyÉ豸Óëat_ctl½øÐÐÀ©Õ¹AT½»»¥£¬Ò²Ö§³Ö¿Í»§µÄMCUͨ¹ýuart»òUSBµÈ´®¿ÚͨµÀͨ¹ýÀ©Õ¹ATÃüÁîÓëat_ctl½øÐн»»¥£¬½ø¶øÊµÏÖÓû§¶ÔsoftapµÄͳһ»¯¿ØÖÆ
+*À©Õ¹ATÃüÁîÓësoftapi¶ÔÍâÌṩµÄapiÏûÏ¢Ò»Ò»¶ÔÓ¦£¬ATÃüÁîµÄ¾ßÌå²ÎÊý£¬±£³ÖÓëÏûÏ¢ÌåÄÚÈÝÍêȫһÖÂ
+
+* ºóÐøÐÂÔöÀ©Õ¹ATÃüÁî×¢²á£¬¿ÉÒԲο¼ÈçÏ´úÂëʵÏÖ
+**********************************************************************************/
+#include "softap_api.h"
+#include "at_com.h"
+#include "at_context.h"
+
+int g_atv = 0;
+int g_atq = 0;
+int g_at_d = 0;
+
+/* ½«À©Õ¹ATÃüÁî²ÎÊý½âÎö³Éreq_msg_id¶ÔÓ¦µÄÏûÏ¢½á¹¹Ì壬Èç¹ûÏûϢûÓÐÄÚÈÝ£¬res_msg=NULL£¬res_msglen=0
+·µ»ØAT_END_AND_MSG£¬ÓÉ¿ò¼ÜÍùat_fdÖÐд\r\nOK\r\n£¬²¢½«req_msg_id·¢Ë͵½·þÎñ¶Ëapp*/
+struct wifi_opt
+{
+ int status;
+};
+
+char * wlan_auth[] =
+{
+ "OPEN",
+ "WPAPSK",
+ "WPA2PSK",
+ "WPAPSKWPA2PSK",
+ "WPA3Personal",
+ "WPA2WPA3",
+};
+
+char * wlan_encrp[] =
+{
+ "NONE",
+ "TKIP",
+ "AES",
+ "TKIPAES",
+};
+
+#if (APP_OS_TYPE == APP_OS_TOS)
+extern SINT32 mmiLcReset(VOID);
+extern UINT32 zOss_ResetNVFactory(VOID);
+#endif
+
+//»Ö¸´³ö³§ÉèÖÃ
+void ext_reset_proc()
+{
+#if (APP_OS_TYPE == APP_OS_TOS)
+#if (PRODUCT_TYPE == PRODUCT_PHONE)
+ mmiLcReset();
+#else
+ zOss_ResetNVFactory();
+#endif
+ //send_soc_msg(FAR_PS, MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_RSP, 0, NULL);
+ platform_send_msg(MODULE_ID_CP_AT_CTL,MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_RSP, 0, NULL);
+#endif
+}
+
+/*
+typedef int (*ser_req_func)(int at_fd, char *at_paras, void ** res_msg, int *res_msglen);
+*/
+int ext_wifi_switch_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ char *opt = (char *)malloc(sizeof(int));
+ if(opt == NULL)
+ return AT_END;
+ memset(opt, 0 , sizeof(int));
+ strcpy(opt, at_paras);
+ printf("at_paras=%s, opt=%s\n", at_paras, opt);
+ *res_msg = opt;
+ *res_msglen = strlen(opt);
+ return AT_CONTINUE;
+}
+
+/*
+typedef int (*app_rsp_proc)(void *rsp_msg, void**ret, int *retlen);
+
+*/
+int ext_wifi_operate_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+
+ char *at_str = NULL;
+
+ if(AT_RSP_ERR == atoi(rsp_msg))
+ {
+ at_str = at_err_build(ATERR_PROC_FAILED);
+ }
+ else
+ {
+ at_str = at_ok_build();
+
+ }
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+
+ return AT_END;
+}
+
+int ext_wifi_cfg_ssid_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ wlan_basic_info *opt = (wlan_basic_info *)malloc(sizeof(wlan_basic_info));
+ if(opt == NULL)
+ return AT_END;
+ memset(opt, 0 , sizeof(wlan_basic_info));
+ void *p[1] = {opt->ssid};
+ parse_param2("%s", at_paras, p);
+
+ printf("ssid=%s,auth=%s, encrypt=%s, pwd=%s, max_access=%s, hidessid=%s\n",opt->ssid, opt->authmode, opt->encrypt, opt->pwd, opt->max_access_num, opt->hidessid);
+ *res_msg = opt;
+ *res_msglen = sizeof(wlan_basic_info);
+ return AT_CONTINUE;
+}
+
+int ext_wifi_cfg_auth_req(int at_fd, char *at_paras,void ** res_msg, int *res_msglen)
+{
+ wlan_basic_info *opt = (wlan_basic_info *)malloc(sizeof(wlan_basic_info));
+ if(opt == NULL)
+ return AT_END;
+ memset(opt, 0 , sizeof(wlan_basic_info));
+
+ void *p[3] = {opt->authmode, opt->encrypt, opt->pwd};
+ parse_param2("%20s,%10s,%65s", at_paras, p);
+
+ unsigned int auth_index = atoi(opt->authmode);
+ unsigned int encrp_index = atoi(opt->encrypt);
+ if(auth_index < (sizeof(wlan_auth)/sizeof(char *)) && encrp_index < (sizeof(wlan_encrp)/sizeof(char *))){
+ sprintf(opt->authmode, "%s", wlan_auth[auth_index]);
+ sprintf(opt->encrypt, "%s", wlan_encrp[encrp_index]);
+ }
+ printf("ssid=%s,auth=%s, encrypt=%s, pwd=%s, max_access=%s, hidessid=%s\n",opt->ssid, opt->authmode, opt->encrypt, opt->pwd, opt->max_access_num, opt->hidessid);
+
+
+ *res_msg = opt;
+ *res_msglen = sizeof(wlan_basic_info);
+ return AT_CONTINUE;
+}
+
+
+int ext_reset_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ restart_info *opt = (restart_info *)malloc(sizeof(restart_info));
+ if(opt == NULL)
+ return AT_END;
+ memset(opt, 0 , sizeof(restart_info));
+ opt->action = Restart_Action_RESET;
+ opt->subaction = Operate_By_MCU;
+ printf("ext_reset_req action=%d,subaction=%d\n",opt->action, opt->subaction);
+ *res_msg = opt;
+ *res_msglen = sizeof(restart_info);
+ return AT_CONTINUE;
+}
+
+int ext_restart_req(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
+{
+ restart_info *opt = (restart_info *)malloc(sizeof(restart_info));
+ if(opt == NULL)
+ return AT_END;
+ memset(opt, 0 , sizeof(restart_info));
+ void *p[2] = {&opt->action, &opt->subaction};
+
+ parse_param2("%d,%d", at_paras, p);
+
+ if (3 != strlen(at_paras) || opt->action < Restart_Action_RESTART || opt->action > Restart_Action_RESET || opt->subaction < Operate_By_MCU || opt->subaction > Operate_By_SOC)
+ {
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);
+ *res_msglen = strlen(*res_msg);
+ return AT_END;
+ }
+
+ printf("ext_restart_req action=%d,subaction=%d ,len=%d \n",opt->action, opt->subaction,strlen(at_paras));
+ *res_msg = opt;
+ *res_msglen = sizeof(restart_info);
+ return AT_CONTINUE;
+}
+
+int ext_restart_rsp(void *rsp_msg, void**ret, int *retlen)
+{
+ char *at_str = NULL;
+
+ at_str = at_ok_build();
+
+ *ret = at_str;
+ *retlen = strlen(at_str);
+
+ return AT_END;
+}
+
+int ext_tc_control_func(char *at_paras, void ** res_msg)
+{
+ int ret = 0;
+ struct tc_control_info my_tc_info = {0};
+ void *p[2] = {&my_tc_info.tc_downlink,&my_tc_info.tc_uplink};
+ ret = parse_param("%d,%d", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ return AT_END;
+ ipc_send_message(MODULE_ID_AT_CTL,MODULE_ID_MAIN_CTRL,MSG_CMD_NET_TC_CTRL,sizeof(struct tc_control_info), (unsigned char *)&my_tc_info,0);
+ return AT_CONTINUE;
+}
+
+int ext_atv_set_func(char *at_paras, void ** res_msg)
+{
+ if(at_paras && strlen(at_paras) <= 1)
+ {
+ if(*at_paras == '\0' || *at_paras == '0')
+ {
+ g_atv = 1;
+ return AT_END;
+ }
+ else if( *at_paras == '1')
+ {
+ g_atv = 0;
+ return AT_END;
+ }
+ }
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);;
+ return AT_END;
+}
+
+int ext_atq_set_func(char *at_paras, void ** res_msg)
+{
+ if(at_paras && strlen(at_paras) <= 1)
+ {
+ if(*at_paras == '\0' || *at_paras == '0')
+ {
+ g_atq = 0;
+ return AT_END;
+ }
+ else if( *at_paras == '1')
+ {
+ g_atq = 1;
+ return AT_END;
+ }
+ }
+ *res_msg = at_err_build(ATERR_PARAM_INVALID);;
+ return AT_END;
+}
+
+int ext_at_w_set_func(char *at_paras, void ** res_msg)
+{
+ char nv_atv[12] = {0};
+ char nv_atq[12] = {0};
+ char nv_at_d[12] = {0};
+
+ snprintf(nv_atv,12,"%d",g_atv);
+ snprintf(nv_atq,12,"%d",g_atq);
+ snprintf(nv_at_d,12,"%d",g_at_d);
+
+ cfg_set("at_atv", nv_atv);
+ cfg_set("at_atq", nv_atq);
+ cfg_set("at_at_d", nv_at_d);
+ cfg_save();
+
+ return AT_END;
+}
+
+int ext_at_d0_set_func(char *at_paras, void ** res_msg)
+{
+ g_at_d = 0;
+ return AT_END;
+}
+
+int ext_at_d1_set_func(char *at_paras, void ** res_msg)
+{
+ g_at_d = 1;
+ return AT_END;
+}
+
+int ext_at_d2_set_func(char *at_paras, void ** res_msg)
+{
+ g_at_d = 2;
+ return AT_END;
+}
+
+int ext_at_mac_manage_set_func(char *at_paras, void ** res_msg)
+{
+ char *at_str = malloc(64);
+ int ret = -1;
+ char n1[10] = {0};
+ char n2[10] = {0};
+ char n3[18] = {0};
+ void *p[] = {n1,n2,n3};
+ ret = parse_param("%s,%s,%s", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ {
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",ret);
+ return AT_END;
+ }
+ if(strcmp(n1,"read") == 0)
+ {
+ if(strcmp(n2,"wlan") == 0)
+ {
+ char wifi_wlan[18] = {0};
+ cfg_get_item("mac_wlan0", wifi_wlan, sizeof(wifi_wlan));
+ sprintf(at_str,"\r\n+MAC_MANAGE: %s\r\nOK\r\n",wifi_wlan);
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);
+ }
+ else if(strcmp(n1,"write") == 0)
+ {
+ if(strcmp(n2,"wlan") == 0)
+ {
+ char wifi_wlan[20] = {0};
+ sprintf(wifi_wlan,"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
+ n3[0],n3[1],n3[2],n3[3],n3[4],n3[5],n3[6],n3[7],n3[8],n3[9],n3[10],n3[11]);
+ cfg_set("mac_wlan0", wifi_wlan);
+ cfg_save();
+ sprintf(at_str,"\r\nOK\r\n");
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",101);
+
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",102);
+
+ *res_msg = at_str;
+ return AT_END;
+}
+
+int ext_at_wifi_info_set_func(char *at_paras, void ** res_msg)
+{
+ char *at_str = malloc(64);
+ int ret = -1;
+ char n1[10] = {0};
+ char n2[18] = {0};
+ void *p[] = {n1,n2};
+ ret = parse_param("%s,%s", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ {
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",ret);
+ return AT_END;
+ }
+ if(strcmp(n1,"read") == 0)
+ {
+ if(strcmp(n2,"host_ssid_2.4G") == 0)
+ {
+ char wifi_ssid[18] = {0};
+ cfg_get_item("SSID1", wifi_ssid, sizeof(wifi_ssid));
+ sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_ssid);
+ }
+ else if(strcmp(n2,"host_passwd_2.4G") == 0)
+ {
+ char wifi_wpapsk[18] = {0};
+ cfg_get_item("WPAPSK1", wifi_wpapsk, sizeof(wifi_wpapsk));
+ sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_wpapsk);
+ }
+ else if(strcmp(n2,"host_ssid_5G") == 0)
+ {
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);
+ }
+ else if(strcmp(n2,"host_passwd_5G") == 0)
+ {
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);
+ }
+ else if(strcmp(n2,"guest_ssid") == 0)
+ {
+ char wifi_ssid[18] = {0};
+ cfg_get_item("SSID1", wifi_ssid, sizeof(wifi_ssid));
+ sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_ssid);
+ }
+ else if(strcmp(n2,"guest_passwd") == 0)
+ {
+ char wifi_wpapsk[18] = {0};
+ cfg_get_item("WPAPSK1", wifi_wpapsk, sizeof(wifi_wpapsk));
+ sprintf(at_str,"\r\n+WIFI_INFO: %s\r\nOK\r\n",wifi_wpapsk);
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",102);
+
+ *res_msg = at_str;
+ return AT_END;
+}
+
+int ext_at_flag_manage_set_func(char *at_paras, void ** res_msg)
+{
+ char *at_str = malloc(64);
+ int ret = -1;
+ char n1[10] = {0};
+ char n2[16] = {0};
+ char n3[18] = {0};
+ void *p[] = {n1,n2,n3};
+ ret = parse_param("%s,%s,%s", at_paras, p);
+ if (ret != AT_PARSE_OK)
+ {
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",ret);
+ return AT_END;
+ }
+ if(strcmp(n1,"read") == 0)
+ {
+ if(strcmp(n2,"wifi_ft") == 0)
+ {
+ char wifi_wlan[18] = {0};
+ cfg_get_item("wifi_ft", wifi_wlan, sizeof(wifi_wlan));
+ sprintf(at_str,"\r\n+FLAG_MANAGE: %s\r\nOK\r\n",wifi_wlan);
+ }
+ else if(strcmp(n2,"wifi_coupling") == 0)
+ {
+ char wifi_wlan[18] = {0};
+ cfg_get_item("wifi_coupling", wifi_wlan, sizeof(wifi_wlan));
+ sprintf(at_str,"\r\n+FLAG_MANAGE: %s\r\nOK\r\n",wifi_wlan);
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",100);
+ }
+ else if(strcmp(n1,"write") == 0)
+ {
+ if(strcmp(n2,"wifi_ft") == 0)
+ {
+ cfg_set("wifi_ft", n3);
+ cfg_save();
+ sprintf(at_str,"\r\nOK\r\n");
+ }
+ else if(strcmp(n2,"wifi_coupling") == 0)
+ {
+ cfg_set("wifi_coupling", n3);
+ cfg_save();
+ sprintf(at_str,"\r\nOK\r\n");
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",101);
+
+ }
+ else
+ sprintf(at_str,"\r\n+CME ERROR: %d\r\n",102);
+
+ *res_msg = at_str;
+ return AT_END;
+}
+
+void ext_notelcom_regist()
+{
+ register_serv_func2("ZWIFI=", MODULE_ID_WIFI,
+ MSG_CMD_WIFI_SWITCH_REQ,
+ MSG_CMD_WIFI_SWITCH_RSP,
+ ext_wifi_switch_req, ext_wifi_operate_rsp);
+ register_serv_func2("ZWSSID=", MODULE_ID_WIFI,
+ MSG_CMD_WIFI_CFG_SSID_REQ,
+ MSG_CMD_WIFI_CFG_SSID_RSP,
+ ext_wifi_cfg_ssid_req, ext_wifi_operate_rsp);
+ register_serv_func2("ZWAUTH=", MODULE_ID_WIFI,
+ MSG_CMD_WIFI_CFG_PWD_REQ,
+ MSG_CMD_WIFI_CFG_PWD_RSP,
+ ext_wifi_cfg_auth_req, ext_wifi_operate_rsp);
+
+
+ register_serv_func2("ZRESET",MODULE_ID_MAIN_CTRL,MSG_CMD_RESET_REQUEST,MSG_CMD_RESTART_RSP,ext_reset_req,ext_restart_rsp);//½ö¹©Éú²ú²âÊÔÓÃ
+ register_serv_func2("ZRESTART=",MODULE_ID_MAIN_CTRL,MSG_CMD_RESTART_REQUEST,MSG_CMD_RESTART_RSP,ext_restart_req,ext_restart_rsp);//ZRESTART=0,0,²ÎÊý1±íʾRESET /RESTART£¬²ÎÊý2±íʾʵ¼ÊÖØÆô²Ù×÷ÊÇ·ñÓɱ¾ºË×Ô¼ºÊµÏÖ
+ register_serv_func("TC_CONTROL=",MODULE_ID_MAIN_CTRL,ext_tc_control_func);
+ register_serv_func("ATV", 0, ext_atv_set_func);
+ register_serv_func("ATQ", 0, ext_atq_set_func);
+ register_serv_func("W", 0, ext_at_w_set_func);
+ register_serv_func("W0", 0, ext_at_w_set_func);
+ register_serv_func("D", 0, ext_at_d0_set_func);
+ register_serv_func("D0", 0, ext_at_d0_set_func);
+ register_serv_func("D1", 0, ext_at_d1_set_func);
+ register_serv_func("D2", 0, ext_at_d2_set_func);
+ register_serv_func("mac_manage=", 0, ext_at_mac_manage_set_func);
+ register_serv_func("wifi_info=", 0, ext_at_wifi_info_set_func);
+ register_serv_func("flag_manage=", 0, ext_at_flag_manage_set_func);
+}
+
+void at_comm_init(void)
+{
+ char nv_atv[8] = {0};
+ char nv_atq[8] = {0};
+ char nv_at_d[8] = {0};
+
+ cfg_get_item("at_atv", nv_atv, sizeof(nv_atv));
+ cfg_get_item("at_atq", nv_atq, sizeof(nv_atq));
+ cfg_get_item("at_at_d", nv_at_d, sizeof(nv_at_d));
+ g_atv = atoi(nv_atv);
+ if(g_atv < 0 || g_atv > 1) {
+ g_atv = 0;
+ }
+ g_atq = atoi(nv_atq);
+ if(g_atq < 0 || g_atq > 1) {
+ g_atq = 0;
+ }
+ g_at_d = atoi(nv_at_d);
+ if(g_at_d < 0 || g_at_d > 2) {
+ g_at_d = 0;
+ }
+ at_print(AT_NORMAL, "atv:%d, atq:%d, at&d:%d \n", g_atv, g_atq, g_at_d);
+}
+
diff --git a/lynq/R305/ap/app/zte_comm/schedule_restart/Makefile b/lynq/R305/ap/app/zte_comm/schedule_restart/Makefile
new file mode 100755
index 0000000..096ce19
--- /dev/null
+++ b/lynq/R305/ap/app/zte_comm/schedule_restart/Makefile
@@ -0,0 +1,41 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC = schedule_restart
+OBJS = schedule_restart.o
+
+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -I$(zte_lib_path)/libnvram
+CFLAGS += -I$(zte_lib_path)/libsqlite
+CFLAGS += -I$(zte_lib_path)/libsoftap
+CFLAGS += -g
+CFLAGS += -g -Werror=implicit-function-declaration
+
+ifeq ($(CUSTOM_MODEL), MF29S2)
+CFLAGS += -DCUSTOM_VERSION_MF29S2_ZTE
+endif
+
+LDLIBS = -lpthread -lm
+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram
+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+all: $(EXEC)
+
+$(EXEC): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^ -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) $(EXEC) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
diff --git a/lynq/R305/ap/app/zte_comm/schedule_restart/schedule_restart.c b/lynq/R305/ap/app/zte_comm/schedule_restart/schedule_restart.c
new file mode 100755
index 0000000..b1e5843
--- /dev/null
+++ b/lynq/R305/ap/app/zte_comm/schedule_restart/schedule_restart.c
@@ -0,0 +1,142 @@
+#include "schedule_restart.h"
+
+void cfg_get_sntp_time(sntp_time * s_time)
+{
+ char sntp_nv_value[20] = {0};
+ if(!s_time)
+ {
+ return;
+ }
+
+ cfg_get_item("sntp_process_result", s_time->result, sizeof(s_time->result));
+
+ if(0 == strcmp("success", s_time->result))
+ {
+ cfg_get_item("sntp_day", sntp_nv_value, sizeof(sntp_nv_value));
+ s_time->day = atoi(sntp_nv_value);
+
+ cfg_get_item("sntp_hour", sntp_nv_value, sizeof(sntp_nv_value));
+ s_time->hour = atoi(sntp_nv_value);
+
+ cfg_get_item("sntp_minute", sntp_nv_value, sizeof(sntp_nv_value));
+ s_time->minute = atoi(sntp_nv_value);
+
+ cfg_get_item("sntp_weekday", s_time->weekday, sizeof(s_time->weekday));
+ }
+
+ return;
+}
+
+void cfg_get_schedule_restart_config(schedule_restart_config * config)
+{
+ char schedule_restart_nv_value[20] = {0};
+ if(!config)
+ {
+ return;
+ }
+
+ cfg_get_item("schedule_restart_enable", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));
+ config->enable = atoi(schedule_restart_nv_value);
+
+ if(config->enable)
+ {
+ cfg_get_item("schedule_restart_option", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));
+ if(0 == strcmp("everyweek", schedule_restart_nv_value))
+ {
+ config->option = EVERY_WEEK;
+ }
+ else if(0 == strcmp("everymonth", schedule_restart_nv_value))
+ {
+ config->option = EVERY_MONTH;
+ }
+ else if(0 == strcmp("everyday", schedule_restart_nv_value))
+ {
+ config->option = EVERY_DAY;
+ }
+
+ cfg_get_item("schedule_restart_day", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));
+ config->day = atoi(schedule_restart_nv_value);
+
+ cfg_get_item("schedule_restart_hour", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));
+ config->hour = atoi(schedule_restart_nv_value);
+
+ cfg_get_item("schedule_restart_minute", schedule_restart_nv_value, sizeof(schedule_restart_nv_value));
+ config->minute = atoi(schedule_restart_nv_value);
+
+ cfg_get_item("schedule_restart_weekday", config->weekday, sizeof(config->weekday));
+ }
+
+ return;
+}
+
+void get_sntp_and_schedule_info(sntp_time * s_time, schedule_restart_config * config)
+{
+ if(!s_time || !config)
+ {
+ return;
+ }
+
+ cfg_get_sntp_time(s_time);
+ cfg_get_schedule_restart_config(config);
+
+ return;
+}
+
+void send_restart_request()
+{
+ ipc_send_message(MODULE_ID_AT_CTL, MODULE_ID_MAIN_CTRL, MSG_CMD_RESTART_REQUEST, 0, NULL,0);
+
+ return;
+}
+
+void check_and_restart(const sntp_time *sntp_time, const schedule_restart_config *config)
+{
+ if(!config->enable || (0 != strcmp("success", sntp_time->result)))
+ {
+ return;
+ }
+
+ if(sntp_time->hour == config->hour && sntp_time->minute == config->minute)
+ {
+ switch(config->option)
+ {
+ case EVERY_DAY:
+ send_restart_request();
+ break;
+ case EVERY_WEEK:
+ if(0 == strcmp(sntp_time->weekday, config->weekday))
+ {
+ send_restart_request();
+ }
+ break;
+ case EVERY_MONTH:
+ if(sntp_time->day == config->day)
+ {
+ send_restart_request();
+ }
+ break;
+ }
+ }
+
+ return;
+}
+
+void schedule_restart_proc()
+{
+ sntp_time s_time;
+ schedule_restart_config config;
+
+ while(1)
+ {
+ get_sntp_and_schedule_info(&s_time, &config);
+ check_and_restart(&s_time, &config);
+ sleep(60);
+ }
+}
+
+int schedule_restart_main(int argc, char * argv[])
+{
+ schedule_restart_proc();
+
+ return 0;
+}
\ No newline at end of file
diff --git a/lynq/R305/ap/app/zte_comm/schedule_restart/schedule_restart.h b/lynq/R305/ap/app/zte_comm/schedule_restart/schedule_restart.h
new file mode 100755
index 0000000..c4d662f
--- /dev/null
+++ b/lynq/R305/ap/app/zte_comm/schedule_restart/schedule_restart.h
@@ -0,0 +1,31 @@
+#ifndef __SCHEDULE_RESTART__
+#define __SCHEDULE_RESTART__
+
+#include "softap_api.h"
+#include "cfg_api.h"
+#include "message.h"
+
+typedef struct {
+ int day;
+ int hour;
+ int minute;
+ char weekday[4];
+ char result[20];
+} sntp_time;
+
+typedef enum {
+ EVERY_DAY,
+ EVERY_WEEK,
+ EVERY_MONTH
+} restart_option;
+
+typedef struct {
+ int enable;
+ restart_option option;
+ int day;
+ int hour;
+ int minute;
+ char weekday[4];
+} schedule_restart_config;
+
+#endif
\ No newline at end of file
diff --git a/lynq/R305/ap/app/zte_ufi/Makefile b/lynq/R305/ap/app/zte_ufi/Makefile
new file mode 100755
index 0000000..2a97bda
--- /dev/null
+++ b/lynq/R305/ap/app/zte_ufi/Makefile
@@ -0,0 +1,322 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************
+include $(zte_app_mak)
+#include ../net_team.mk
+include $(COMMON_MK)
+
+CPU_PUB_ROOT=$(TOPDIR_AP)/../pub
+##############USER COMIZE BEGIN################
+EXEC = zte_ufi
+EXEC1 = zte-rtc-clock
+EXEC2 = router_msg_proxy
+OBJS = zte_ufi.o ../zte_comm/nvserver/nvserver.o ../zte_comm/nvserver/nvupdate.o \
+ $(patsubst %.c,%.o,$(wildcard ../zte_comm/at_ctl/src/atctrl/*.c ../zte_comm/at_ctl/src/atconfig/*.c ../zte_comm/at_ctl/src/phone/*.c ../zte_comm/at_ctl/src/phone/src/*.c)) \
+ ../zte_comm/rtc-service/rtc-service.o \
+ $(filter-out ../zte_comm/zte_mainctrl/router_msg_proxy.o,$(patsubst %.c,%.o,$(wildcard ../zte_comm/zte_mainctrl/*.c))) \
+ ../zte_comm/zte_hotplug/hotplug.o ../zte_comm/zte_hotplug/netdev_plug.o ../zte_comm/zte_hotplug/drv_plug.o \
+ $(patsubst %.c,%.o,$(wildcard ../zte_comm/zte_drv_ctrl/usb/*.c ../zte_comm/zte_drv_ctrl/serial/*.c)) \
+ ../zte_comm/fluxstat/fluxstat.o \
+ ../zte_comm/sntp/sntp.o \
+ ../zte_comm/schedule_restart/schedule_restart.o \
+ $(patsubst %.c,%.o,$(wildcard ../zte_comm/sms/src/*.c ))
+ifeq ($(USE_FOTA),yes)
+OBJS += $(patsubst %.c,%.o,$(wildcard ../zte_comm/fota_dm/src/*.c ))
+endif
+OBJS += $(patsubst %.c,%.o,$(wildcard ../zte_comm/phonebook/src/*.c )) ../zte_comm/zte_audio_ctrl/audio_res_ctrl.o
+
+OBJS1 = ../zte_comm/rtc-service/zte-rtc-clock.o
+OBJS2 = ../zte_comm/zte_mainctrl/router_msg_proxy.o
+
+ZTE_MMI_DEP = zte_mmi_app
+ZTE_MMI_TOBJS = mmi_adapter.o mmi.o mmi_battery.o mmi_net.o mmi_wifi.o mmi_tip.o mmi_sms.o mmi_lcd_page.o mmi_lcd.o mmi_lcd_init.o mmi_ctrl.o \
+ mmi_keystrokes.o mmi_lcd_timer.o mmi_led.o mmi_led_init.o mmi_led_adapter.o mmi_poweroff_charger.o mmi_traffic.o mmi_fota.o mmi_msg.o \
+ mmi_cfg.o mmi_poweroff.o mmi_battery_adapter.o mmi_mo.o mmi_mo_en.o mmi_mo_zh.o mmi_voip.o mmi_plat_adapter.o
+ZTE_MMI_OBJS = $(addprefix ../zte_comm/zte_mmi/,$(ZTE_MMI_TOBJS))
+
+ZTE_LOCKNET_DEP = zte_locknet_app
+ZTE_LOCKNET_OBJS = $(patsubst %.c,%.o,$(wildcard ../zte_comm/zte_locknet/src/*.c ))
+
+ZTE_WATCHDOG_DEP = zte_watchdog_app
+ZTE_WATCHDOG_TOBJS = watchdog.o watchdog_adapter.o watchdog_battery.o
+ZTE_WATCHDOG_OBJS = $(addprefix ../zte_comm/zte_watchdog/,$(ZTE_WATCHDOG_TOBJS))
+
+#wifi
+ifeq ($(CONFIG_WIFI_MODULE),realtek)
+CFLAGS += -D__REALTEK_8192_CHIP__
+ifeq ($(CONFIG_WIFI_RTL_WPA2),yes)
+tools_dir += ../zte_comm/wlan/realtek_tools_wpa2/auth ../zte_comm/wlan/realtek_tools_wpa2/mini_upnp ../zte_comm/wlan/realtek_tools_wpa2/utility
+tools_dir += ../zte_comm/wlan/realtek_tools_wpa2/wsc ../zte_comm/wlan/realtek_tools_wpa2/wireless_tools.25
+else
+tools_dir += ../zte_comm/wlan/realtek_tools/auth ../zte_comm/wlan/realtek_tools/mini_upnp ../zte_comm/wlan/realtek_tools/utility
+tools_dir += ../zte_comm/wlan/realtek_tools/wsc ../zte_comm/wlan/realtek_tools/wireless_tools.25
+endif
+else ifeq ($(CONFIG_WIFI_MODULE),rda5995)
+CFLAGS += -D__RDA_5995_CHIP__
+tools_dir += ../zte_comm/wlan/rda_tools
+else ifeq ($(CONFIG_WIFI_MODULE),esp8089)
+CFLAGS += -D__ESP_8089_CHIP__
+tools_dir += ../zte_comm/wlan/esp_tools/eagle_test ../zte_comm/wlan/esp_tools/fcctest
+else ifeq ($(CONFIG_WIFI_MODULE),xr819)
+CFLAGS += -D__XR_819_CHIP__
+#tools_dir +=
+else ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)
+CFLAGS += -D__SSV_6X5X_CHIP__
+#tools_dir +=
+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)
+CFLAGS += -D__AIC_8800DW_CHIP__
+tools_dir += ../zte_comm/wlan/aic_tools/rftest
+ifeq ($(CONFIG_WIFI_SINGLEAP), no)
+CFLAGS += -D__MULTI_AP__
+endif
+endif
+
+$(warning CONFIG_WIFI_FUNCTION=$(CONFIG_WIFI_FUNCTION))
+
+ifeq ($(findstring sta,$(CONFIG_WIFI_FUNCTION)), sta)
+WLAN_STA_FUNC=yes
+endif
+
+ifeq ($(findstring ap,$(CONFIG_WIFI_FUNCTION)), ap)
+WLAN_AP_FUNC=yes
+endif
+
+CFLAGS += -D__QRCODE_WIFI__
+CFLAGS += -D__USE_AES__
+
+ifeq ($(WLAN_STA_FUNC),yes)
+CFLAGS += -D__STA_FUNC__
+ifneq ($(WLAN_AP_FUNC),yes)
+ifeq ($(CONFIG_WIFI_MODULE),aic8800)
+CFLAGS += -I$(zte_app_path)/wpa_supplicant-2.10/src/common
+LDLIBS += -lwpa_client -L$(zte_app_path)/wpa_supplicant-2.10/wpa_supplicant
+else
+CFLAGS += -I$(zte_app_path)/wpa_supplicant-2.6/src/common
+LDLIBS += -lwpa_client -L$(zte_app_path)/wpa_supplicant-2.6/wpa_supplicant
+endif
+endif
+endif
+ifeq ($(WLAN_AP_FUNC),yes)
+CFLAGS += -D__AP_FUNC__
+ifeq ($(CONFIG_WIFI_MODULE),aic8800)
+CFLAGS += -I$(zte_app_path)/hostapd-2.10/src/common
+LDLIBS += -lwpa_client -L$(zte_app_path)/hostapd-2.10/hostapd
+else
+CFLAGS += -I$(zte_app_path)/hostapd-2.6/src/common
+LDLIBS += -lwpa_client -L$(zte_app_path)/hostapd-2.6/hostapd
+endif
+endif
+
+OBJS += ../zte_comm/wlan/src/wlan_main.o ../zte_comm/wlan/src/wifi_socket.o ../zte_comm/wlan/src/wlan_rtc_sleep.o ../zte_comm/wlan/src/wifi_drv_ko.o \
+ ../zte_comm/wlan/src/wifi_sta_ctrl.o ../zte_comm/wlan/src/wifi_util.o ../zte_comm/wlan/src/wlan_config_ssid.o ../zte_comm/wlan/src/wlan_netlink.o ../zte_comm/wlan/src/Vector.o
+ifeq ($(CONFIG_WIFI_MODULE),realtek)
+OBJS += ../zte_comm/wlan/src/wifi_hal.o
+ ifeq ($(WLAN_STA_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wlan-station.o
+ endif
+LDLIBS += -lwlan_interface
+LDLIBS += -L$(zte_lib_path)/libwlan_interface
+else ifeq ($(CONFIG_WIFI_MODULE),rda5995)
+ ifeq ($(WLAN_STA_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wlan_sta_manager.o ../zte_comm/wlan/src/wlan_sm.o
+ endif
+
+ ifeq ($(WLAN_AP_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o
+LDLIBS += -lwlan_interface
+LDLIBS += -L$(zte_lib_path)/libwlan_interface
+ endif
+else ifeq ($(CONFIG_WIFI_MODULE),esp8089)
+ ifeq ($(WLAN_STA_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wlan_sta_manager.o ../zte_comm/wlan/src/wlan_sm.o
+ endif
+
+ ifeq ($(WLAN_AP_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o
+LDLIBS += -lwlan_interface
+LDLIBS += -L$(zte_lib_path)/libwlan_interface
+ endif
+else ifeq ($(CONFIG_WIFI_MODULE),xr819)
+ ifeq ($(WLAN_STA_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wlan_sta_manager.o ../zte_comm/wlan/src/wlan_sm.o
+ endif
+
+ ifeq ($(WLAN_AP_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o
+LDLIBS += -lwlan_interface
+LDLIBS += -L$(zte_lib_path)/libwlan_interface
+ endif
+else ifeq ($(CONFIG_WIFI_MODULE),ssv6x5x)
+ ifeq ($(WLAN_STA_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wlan-station.o
+ endif
+
+ ifeq ($(WLAN_AP_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o
+LDLIBS += -lwlan_interface
+LDLIBS += -L$(zte_lib_path)/libwlan_interface
+ endif
+else ifeq ($(CONFIG_WIFI_MODULE),aic8800)
+ ifeq ($(WLAN_STA_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wlan-station.o
+ endif
+
+ ifeq ($(WLAN_AP_FUNC),yes)
+ OBJS += ../zte_comm/wlan/src/wifi_ap_ctrl.o
+LDLIBS += -lwlan_interface
+LDLIBS += -L$(zte_lib_path)/libwlan_interface
+ endif
+endif
+#aes
+CFLAGS += -I$(zte_lib_path)/libssl/install/include
+LDLIBS += -L$(zte_lib_path)/libssl/install/lib -lcrypto
+
+#ifeq ($(CONFIG_USE_WEBUI_SECURITY),yes)
+#CFLAGS += -DWEBS_SECURITY
+#endif
+#*******************************************************************************
+# include path
+#*******************************************************************************
+CFLAGS += -I./
+CFLAGS += -I../include
+CFLAGS += -I../zte_comm/nvserver
+CFLAGS += -I$(LIB_DIR)/libnvram
+CFLAGS += -I$(APP_DIR)/include
+CFLAGS += -g -Werror=implicit-function-declaration
+
+CFLAGS += -I../zte_comm/zte_hotplug
+CFLAGS += -I../zte_comm/at_ctl/inc
+CFLAGS += -I../zte_comm/at_ctl/src/phone/inc
+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -I$(zte_lib_path)/libatext
+CFLAGS += -I$(zte_lib_path)/libsqlite
+CFLAGS += -I$(zte_lib_path)/libnvram
+CFLAGS += -I$(LINUX_DIR)
+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/bl
+CFLAGS += -I$(zte_lib_path)/libzcore/std/inc/zCore/gui
+CFLAGS += -I$(CPU_PUB_ROOT)/project/zx297520v3/include/nv
+CFLAGS += -O -Dlinux=1 -DHIGH_SPEED=1
+
+
+CFLAGS += -I$(zte_lib_path)/libsoftap
+#CFLAGS += -I.
+
+
+CFLAGS += -I$(zte_lib_path)/libsoft_timer
+
+CFLAGS += -I../zte_comm/sms/inc
+CFLAGS += -I../zte_comm/phonebook/inc
+
+CFLAGS += -I../zte_comm/wlan/inc
+
+
+CFLAGS += -I../zte_comm/fota_dm/inc
+#CFLAGS += -I../zte_comm/fota_dm/gs_lib
+CFLAGS += -I../zte_comm/fota_dm/rs_lib
+CFLAGS += -I$(zte_lib_path)/libzte_dmapp/inc
+
+#*******************************************************************************
+# library
+#*******************************************************************************
+LDLIBS += -lnvram -L$(zte_lib_path)/libnvram -lpthread
+ifeq ($(LINUX_TYPE),uClinux)
+LDFLAGS += -Wl,--allow-multiple-definition,-elf2flt=-s131072
+endif
+
+
+LDLIBS += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+LDLIBS += -latutils -L$(zte_lib_path)/libatutils
+LDLIBS += -lsqlite -L$(zte_lib_path)/libsqlite
+LDLIBS += -latext -L$(zte_lib_path)/libatext
+LDLIBS += -lm
+#LDLIBS += -ltinyalsa -L$(zte_lib_path)/libtinyalsa
+LDLIBS += -lcpnv -L$(zte_lib_path)/libcpnv
+LDLIBS += -lamt -L$(zte_lib_path)/libamt
+LDLIBS += -lkey -L$(zte_lib_path)/libkey
+
+LDLIBS += -lcurl -L$(zte_lib_path)/libcurl/install/lib
+
+ifneq ($(CONFIG_MMI_LCD),no)
+LDLIBS += -lzcore
+LDLIBS += -lrt
+ifeq ($(USE_TTF_FONT), yes)
+LDLIBS += -lft2
+LDLIBS += -lttf_font
+else
+LDLIBS += -lbitmap_font
+endif
+LDLIBS += -L$(zte_lib_path)/libzcore/min
+ifeq ($(USE_TTF_FONT), yes)
+LDLIBS += -L$(zte_lib_path)/libzcore/min/prebuilts/freetype
+endif
+endif
+ifeq ($(USE_FOTA),yes)
+LDLIBS += -lztedmapp -L$(zte_lib_path)/libzte_dmapp
+#LIBSHARE_GS = ../zte_comm/fota_dm/gs_lib/libdmgr.so.1
+#LDLIBS += -L../zte_comm/fota_dm/gs_lib -ldmgr
+
+LIBSHARE_GS = ../zte_comm/fota_dm/rs_lib/librsdlsdk.so
+LDLIBS += -L../zte_comm/fota_dm/rs_lib -lrsdlsdk
+endif
+
+LDLIBS1 += -lnvram -L$(zte_lib_path)/libnvram -lpthread
+LDLIBS1 += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS1 += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+##############USER COMIZE END##################
+
+all: $(EXEC) $(EXEC1) $(EXEC2)
+ifneq ($(tools_dir), )
+ for i in $(tools_dir) ; do $(MAKE) -C $$i || exit $?; done
+endif
+ifeq ($(USE_FOTA),yes)
+ (cd ../zte_comm/fota_dm/gs_lib;rm libdmgr.so;ln -s libdmgr.so.1 libdmgr.so; cd ../../../zte_comm)
+endif
+
+$(EXEC): $(OBJS) $(ZTE_MMI_DEP) $(ZTE_LOCKNET_DEP) $(ZTE_WATCHDOG_DEP)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(ZTE_MMI_OBJS) $(ZTE_LOCKNET_OBJS) $(ZTE_WATCHDOG_OBJS) -Wl,--start-group $(LDLIBS) -Wl,--end-group
+ @cp $@ $@.elf
+
+$(EXEC1): $(OBJS1)
+ $(CC) $(CFLAGS) -o $@ $(OBJS1) -Wl,--start-group $(LDLIBS1) -Wl,--end-group
+ @cp $@ $@.elf
+
+$(EXEC2): $(OBJS2)
+ $(CC) $(CFLAGS) -o $@ $(OBJS2) -Wl,--start-group $(LDLIBS1) -Wl,--end-group
+ @cp $@ $@.elf
+
+romfs:
+ $(ROMFSINST) /sbin/$(EXEC)
+ $(ROMFSINST) /sbin/$(EXEC1)
+ $(ROMFSINST) /sbin/$(EXEC2)
+ifeq ($(USE_FOTA),yes)
+ $(ROMFSINST) $(LIBSHARE_GS) /lib/
+endif
+ifneq ($(tools_dir), )
+ for i in $(tools_dir) ; do $(MAKE) -C $$i romfs || exit $?; done
+endif
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
+ -rm -f $(EXEC1) *.elf *.gdb *.o
+ -rm -f $(EXEC2) *.elf *.gdb *.o
+ -find ../zte_comm/ -name \*.o -exec rm -rf {} \;
+ -find . -name \*.o -exec rm -rf {} \;
+ifneq ($(tools_dir), )
+ for i in $(tools_dir) ; do $(MAKE) -C $$i clean || exit $?; done
+endif
+ifeq ($(CONFIG_USER_SINGLE_DM), zx)
+ifeq ($(USE_FOTA),yes)
+ rm -rf $(ROOTFS_DIR)//bin/$(EXEC_GS)
+endif
+endif
+
+$(ZTE_MMI_DEP):
+ ${MAKE} -C ../zte_comm/zte_mmi lib
+
+$(ZTE_LOCKNET_DEP):
+ ${MAKE} -C ../zte_comm/zte_locknet lib
+
+$(ZTE_WATCHDOG_DEP):
+ ${MAKE} -C ../zte_comm/zte_watchdog lib
diff --git a/lynq/R305/ap/app/zte_ufi/zte_ufi.c b/lynq/R305/ap/app/zte_ufi/zte_ufi.c
new file mode 100755
index 0000000..e41eaab
--- /dev/null
+++ b/lynq/R305/ap/app/zte_ufi/zte_ufi.c
@@ -0,0 +1,284 @@
+#define _GNU_SOURCE /**/
+
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <time.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/sysctl.h>
+#include <net/if.h>
+#include <poll.h>
+#include <stddef.h>
+#include <linux/if_packet.h>
+#include <netinet/ether.h>
+#include <netinet/if_ether.h>
+#include <arpa/inet.h>
+#include <pthread.h>
+#include <zte_ufi.h>
+#include "softap_api.h"
+
+void nvserver_entry(void)
+{
+ nvserver_main(0,NULL);
+ return;
+}
+
+void at_ctl_entry(char *arg)
+{
+ //printf("at_ctl_entry boot:%s\n", arg);
+ char *argv[2];
+ argv[0] = NULL;
+ argv[1] = arg;
+
+ at_ctl_main(2, argv);
+ return;
+}
+
+void rtc_service_entry(char *arg)
+{
+ rtc_service_main(0,NULL);
+ return;
+}
+
+void zte_mainctrl_entry(char *arg)
+{
+ /*if (0 == strcmp(arg, "2")) {
+ char *argv[2];
+ argv[0] = NULL;
+ argv[1] = "poweroff_charger";
+
+ zte_mainctrl_main(2, argv);
+ } else {*/
+ zte_mainctrl_main(0,NULL);
+ //}
+
+ return;
+}
+
+void zte_hotplug_entry(char *arg)
+{
+ zte_hotplug_main(0,NULL);
+ return;
+}
+
+void zte_audio_res_ctrl_entry(char *arg)
+{
+ zte_audio_res_ctrl_main(0,NULL);
+ return;
+}
+
+void zte_drv_serial_ctrl_entry(char *arg)
+{
+ zte_drv_serial_ctrl_main();
+ return;
+}
+
+void zte_drv_usb_ctrl_entry(char *arg)
+{
+ if(arg)
+ zte_drv_usb_ctrl_main(3,NULL);
+ else
+ zte_drv_usb_ctrl_main(0,NULL);
+ return;
+}
+
+void zte_mmi_entry(char *arg)
+{
+ //printf("zte_mmi_entry boot:%s\n", arg);
+/* if (0 == strcmp(arg, "2")) {
+ char *argv[2];
+ argv[0] = NULL;
+ argv[1] = "poweroff_charger";
+
+ zte_mmi_main(2, argv);
+ } else {*/
+ zte_mmi_main(0,NULL);
+ //}
+ return;
+}
+
+void zte_locknet_entry(char *arg)
+{
+ zte_locknet_main(0,NULL);
+ //return; //klocwork
+}
+
+void zte_watchdog_entry(char *arg)
+{
+ zte_watchdog_main(0,NULL);
+ return;
+}
+
+void fluxstat_entry(char *arg)
+{
+ fluxstat_main(0,NULL);
+ return;
+}
+
+void sntp_entry(char *arg)
+{
+ sntp_main(0,NULL);
+ return;
+}
+
+void schedule_restart_entry(char *arg)
+{
+ schedule_restart_main(0,NULL);
+ return;
+}
+
+/*
+void sd_hotplug_entry(char *arg)
+{
+ sd_hotplug_main(0,NULL);
+ return;
+}
+*/
+void sms_entry(char *arg)
+{
+ sms_main(0,NULL);
+}
+
+void phonebook_entry(char *arg)
+{
+ phonebook_main(0,NULL);
+ return;
+}
+
+void wlan_entry(char *arg)
+{
+ wlan_main(0,NULL);
+ return;
+}
+
+#ifndef FOTA_DISABLE
+void fota_dm_entry(char *arg)
+{
+ fota_dm_main(0,NULL);
+}
+#endif
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ /* nvserver */
+ pthread_t nvserver_thread_tid;
+ pthread_create(&nvserver_thread_tid, NULL, (void *)nvserver_entry, NULL);
+
+ /* zte_hotplug */
+ pthread_t zte_hotplug_thread_tid;
+ pthread_create(&zte_hotplug_thread_tid, NULL, (void *)zte_hotplug_entry, NULL);
+
+ /* zte_drv_serial_ctrl */
+ pthread_t zte_drv_serial_ctrl_thread_tid;
+ pthread_create(&zte_drv_serial_ctrl_thread_tid, NULL, (void *)zte_drv_serial_ctrl_entry, NULL);
+ if (0 == strcmp(argv[2], "amt")) {
+ ret = cfg_set("ver_mode", "0");
+ if(ret < 0)
+ printf("zte_ufi set vermode fail\n");
+ else
+ cfg_save();
+ printf("---set ver mode to 0\n");
+ }
+ /* zte_drv_usb_ctrl */
+ pthread_t zte_drv_usb_ctrl_thread_tid;
+
+ if (0 != strcmp(argv[2], "amt")) { //³äµç»òÕý³£¿ª»úģʽ
+ char LanEnable[10] = {0};
+ /* at_ctl */
+ pthread_t at_ctl_thread_tid;
+ pthread_create(&at_ctl_thread_tid, NULL, (void *)at_ctl_entry, argv[1]);
+ /* rtc_service */
+ pthread_t rtc_service_thread_tid;
+ pthread_create(&rtc_service_thread_tid, NULL, (void *)rtc_service_entry, NULL);
+ /* zte_mainctrl */
+ pthread_t zte_mainctrl_thread_tid;
+ pthread_create(&zte_mainctrl_thread_tid, NULL, (void *)zte_mainctrl_entry, argv[1]);
+
+ /* zte_audio_res_ctrl */
+ pthread_t zte_audio_res_ctrl_thread_tid;
+ pthread_create(&zte_audio_res_ctrl_thread_tid, NULL, (void *)zte_audio_res_ctrl_entry, NULL);
+
+ cfg_get_item("LanEnable", LanEnable, sizeof(LanEnable));
+ if(atoi(LanEnable) == 1) { //mifiÐÎ̬
+ /* zte_mmi */
+ pthread_t zte_mmi_thread_tid;
+ pthread_create(&zte_mmi_thread_tid, NULL, (void *)zte_mmi_entry, argv[1]);
+ }
+
+ //if(0 != strcmp(argv[1], "2")){
+ pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
+
+ if(atoi(LanEnable) == 1) { //mifiÐÎ̬
+ /* zte_locknet */
+ pthread_t zte_locknet_thread_tid;
+ pthread_create(&zte_locknet_thread_tid, NULL, (void *)zte_locknet_entry, NULL);
+ /* fluxstat */
+
+
+ pthread_t fluxstat_thread_tid;
+ pthread_create(&fluxstat_thread_tid, NULL, (void *)fluxstat_entry, NULL);
+ /* sntp */
+ pthread_t sntp_thread_tid;
+ pthread_create(&sntp_thread_tid, NULL, (void *)sntp_entry, NULL);
+ /* schedule_restart */
+ pthread_t schedule_restart_thread_tid;
+ pthread_create(&schedule_restart_thread_tid, NULL, (void *)schedule_restart_entry, NULL);
+ /* sd_hotplug */
+ //pthread_t sd_hotplug_thread_tid;
+ //pthread_create(&sd_hotplug_thread_tid, NULL, (void *)sd_hotplug_entry, NULL);
+ //sd_hotplug_init();
+ /* sms */
+ pthread_t sms_thread_tid;
+ pthread_create(&sms_thread_tid, NULL, (void *)sms_entry, NULL);
+ /* phonebook */
+ //NV_NEED_SUPPORT_PB
+ pthread_t phonebook_thread_tid;
+ pthread_create(&phonebook_thread_tid, NULL, (void *)phonebook_entry, NULL);
+
+ /* wifi_manager */
+ pthread_t wlan_thread_tid;
+ pthread_create(&wlan_thread_tid, NULL, (void *)wlan_entry, NULL);
+
+ }
+#ifndef FOTA_DISABLE
+ /* fota_dm */
+ pthread_t fota_dm_thread_tid;
+ pthread_create(&fota_dm_thread_tid, NULL, (void *)fota_dm_entry, NULL);
+#endif
+/* }else{
+ pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, "poweroff_charger");
+ }*/
+
+
+ /* zte_watchdog */
+ pthread_t zte_watchdog_thread_tid;
+ pthread_create(&zte_watchdog_thread_tid, NULL, (void *)zte_watchdog_entry, NULL);
+ }
+ else
+ {
+ pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
+ }
+
+
+ while(1)
+ {
+ sleep(20);
+ //printf("zte app test -1 \n");
+ }
+
+ return 0;
+}
+
diff --git a/lynq/R305/ap/app/zte_ufi/zte_ufi.h b/lynq/R305/ap/app/zte_ufi/zte_ufi.h
new file mode 100755
index 0000000..014e91b
--- /dev/null
+++ b/lynq/R305/ap/app/zte_ufi/zte_ufi.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* ��Ȩ���� (C)2016, ����ͨѶ�ɷ�����˾��
+*
+* �����: zte_ufi.h
+* �ļ���ʶ: zte_ufi.h
+* ����ժҪ: ufi�ϲ�Ӧ��ͷ�ļ�
+* ʹ�÷���: #include <zte_ufi.h>
+*
+*
+*******************************************************************************/
+#ifndef _ZTE_UFI_H
+#define _ZTE_UFI_H
+
+/*******************************************************************************
+* ͷ�ļ� *
+*******************************************************************************/
+
+
+/*******************************************************************************
+* �궨�� *
+*******************************************************************************/
+
+
+/*******************************************************************************
+* �������Ͷ��� *
+*******************************************************************************/
+
+
+/*******************************************************************************
+* ȫ�ֱ������� *
+*******************************************************************************/
+
+
+/*******************************************************************************
+* ȫ�ֺ������� *
+*******************************************************************************/
+int nvserver_main(int argc, char *argv[]);
+int at_ctl_main(int argc, char * argv[]);
+int rtc_service_main(int argc, char **argv);
+int zte_mainctrl_main(int argc, char * argv[]);
+int zte_hotplug_main(int argc, char * argv[]);
+int zte_audio_res_ctrl_main(int argc, char * argv[]);
+int zte_drv_serial_ctrl_main();
+int zte_drv_usb_ctrl_main(int argc, char* argv[]);
+int zte_mmi_main(int argc, char* argv[]);
+int zte_locknet_main(int argc, char* argv[]);
+int zte_watchdog_main(int argc, char * argv[]);
+int fluxstat_main(int argc, char * argv[]);
+int sntp_main(int argc, char * argv[]);
+int schedule_restart_main(int argc, char * argv[]);
+int sd_hotplug_init(viod);
+int sd_hotplug_main(int argc, char* argv[]);
+int sms_main(int argc, char* argv[]);
+int phonebook_main(int argc, char* argv[]);
+int wlan_main (int argc, char *argv[]);
+int fota_dm_main(int argc, char**argv);
+
+
+#endif
+
diff --git a/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties b/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
new file mode 100755
index 0000000..869c34e
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/i18n/Messages_zh-cn.properties
@@ -0,0 +1,1696 @@
+#menu 中文字符
+pc_version = PC版
+mobile_version = 手机版
+home = 首页
+phonebook = 电话本
+sms = 短信
+sd = SD卡
+setting = 设置
+status = 基本信息
+net_select = 找网方式
+dial_setting = 拨号设置
+apn_setting = APN设置
+wifi_advance = 高级设置
+management = 管理
+net_setting = 联网设置
+quick_setting = 快速设置
+
+device_info = 状态信息
+traffic_statistics = 流量统计
+traffic_alert = 流量管理
+
+wifi = Wi-Fi 设置
+wifi_basic = 基本设置
+device_setting = 设备设置
+sim = SIM卡侧
+device = 设备侧
+router_setting = 路由
+mac_filter = 无线MAC过滤
+
+wps = WPS
+sleep_mode = 省电
+lan = 局域网
+
+firewall = 防火墙
+system_security = 系统安全
+port_forward = 端口转发
+port_filter = 端口过滤
+fastboot = 快速开机
+display_password = 显示密码
+display_QR = 显示二维码
+cable = 有线
+wireless = 无线
+
+my_router = 网络设置
+net_surfing = 网络连接
+
+#validate
+phonenumbers_check = 最多可输入 5 个电话号码,并且用 ';' 将号码隔开
+required = 必填项
+remote = 请修正该字段
+url = 请输入有效的网址
+siteLink_check = 请输入有效的网址
+siteName_check = 请输入有效的网站名
+date = 请输入有效的日期
+dateISO = 请输入有效的日期 (ISO)
+number = 请输入有效的数字
+digits = 只能输入整数
+decimalRange = 请输入正数且小数位最多2位
+any_digits = 只能输入整数
+creditcard = 请输入有效的信用卡号
+equalTo = 请再次输入相同的值
+accept = 请输入拥有效后缀名的字符串
+maxlength = 最多输入 {0} 个字符
+minlength = 最少输入 {0} 个字符
+rangelength = 请输入一个长度介于 {0} 和 {1} 之间的字符串
+range = 请输入一个介于{0}和{1}之间的值
+max = 请输入一个最大为 {0} 的值
+min = 请输入一个最小为 {0} 的值
+ssid = 请输入有效的 SSID
+ssid_ap = 请输入有效的 SSID(无效字符包括 , ; " \)
+email_check = 请输入有效的邮箱
+ipv4 = 请输入有效的 IP 地址
+ipv6 = 请输入有效的 IPv6 地址
+name_check = 请输入有效的姓名
+phonenumber_check = 请输入有效的电话号码
+sms_service_center_check = 请输入有效的短信中心号码
+pin_check = 请输入 4 到 8 位的数字
+puk_check = 请输入 8 位数字
+password_check = 请输入有效的密码
+subnetmask_check = 无效的子网掩码
+dns_check = 无效的 DNS,DNS不能为255.255.255.255或0.0.0.0
+dhcp_check = DHCP 的 {0}IP 超出局域网子网范围
+start = 起始
+end = 结束
+dhcpCompare = 无效的 IP 地址,起始地址不能大于结束地址
+ipRange = IP 地址池不能包含局域网 IP 地址(DHCP 起始地址应该比局域网 IP 地址大)
+lanip_check = 请输入有效的 IP 地址
+ip_check = 请输入完整且有效的 IP 地址
+dmz_ip_check = 请输入有效的 IP 地址
+wps_pin_check = 无效的 PIN
+wps_pin_length_check = 请输入4位或8位数字
+browse_sdcard = 查看 SD 卡
+portCompare = 无效的端口范围
+comment_check = 无效字符
+check_file_path = 文件夹名称中包含无效的字符
+check_filefold_name = 文件夹名称中包含无效的字符: ` ~ # & * + | \ : ? / < > . " '
+apn_check = 请输入有效的 APN
+ppp_username_check = 请输入有效的用户名
+ppp_password_check = 请输入有效的密码
+unlock_code_check = 请输入正确的解锁码。解锁码只能输入 0-9、a-f、A-F,并且长度为 16 个字符
+apn_profile_name_check = APN 配置文件名称中包含无效的字符
+dlna_name_check = 设备名称只能输入 0-9、a-z、A-Z 或 _
+wifi_password_check = 请输入有效的密码
+wifi_wep_password_check = 请输入 5 或 13 位ASCII密钥,或者输入 10 或 26 位 Hex 密钥。
+range_except = 请输入有效值,有效范围:{0}-{1}。(32000-32007 的范围值除外)。
+
+#common
+copyright = Copyright © 2010-2022 示例公司 版权所有
+enable=启用
+disable=关闭
+apply= 应用
+cancel = 取消
+clear = 清除
+reset = 重置
+add = 添加
+add_new = 新增
+save = 保存
+new = 新建
+view = 查看
+select = 选择
+edit = 编辑
+delete = 删除
+delete_all = 删除所有
+success_info = 成功
+error_info = 失败
+connect = 连接
+disconnect = 断开连接
+connected = 已连接
+disconnected = 已断开连接
+connecting = 正在连接…
+disconnecting = 正在断开连接…
+cancelconnect = 取消连接
+confirm = 确认
+prompt = 提示
+info = 信息
+alert = 提醒
+yes = 是
+no = 否
+ok = 确定
+back = 返回
+exit = 退出
+next_step = 下一步
+prev_step = 上一步
+next_page = >>
+prev_page = <<
+root = 根目录
+create = 创建
+speed = 速率
+upload = 上传
+download = 下载
+uploaded = 已上传
+downloaded = 已下载
+on = 打开
+off = 关闭
+need_login_again = 您的帐户已退出,请重新登录。
+modify = 更改
+content = 内容
+time = 时间
+processing = 处理中…
+saving = 保存中…
+deleting = 删除中…
+scanning = 状态:扫描中…
+dlna_scanning = 状态:扫描中…
+scanned = 状态:扫描结束。
+need_rescan = 状态: 需要重新扫描。
+sending = 发送中…
+creating = 创建中…
+uploading = 上传中…
+waiting = 请稍等…
+leave_page_info = 您有未保存的修改。您确定要继续吗?
+colon = :
+page = 页码:
+go = 跳转
+ALL = 全部
+open_source_licenses = 开放源代码许可
+vertical_bar = |
+
+#security
+security_policy = 安全策略
+security_mode = 安全模式
+security_mode_OPEN = OPEN
+security_mode_SHARED = SHARED
+security_mode_WPA2PSK = WPA2(AES)-PSK
+security_mode_WPAPSKWPA2PSK = WPA-PSK/WPA2-PSK
+security_mode_WPA3Personal = WPA3-Personal
+security_mode_WPA2WPA3 = WPA2(AES)/WPA3-Personal
+wpa = WPA
+pass_phrase = 密码
+
+#Station
+station_info = 接入设备
+station_number = 序号
+host_name = 主机名
+
+#Wifi Basic
+multi_ssid_enable = 多重网络名称开关
+multi_ssid_1 = 主SSID
+multi_ssid_2 = 副SSID
+multi_ssid_enable_confirm = 如果开启“多重网络名称”,Internet Wi-Fi 功能将会停用。您要继续吗?
+multi_ssid_enable_confirm2 = 如果开启“多重网络名称”,Internet Wi-Fi 功能将会停用。且已连接的 Wi-Fi 设备可能需要重连。您要继续吗?
+multi_ssid_max_access_number_alert = 主SSID 和 副SSID 的最大接入数之和不能超过 {0}!
+network_band_selection = 频段选择
+network_mode = 网络模式
+network_name = 网络名称(SSID)
+broadcast_network_name = SSID 广播
+country_region_code = 国家/地区 码
+frequency_channel = 信道
+rate = 速率
+max_station_number = 最大接入数
+wifi_basic_note = 点击“应用”时,任意已连接的 Wi-Fi 设备需要重新连接。
+wifi_disconnect_confirm = 所有已连接的 Wi-Fi 设备需要重连。您要继续吗?
+wifi_disconnect_confirm2 = 已连接的 Wi-Fi 设备可能需要重连。您要继续吗?
+network_mode_2 = 仅 802.11 n
+network_mode_4 = 802.11 b/g/n
+network_mode_5 = 仅 802.11 a
+network_mode_6 = 802.11 b/g/n/ax
+frequency_channel_0 = 自动
+frequency_channel_1 = (频道 1)
+frequency_channel_2 = (频道 2)
+frequency_channel_3 = (频道 3)
+frequency_channel_4 = (频道 4)
+frequency_channel_5 = (频道 5)
+frequency_channel_6 = (频道 6)
+frequency_channel_7 = (频道 7)
+frequency_channel_8 = (频道 8)
+frequency_channel_9 = (频道 9)
+frequency_channel_10 = (频道 10)
+frequency_channel_11 = (频道 11)
+frequency_channel_12 = (频道 12)
+frequency_channel_13 = (频道 13)
+frequency_channel_14 = (频道 14)
+frequency_channel_15 = (频道 15)
+frequency_channel_16 = (频道 16)
+frequency_channel_17 = (频道 17)
+frequency_channel_18 = (频道 18)
+frequency_channel_19 = (频道 19)
+frequency_channel_20 = (频道 20)
+frequency_channel_21 = (频道 21)
+frequency_channel_22 = (频道 22)
+frequency_channel_23 = (频道 23)
+frequency_channel_24 = (频道 24)
+frequency_channel_25 = (频道 25)
+frequency_channel_26 = (频道 26)
+frequency_channel_36 = (频道 36)
+frequency_channel_40 = (频道 40)
+frequency_channel_44 = (频道 44)
+frequency_channel_48 = (频道 48)
+frequency_channel_149 = (频道 149)
+frequency_channel_153 = (频道 153)
+frequency_channel_157 = (频道 157)
+frequency_channel_161 = (频道 161)
+frequency_channel_165 = (频道 165)
+rate_0 = 自动
+rate_1 = 1 Mbps
+rate_2 = 2 Mbps
+rate_3 = 5.5 Mbps
+rate_4 = 6 Mbps
+rate_5 = 6.5 Mbps
+rate_6 = 9 Mbps
+rate_7 = 11 Mbps
+rate_8 = 12 Mbps
+rate_9 = 13 Mbps
+rate_10 = 18 Mbps
+rate_11 = 19.5 Mbps
+rate_12 = 24 Mbps
+rate_13 = 26 Mbps
+rate_14 = 36 Mbps
+rate_15 = 39 Mbps
+rate_16 = 48 Mbps
+rate_17 = 52 Mbps
+rate_18 = 54 Mbps
+rate_19 = 58.5 Mbps
+rate_20 = 65 Mbps
+cannot_operate_when_wifi_connected = Wi-Fi 连接时无法进行该操作!
+network_mode_select_2 = 仅 802.11 n
+network_mode_select_3 = 802.11 b/g
+network_mode_select_4 = 802.11 b/g/n
+network_mode_select_6 = 802.11 b/g/n/ax
+network_modes_band_select_2 = 仅802.11 n
+network_modes_band_select_4 = 802.11 a/n
+network_modes_band_select_5 = 仅 802.11 a
+
+#net select
+auto_select = 自动
+manual_select = 手动
+auto_select_type_WCDMA_preferred = 自动
+auto_select_type_LTE_preferred = 自动
+auto_select_type_NETWORK_auto = 自动
+auto_select_type_Only_LTE = 仅4G
+auto_select_type_WCDMA_AND_LTE = 仅4G/3G
+auto_select_type_Only_WCDMA = 仅3G
+auto_select_type_TD_W = 仅3G
+auto_select_type_Only_GSM = 仅2G
+
+search = 搜索
+searching_net = 搜索中,请稍候...
+registering_net = 注册中,请稍候...
+network_list = 网络列表
+register = 注册
+auto = 自动
+unknown = 未知
+available = 可用
+current = 当前
+forbidden = 禁止
+net_select_note_automatic = 自动:该设备将会自动搜索可用网络。
+net_select_note_manual = 手动:将会手动搜索可用网络。
+net_status = 网络状态
+mccmnc = MCCMNC
+option = 选项
+networktype = 网络类型
+subnet = 制式
+
+#home
+ap_station_clear = 清空
+current_flux = 当前流量
+total_flux = 已用总流量
+connected_time = 持续时间
+flux_up = 上传速率
+flux_down = 下载速率
+traffic_current_connection = 当前连接
+traffic_current_month_data = 当月
+traffic_total_traffic = 已用总流量
+traffic_used_data_month = 本月流量使用情况:
+traffic_used_time_month = 本月上网时间:
+traffic_data_approximated = 流量仅供参考,建议向运营商查询以获得准确流量。
+traffic_used_month = 已用:
+traffic_left_month = 剩余:
+traffic_exceeded_month = 超出:
+traffic_total_month = 限额:
+traffic_apply_volume_limit = 流量管理
+traffic_data_limit_type = 套餐形式
+traffic_data = 流量
+traffic_time = 时间
+traffic_limit_data_month = 每月
+traffic_alert_when_data_reach = 提醒设置
+traffic_limit_time_month = 当月配额
+traffic_alert_when_time_reach = 提醒设置
+traffic_million_byte = MB
+traffic_percent = %
+traffic_limit_disconnect_msg = 您的流量/时间已经达到 {0}%,要断开网络连接吗?
+traffic_limit_connect_msg = 您的流量/时间已经达到 {0}%,要继续连接网络吗?
+traffic_limit_msg = 您的流量/时间已经达到 {0}%。
+traffic_beyond_disconnect_msg = 您的流量/时间已超出配额,要断开网络连接吗?
+traffic_beyond_connect_msg = 您的流量/时间已超出配额,要继续连接网络吗?
+traffic_beyond_msg = 您的流量/时间已超出配额。
+traffic_calibrate_note = 支持手动校准流量功能。如果页面流量统计与实际有偏差,您可以修改实际已用流量。
+traffic_note = 当已用流量/时间达到设置的百分比时提醒我。
+traffic_over_note = 当流量套餐单位为MB时,已使用流量的统计范围需小于4096TB。
+traffic_clear_confirm = 您确定要清除吗?
+traffic_not_support = 当前模式不支持此功能。
+
+#APN
+apn_currentApn = 当前 APN
+apn_mode = 模式
+apn_auto_apn = 自动
+apn_manual_apn = 手动
+apn_profile = 配置文件
+apn_profile_name = 配置文件名称
+apn = APN
+apn_ipv4_apn = IPv4 APN
+apn_ipv6_apn = IPv6 APN
+apn_dns_mode = DNS 模式
+apn_dns_mode_ipv4 = IPv4 DNS 模式
+apn_dns_mode_ipv6 = IPv6 DNS 模式
+apn_auto_dns = 自动
+apn_manual_dns = 手动
+apn_dns1 = DNS 1
+apn_dns2 = DNS 2
+apn_dns1_ipv4 = IPv4 DNS 1
+apn_dns2_ipv4 = IPv4 DNS 2
+apn_dns1_ipv6 = IPv6 DNS 1
+apn_dns2_ipv6 = IPv6 DNS 2
+apn_authentication = 鉴权方式
+apn_authentication_ipv4 = IPv4 鉴权方式
+apn_authentication_ipv6 = IPv6 鉴权方式
+apn_user_name = 用户名
+apn_user_name_ipv4 = IPv4 用户名
+apn_user_name_ipv6 = IPv6 用户名
+apn_password = 密码
+apn_password_ipv4 = IPv4 密码
+apn_password_ipv6 = IPv6 密码
+apn_pdp_type = PDP 类型
+set_default = 设为默认
+apn_save_profile_exist = 配置文件名称已存在,请选择其他名称。
+apn_delete_cant_delete_default = 无法删除默认配置文件。
+apn_delete_confirm = 确定删除?
+apn_cant_modify_status = 网络为 {0} 时无法更改当前的 APN 设置!
+apn_cant_modify_current = 无法更改正在使用的 APN!
+apn_cant_delete_current = 无法删除正在使用的配置文件!
+apn_profile_full = 最多只能添加 {0} 项设置!
+dial_num = 拨号号码
+apn_no_select_alert = 请选择有效的配置文件!
+
+#Status bar
+network_status = 网络状态
+connection_status = 无线宽带连接状态
+rj45_connection_status = 有线宽带连接状态
+battery = 电量
+charging = 充电中
+sim_status = SIM卡状态
+sim_status_modem_waitpin = 无效的 SIM卡
+sim_status_modem_waitpuk = 无效的 SIM卡
+sim_status_modem_sim_undetected = 无效的 SIM卡
+sim_status_modem_undetected = 无效的 SIM卡
+sim_status_modem_imsi_waitnck = 无效的 SIM卡
+sim_status_modem_sim_destroy = 无效的 SIM卡
+sim_status_modem_destroy = 无效的 SIM卡
+sim_status_modem_init_complete = 有效的 SIM卡
+sim_status_modem_ready = SIM卡就绪
+wifi_status = Wi-Fi 状态
+wifi_status_on = Wi-Fi 开
+wifi_status_off = Wi-Fi 关
+wifi_status1 = 用户数:1
+wifi_status2 = 用户数:2
+wifi_status3 = 用户数:3
+wifi_status4 = 用户数:4
+wifi_status5 = 用户数:5
+wifi_status6 = 用户数:6
+wifi_status7 = 用户数:7
+wifi_status8 = 用户数:8
+wifi_status9 = 用户数:9
+wifi_status10 = 用户数:10
+enable_pin = 启用 PIN
+remaining_time = 剩余时间
+signal = 信号
+network_type = 网络类型
+network_type_limited_service = 服务受限
+network_type_no_service = 无服务
+network_provider = 运营商
+roaming_status = 漫游状态
+sim_status_ready = SIM卡就绪
+sim_status_waitpin = 等待输入 PIN
+sim_status_waitpuk = 等待输入 PUK
+sim_status_undetected = 未检测到 SIM卡
+sim_status_waitnck = 等待输入 NCK
+sim_status_destroy = SIM卡已损毁
+signal_strength = 信号强度
+signal_strength_label = 信号强度
+battery_level = 电量
+
+#dial_setting
+dial_note = WAN 连接状态
+dial_mode = 连接模式
+dial_mode_cpe = 拨号方式
+dial_roam_info = 您尚未开启漫游设置。要开启漫游功能,请到设置页面中勾选复选框。
+dial_setting_note_automatic = 自动:开机后,设备会自动连接到网络。
+dial_setting_note_manual = 手动:开机后,设备需要手动连接到网络。
+dial_roaming_remind = 勾选此项,您可以在漫游状态下连接到网络,且可能会产生额外费用。
+dial_roaming_connect = 设备处于漫游状态,连接网络会使您的资费增加。确定继续?
+
+#phonebook
+search = 搜索
+save_location = 存储位置
+save_location_0 = SIM卡
+save_location_1 = 设备
+group_all = 全部
+group_null = -
+group_common = 普通
+group_family = 家人
+group_friend = 朋友
+group_colleague = 同事
+name = 姓名
+mobile_phone_number = 移动电话
+home_phone_number = 住宅电话
+office_phone_number = 单位电话
+mail = 邮箱
+group = 群组
+no_data_selected = 请选择一项!
+confirm_data_delete = 确定删除?
+confirm_pb_delete = 确定要删除所选联系人吗?
+too_many_data_selected = 选择电话号码过多,请选择一个电话号码!
+delete_fail_try_again = 删除失败,请重试。
+max_send_number = 最多输入 5 个电话号码!
+send = 发送
+send_sms = 发送短信
+new_message = 新短信
+send_numbers = 电话号码
+contents = 短信内容
+device_full = 设备的电话本存储空间已满!
+sim_full = SIM卡已满!
+phonebook_init_fail = 电话本初始化失败!<br/>请检查SIM卡并重启设备。
+sim_removed = SIM卡已被移除!
+change_device_to_sim_confirm = 可能会丢掉信息,是否需要继续转存?
+
+#SMS
+smslist = 设备侧短信
+sms_setting = 短信设置
+sim_messages = SIM侧短信
+refresh = 刷新
+forward = 转发
+draft = 草稿
+send_fail_try_again = 发送失败。
+sms_content_required = 请输入短信息内容。
+sms_contact_required = 请选择联系人。
+select_some_options = 最多可选择5位联系人
+select_an_option = 请选择一个选项
+chat_input_placehoder = 请在此输入信息
+sms_chat_input_confirm = 请按回车键或者用分号完成输入
+sms_capacity_will_full = 短信容量将满,请删除部分短信
+sms_capacity_is_full = 短信容量满,请删除部分短信
+sms_capacity_is_full_for_send = 短信容量满,请删掉部分短信以正常收发新信息。
+sms_capacity_will_full_just = 容量将满,您最多只能发送 {0} 条。
+sms_init_fail = 短信初始化失败!<br/>请检查SIM卡并重启设备。
+sms_resending = 正在重发短信...
+sms_resend_fail = 短信重发失败。
+sms_stop_sending = 停止发送
+sms_unread_count = 未读短信
+sms_delivery_report_1 = 短信已送达对方。
+sms_delivery_report_2 = 短信未送达对方。
+sms_delivery_report_3 = 正在发送短信...
+sms_report = 发送报告
+sms_cancel_sending = 取消中…
+sms_save_draft_success = 短信已存为草稿
+sms_save_draft_failed = 草稿保存失败
+sms_to_save_draft = 短信已修改,要存为草稿吗?
+sms_no_recipient = 您尚未选择收件人,该短信将被舍弃。
+phone_number_invalid = 电话号码无效
+sms_to = 接收人:
+confirm_sms_delete = 确定要删除所选信息吗?
+sms_save_tip = 保存草稿中...
+
+#login
+password = 密码
+puk = PUK
+login = 登录
+logout = 退出
+new_pin = 新 PIN
+confirm_pin = 确认新 PIN
+puk_locked = 您的 SIM卡已彻底锁定。请联系您的运营商。
+password_error = 密码不正确!
+password_error_left = 密码不正确!<br/>您的剩余尝试次数:{0}。
+password_error_account_lock = 你的账户被锁定。<br/>剩余时间:
+password_error_five_times = 您已经输错5次。请5分钟后再试。
+password_error_account_lock_time = 您的账户已被锁定。<br/>请稍后再试。
+enter_pin = SIM卡已锁,请输入 PIN码以解锁。
+enter_puk = SIM卡 PIN码已锁,请输入 PUK码以解锁。
+last_enter_pin = 最后尝试机会。如果再次错误,您的 SIM卡将被锁定!
+last_enter_puk = 最后尝试机会。如果再次错误,您的 SIM卡将会损毁!
+attempts_left = 剩余次数:
+pin_error = PIN码不正确!
+puk_error = PUK码不正确!
+confirm_logout = 您要注销吗?
+
+#advanced password
+password_management = 登录密码
+current_password = 当前密码
+new_password = 新密码
+confirm_password = 确认新密码
+current_password_error = 当前密码错误!
+password_note_info = 您可以在该网页更改登录密码。
+password_note_valid = 密码不能为空,且最多包含 32 个字符。
+password_note_input = 密码的有效字符包含:0-9 a-z A-Z ! # $ * + , - . % : = ? @ [ ] ^ _ { | } ~
+password_note_first_change = 请修改您的初始登陆密码!
+password_note_too_low = 您的密码复杂度太低(密码中可以包含大小写字母、数字、特殊字符,且不小于8位)。您要继续吗?
+
+#advanced pin
+pin = PIN
+current_pin = 当前 PIN
+pin_management = PIN码管理
+pin_status = PIN码状态
+modify_pin = 更改 PIN
+cannot_operate_when_connected = 网络连接时无法进行该操作!
+cannot_change_pin_when_connected = 网络连接时无法更改 PIN!
+pin_note_info = “PIN码管理”提供PIN保密设置功能,防止对SIM/USIM/UIM卡的非授权使用。如果要改变当前设置,请先断开网络。
+pin_note_operator = 启用PIN码后,下次启动设备时,需要输入PIN码;关闭PIN码后,下次启动设备时,不需要输入PIN码。
+pin_note_modify = 启用PIN码后,可修改PIN码。
+
+#lan
+lan_setting = 局域网接口设置
+ip_address = IP 地址
+subnet_mask = 子网掩码
+mac_address = MAC地址
+dhcp_server = DHCP服务
+dhcp_ip_pool = DHCP IP池
+dhcp_lease = DHCP租期
+hours = 小时
+minutes = 分钟
+lan_note = 新的设置会在设备重启后生效。
+lan_note_ip_address = IP 地址:路由器局域网的IP地址,使用该IP地址可以通过浏览器管理设备。
+lan_note_subnet_mask = 子网掩码:对应 IP 地址的子网掩码。
+lan_note_dhcp_server_enable = DHCP服务启用:如果开启DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)服务,设备将会为所连接的客户端自动分配IP地址。
+lan_note_dhcp_server_disable = DHCP服务关闭:如果关闭DHCP服务,设备将不会为连接的客户端自动分配IP地址,客户端必须手动输入IP地址。
+lan_note_dhcp_ip_pool = DHCP IP 池:起始IP地址和终止IP地址指定了DHCP服务器分配给接入设备的IP地址范围。这个范围之外的地址不能由DHCP服务器分配。
+lan_note_dhcp_lease_time = DHCP 租期时间:租期时间表示计算机获取IP地址后可以使用这个IP地址的期限,到达租期时间后,如果客户端需要继续使用这个地址,必须在到期前重新发起请求。只有当原来的客户端租期到期并且不再发起续租请求时,这个地址才能分配给其他客户端使用。
+lan_confirm_reopen = 您的设置将在设备重启后生效。您要继续吗?<br/><br/><i>注意:选择是,表示提交请求并重启设备。如果选择否,表示您放弃当前的选择。</i>
+lan_tip_staticip_notsame = 路由器局域网的IP地址不能与静态IP地址在同一个网段内!
+
+#sms_setting
+sms_validity = 有效期
+sms_validity_twelve_hours = 12 小时
+sms_validity_one_day = 1 天
+sms_validity_one_week = 1 周
+sms_validity_largest = 最长
+center_number = 中心号码
+delivery_report = 发送报告
+list = 列表
+
+#restore
+restore = 恢复出厂
+restore_title = 恢复出厂设置
+restore_button = 恢复出厂设置
+restore_confirm = 所有参数将恢复为出厂设置,设备会重启。确定继续?
+restore_when_connected = 请先断开 WAN 网络!
+restoring = 出厂设置恢复中
+restore_note_info = 点击“恢复出厂”以将所有设置还原为默认值,并且设备会自动重启。
+
+#wps
+wps_note_all = WPS(Wi-Fi Protected Setup)代表Wi-Fi保护设置,是一个简单且安全地建立无线网络的标准,您可以通过这一过程轻松地将无线客户端连接到设备,而无需进行任何具体的配置,例如SSID、安全模式和密码。
+wps_note_pin = PIN:您需要输入客户端的PIN码。
+wps_note_pbc = PBC:您可以在该网页选择PBC(Push Button Configuration)或者长按(3-4秒)设备上的WPS按键启用WPS功能。
+wps_note_wait = 该设备在 2 分钟内会等候接收无线接入客户端的访问请求。
+wps_pin = PIN
+wps_pbc = PBC
+wps_wifi_off = Wi-Fi 关闭时无法进行操作!
+wps_auth_open = 当前的加密类型不支持WPS。
+wps_on_info = WPS 已经启用,请稍后再试!
+wps_ssid_broadcast_disable = SSID 广播关闭时无法进行该操作!
+
+#sleep mode
+wifi_sleep = Wi-Fi 休眠设置
+sleep_time = 休眠时间
+sleep_mode_-1 = 从不休眠
+sleep_mode_5 = 5分钟
+sleep_mode_10 = 10分钟
+sleep_mode_20 = 20分钟
+sleep_mode_30 = 30分钟
+sleep_mode_60 = 1小时
+sleep_mode_120 = 2小时
+wifi_sleep_note_info = 休眠时间:当在指定的时间内无 Wi-Fi 连接时,Wi-Fi 功能将会停用,系统会转入休眠模式以节省电量。
+wifi_sleep_confirm = 当前设置改变时将会重启wifi,是否继续?
+
+#system security
+remote_management = 远程管理(通过 WAN 口)
+ping_from_wan = 从外网 PING 入
+
+#portforward
+protocol_TCP&UDP = TCP+UDP
+protocol_TCP = TCP
+protocol_UDP = UDP
+virtual_server_setting = 虚拟服务器设置
+port_forward_setting = 端口转发设置
+port_forward_list = 系统当前虚拟服务器
+port_forward_note_info = 配置端口转发以启用外部计算机,访问局域网提供的网络、FTP 或其他服务。
+port_forward_note_port = 端口范围:设置要转发的源端口数量。
+port_forward_note_ip_address = IP 地址:设置要转发的源 IP 地址。
+port_forward_note_protocol = 协议:设置用于转发的协议。
+port_forward_note_comment = 注释:输入用于转发设置的注释。有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 。
+port_range = 端口范围
+protocol = 协议
+comment = 注释
+ipExam = (例如:192.168.0.101)
+rules_max = 规则数量已达最大值{0}。
+rule_exist = 规则已经存在。
+rule_max_note = 规则的最大数量为 10。
+rule_max_note_v4v6 = IPv4 或 IPv6 规则的最大数量为 10。
+
+rules_max_v4v6 = {0}规则数量已达最大值{1}。
+rule_exist_v4v6 = {0}规则已经存在。
+
+#quick setting
+step_number_1 = 1
+step_number_2 = 2
+step_number_3 = 3
+step_number_4 = 4
+step_number_5 = 5
+step_number_6 = 6
+step_name_1 = 1.快速设置
+step_name_2 = 2.APN 设置
+step_name_3 = 3.PPP 鉴权
+step_name_4 = 4.SSID 配置
+step_name_5 = 5.安全配置
+step_name_6 = 配置如下
+step1_exp1 = 该向导帮助您安全设置网关基本参数:点击“上一步”和“下一步”进行导航;点击“应用”以保存设置。您也可以在其他菜单中设置高级参数。
+step1_exp2 = 在该向导中设置基本参数。您也可以在其他菜单中设置高级参数。
+apn_settings = APN 设置
+step2_auto_apn_explain = 如果您选择了“自动 APN”,将跳过第二步设置(PPP 鉴权)。
+step2_profile_name_explain = 配置文件名称:您当前使用的默认配置文件。
+ppp_authentication = PPP 鉴权
+step3_authentication_apn_explain1 = 鉴权方式:由您的互联网服务提供商 (ISP) 来提供。密码验证协议 (PAP) 不用加密就可以通过两次握手建立对端的身份。询问握手认证协议(CHAP)通过三次握手周期性的校验对端的身份。
+step3_authentication_apn_explain2 = 用户名:用于建立连接时,从互联网服务提供商获取验证。
+step3_authentication_apn_explain3 = 密码:用于建立连接时,从互联网服务提供商获取验证。
+step3_username_password_explain = 点击“设为默认”以将该配置文件设置为默认配置文件。
+ssid_title = SSID
+ssid_name = 网络名称 (SSID)
+ssid_broadcast = SSID 广播
+step4_ssid_explain = 网络名称:服务集标识符 (SSID)。输入无线局域网 (WLAN) 名称,最多 32 个字符。
+step4_ssid_broadcast_explain1 = SSID 广播:停用或启用(默认为启用)该功能。一旦启用该功能,路由器将会广播 SSID,其他设备将会发现该设备并进行连接。
+step4_ssid_broadcast_explain2 = 禁用:网关停止广播 SSID,在网络中隐藏您的网络名称。
+step5_encryption_mode_info = 安全模式:
+step5_encryption_mode_explain1 = OPEN:不进行验证以及加密。这可能会导致个人信息被拦截,或者网络被他人滥用,因此不推荐使用此方式。
+step5_encryption_mode_explain2 = WPA2(AES)-PSK:WPA2(AES)-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。
+step5_encryption_mode_explain3 = WPA-PSK/WPA2-PSK:WPA 预共享密钥 (WPA-PSK)。以纯文本 (ASCII) 密码的方式输入预共享密钥。WPA2-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。
+step5_encryption_mode_explain4 = 密码:密码的有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~
+step6_apply_explain = 一旦设置完成时,您需要重新连接无线网络。
+quick_setting_wifi_disable_confirm = 1、Wi-Fi 已关闭,与 Wi-Fi 相关的设置不会生效。<br\>要继续吗?
+quick_setting_param_changed_confirm = 1、Wi-Fi 配置更改后已连接的 Wi-Fi 设备可能需要重连。<br\>要继续吗?
+#SD Card
+sdcard = SD卡
+httpshare = HTTP 共享
+sd_card_mode = 模式
+sd_card_share_setting = 共享设置
+sd_card_share_usb_mode = USB
+sd_card_share_http_share_mode = HTTP 共享
+http_title = HTTP 共享设置
+sd_card_status = 状态
+sd_card_file_to_share = 共享文件
+sd_card_access_type = 访问类型
+sd_card_path_to_share = 路径共享
+sd_card_entire_sd_card = 整个SD卡
+sd_card_custom_setting = 自定义
+sd_card_read_write = 读/写
+sd_card_readonly = 只读
+sd_card_share_setting_no_sdcard = 无 SD卡!
+sd_card_share_setting_exist = 该文件或文件夹已经存在!
+sd_card_share_setting_noexist = 该文件或文件夹不存在!
+sd_card_status_info_0 = 无 SD卡!
+sd_card_status_info_1 = SD卡存在,现在可以使用了
+sd_card_status_info_2 = SD卡存在,但目前处于无效状态,请 5 秒后重试。如果无法使用,请检查 SD卡!
+sd_card_status_info_2_reason = 可能的原因如下
+sd_card_status_info_2_reason_1 = SD卡格式是NTFS,请切换至USB方式使用。
+sd_card_status_info_2_reason_2 = SD卡内容正在加载中,请5分钟后再试;如果仍然无效,请检查SD卡。
+sd_card_invalid_chars_cant_download = 文件名称中包含无效的字符,无法下载!(无效字符包括 < > " '' & + / \\ : * | # ? ~ `)。
+note_not_support_fs_ntfs = 在 HTTP 共享模式下,设备仅支持 FAT/FAT32 文件系统!
+note_web_share_mode = HTTP 分享模式:通过网络浏览器分享 SD 卡。此模式将会停用通过 USB 端口访问 SD 卡的可移动驱动器映射功能。
+note_usb_access = 仅通过 USB 访问:在可移动的驱动器映射模式下,用户仅能通过 USB 数据线来访问 SD 卡。共享的 SD 卡的网页将会停用。
+note_http_share_usb_access = 仅通过 USB 访问:在可移动的驱动器映射模式下,用户仅能通过 USB 数据线来访问 SD 卡。共享的 SD 卡的网页将会停用。
+note_http_share_cannot_access = 无法访问此页面!
+note_path_to_share_example = 路径共享:您可以输入共享路径,例如:/Picture。当仅输入斜线号“/”时,表示共享整个SD卡。
+note_upload_not_refresh = 当下载或者上传文件时,请不要刷新该网页!
+note_upload_single_file_2g = 单个文件上传最大支持2G。
+note_upload_filelenth_25 = 文件名、文件夹名称修改支持最长25个字符。
+note_uploading_not_refresh = 文件上传中,请不要刷新该页面!
+note_invalid_file_path = 路径共享不能为单独的小数点,也不能包含以下字符: < > " '' & + / \\ : * | # ? ~ `
+browse_btn = 浏览
+change_btn = 更改
+no_file_selected = 未选择文件
+sd_no_file_selected = 请选择一个文件
+sd_name = 名称
+sd_path = 路径:
+sd_rename = 重命名
+sd_download = 下载
+sd_file_size = 文件大小
+sd_update_time = 更新时间
+no_sdcard = 无 SD卡!
+no_exist = 文件不存在!
+sd_card_folder_name_is_null = 请输入名称
+get_file_list_failure = 获取文件列表失败
+create_folder_failure = 创建文件夹失败
+delete_folder_failure = 删除文件或文件夹失败
+sd_card_path_too_long = 文件路径过长。
+sd_file_size_too_big = 文件过大。单个文件上传最大支持2G。
+sd_file_name_invalid = 本设备不支持含有*号的文件名,请更新文件名。
+back_to_login = 返回登录
+sd_config_changed_reload = SD卡共享设置已改变,页面将重新加载。
+sd_upload_space_not_enough = SD卡空间不足!
+sd_upload_data_lost = 文件上传出现异常,请重试。
+sd_upload_file_is_downloading = 文件正在下载中,请稍候!
+sd_share_path_is_invalid = 共享路径无效,请重新设置
+sd_share_path_cant_rename = 文件夹已共享,无法重命名。
+sd_share_path_cant_delete = 文件夹“{0}”已共享,无法删除。
+sd_share_path_invalid = 共享路径失效。
+sd_file_processing_cant_delete = 文件正在被使用,无法删除。
+sd_file_processing_cant_rename = 文件正在被使用,无法重命名。
+sd_not_support = SD卡格式不支持或其它原因,请重新插入或更换SD卡。
+sd_usb_forbidden = SD卡正在被使用,无法切换。
+sd_upload_rename = 该文件已经存在!如需继续上传请修改文件名并选择“是”。选择“否”将取消上传。
+sd_upload_rename_null = 文件名不能为空或超过25个字符!
+
+#port filter
+filter_basic_setting = 基本设置
+port_filter_enabled = MAC/IP/端口过滤
+default_policy = 默认策略
+default_policy_note = 您可以设置防火墙策略以保护网络免受病毒、蠕虫和恶意网络行为的攻击。
+default_policy_note_filter = 过滤策略仅在启用过滤功能时可用。
+accepted = 放行
+dropped = 丢弃
+port_filter_setting = MAC/IP/端口过滤设置
+mac_address = MAC 地址
+macExam = (例如:00:1E:90:FF:FF:FF)
+dest_ip_address = 目的 IP 地址
+source_ip_address = 源 IP 地址
+port_filter_action = 操作
+filter_accept = 放行
+filter_drop = 丢弃
+protocol_None = 全部
+protocol_ICMP = ICMP
+port_filter_list = 系统当前 MAC/IP/端口过滤规则
+dest_port_range = 目的端口范围
+source_port_range = 源端口范围
+filter_accept_note = 其它数据包会被放行。
+filter_drop_note = 其它数据包会被丢弃。
+filter_optional = 请输入IP,MAC 或者端口值
+mac_check = 无效的 MAC 地址
+filter_ip_setting = IP设置
+filter_ipv4 = IPv4
+filter_ipv6 = IPv6
+ip_type = IP 类型
+source_ipv6_address = 源 IPv6 地址
+dest_ipv6_address = 目的 IPv6 地址
+port_filter_note_mac_address = MAC 地址:设置要过滤的 MAC 地址。
+port_filter_note_source_ip_address = 源 IP 地址:设置要过滤的源 IP 地址。
+port_filter_note_dest_ip_address = 目的 IP 地址:设置要过滤的目的 IP 地址。
+port_filter_note_protocol = 协议:设置用于过滤的协议。
+port_filter_note_source_port_range = 源端口范围:设置要过滤的源端口数量。
+port_filter_note_dest_port_range = 目的端口范围:设置要过滤的目的端口数量。
+port_filter_note_action = 操作:如果信息包与规则相符,可设置处理信息包。
+port_filter_note_comment = 注释:输入用于过滤设置的注释。有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 。
+port_filter_note_info = 过滤策略同规则是一一对应的。如果与此条款相抵触,将不会继续同下列规则匹配。
+confirm_data_effect = 您的设置可能不会立即生效,如果需要全部生效,建议重启设备,是否继续?
+
+#wifi_range
+wifi_range_settings = Wi-Fi 性能设置
+wifi_range = Wi-Fi 覆盖范围
+wifi_short_mode = 近距离 Wi-Fi 范围 - 最佳电池续航
+wifi_medium_mode = 中距离 Wi-Fi 范围
+wifi_long_mode = 远距离 Wi-Fi 范围
+wifi_des_short_mode = 近距离 Wi-Fi 范围
+wifi_des_medium_mode = 中距离 Wi-Fi 范围
+wifi_des_long_mode = 远距离 Wi-Fi 范围
+wifi_range_note_range = Wi-Fi 范围:
+wifi_range_note_short = 近距离 Wi-Fi 范围:覆盖范围和发射功耗小,是最佳电池续航方案。
+wifi_range_note_medium = 中距离 Wi-Fi 范围:覆盖范围和发射功耗是设备支持能力的一半,正常耗电。
+wifi_range_note_long = 远距离 Wi-Fi 范围:设备最大发射功耗和覆盖范围,如果一直有终端接入,耗电会增加,减少电池续航。
+wifi_range_note_short_cpe = 近距离 Wi-Fi 范围:覆盖范围和发射功耗最小。
+wifi_range_note_medium_cpe = 中距离 Wi-Fi 范围:覆盖范围和发射功耗是设备支持能力的一半。
+wifi_range_note_long_cpe = 远距离 Wi-Fi 范围:设备最大发射功耗和覆盖范围。
+
+#upnp
+upnp = UPnP
+upnp_setting = UPnP 设置
+upnp_note_info = 通用即插即用 (UPnP) 是网络协议集。它允许电脑、打印机、互联网网关、Wi-Fi 接入点和移动设备之间在网络上更方便地进行互相搜索,并为数据共享、通信和娱乐建立功能性的网络服务。
+
+#dmz
+dmz = DMZ
+dmz_setting = DMZ 设置
+dmz_note_info = 如果终端设备无法通过该设备运行网络应用程序,请启用 DMZ,在输入框输入该终端设备的 IP 地址。
+dmz_note_function = 您可以在该网页配置 DMZ 地址、启用或停用 DMZ 功能。
+
+#Device Information
+max_access_num = 最大连接数
+lan_domain = 局域网域名
+sim_serial_number = SIM卡卡号
+software_version = 软件版本
+firmware_version = 固件版本
+hardware_version = 硬件版本
+imei = IMEI
+imsi = IMSI
+wan_ip_address = WAN IP 地址
+ipv6_wan_ip_address = WAN IPv6 地址
+network_name_ssid1 = 网络名称 (主SSID)
+pass_phrase_ssid1 = 密码 (主SSID)
+max_access_num_ssid1 = 最大连接数 (主SSID)
+network_name_ssid2 = 网络名称 (副SSID)
+pass_phrase_ssid2 = 密码 (副SSID)
+max_access_num_ssid2 = 最大连接数 (副SSID)
+
+#port map
+port_map = 端口映射
+port_map_basic = 基本设置
+port_map_setting = 端口映射设置
+source_port = 源端口
+dest_port = 目的端口
+port_map_list = 当前映射规则
+port_map_note_info = 配置端口映射以启用外部计算机,访问局域网提供的网络、FTP 或其他服务。
+port_map_note_port = 源端口/目的端口:提供服务的计算机端口。
+port_map_note_dest_ip_address = 目的 IP 地址:指定一台加入局域网的计算机以提供服务。
+port_map_note_protocol = 协议:由服务应用的协议。
+port_map_note_comment = 注释:输入用于端口映射规则的注释。有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 。
+
+#USSD Info
+USSD = USSD
+ussd = USSD
+ussd_send_to = 发送
+ussd_send = 发送
+ussd_cancel = 取消
+ussd_reply_to = 回复
+ussd_reply = 回复
+ussd_contents = 内容
+ussd_timeout = 网络超时!
+ussd_operation_timeout = 操作超时!
+ussd_no_service = 无网络服务!
+ussd_retry = 操作失败!请重试!
+ussd_unsupport = 不支持 USSD 功能!
+ussd_info_error = 获取信息出错!
+ussd_fail = 操作失败!
+ussd_error_input = 输入有误!
+ussd_note1 = 您可以向网络发送一条指令(已预先制定的数字或者符号),网络将会根据指令给您提供相应的服务。
+
+#dlna setting
+dlna_setting = DLNA 设置
+dlna_language = 语言
+dlna_language_chinese = 中文
+dlna_language_english = 英文
+dlna_device_name = 设备名称
+dlna_media_type = 共享媒体类型
+dlna_media_info = 共享设置
+dlna_audio = 音乐
+dlna_image = 图片
+dlna_video = 视频
+dlna_rescan = 重新扫描
+dlna_note_info = 当 SD 卡可用或者 HTTP 共享模式启用时,您可以设置数字生活网络联盟 (DLNA)。
+dlna_note_httpshare = 您可以设置要在该网页上共享的数字媒体服务器 (DMS) 语言、设备名称和媒体类型。
+dlna_note_rescan = 为了使 DLNA 多媒体文件数据库与 SD 卡保持同步,建议重新扫描。
+
+#nosimcard
+no_sim_card_title = 系统信息
+no_sim_card_message = 没有 SIM卡或者 SIM卡无效!
+
+#network_locked
+network_locked = 网络被锁!
+network_locked_explain = 设备的网络被锁,请联系您的服务提供商获取解锁码。
+network_locked_times_explain = 解锁码输入剩余次数:
+network_locked_enter_explain = 请输入解锁码:
+network_locked_zero_times = 网络被锁,请联系您的服务提供商。
+
+#update_info
+update_info = 升级信息
+update_no_info = 当前已是最新版本
+update_new_version_found = 有新版本可用
+update_current_version = 当前版本
+update_new_version = 新版本
+update_link_prompt = 点击下面的链接下载升级工具
+update_skip_btn = 应用
+update_id_skip_info = 如果不想升级至此版本,请点击“跳过”按钮
+update_remind = 有新版本时提醒我。
+update_management = 更新管理
+update_log = 问题解决
+update_note = 备注
+update_notice = 发现新版本。通过“设置->设备设置->更新管理”查看详情。
+update_note_info = 点击链接以下载对应系统的更新工具。
+update_note_install = 解压更新工具并运行,进行版本更新。
+update_note_linux = Linux 系统不支持在线升级。如需升级,请在 Windows 系统或 Mac 上完成。
+update_status = 状态
+update_settings = 升级
+wifi_connect_alert = 您只能通过以太网升级。
+
+#AP_Station
+ap_station = Internet Wi-Fi
+ap_station_switch = Internet Wi-Fi 开关
+ap_station_wlan_mode = 首选网络
+ap_station_wifi_prior = Wi-Fi
+ap_station_3g_prior = WWAN
+ap_station_current_status = 当前状态
+ap_station_wlan_connected = Wi-Fi 已连接
+ap_station_wan_connected = WAN 已连接
+ap_station_no_connection = 无任何连接
+ap_station_hotspot_list = Wi-Fi 热点
+ap_station_connect = 连接
+ap_station_disconnect = 断开连接
+ap_station_add_hotspot = 添加 Wi-Fi 热点
+ap_station_edit_hotspot = 编辑 Wi-Fi 热点
+ap_station_show_password = 显示密码
+ap_station_encrypt_type = 加密方式
+ap_station_wep_keys = WEP密钥
+ap_station_encrypt_type_none = 不加密
+ap_station_encrypt_type_wep = WEP
+ap_station_wep_key_type_ascii = ASCII
+ap_station_wep_key_type_hex = HEX
+ap_station_cipher = WPA算法
+ap_station_cipher_TKIP = TKIP
+ap_station_cipher_AES = AES
+ap_station_cipher_AUTO = AUTO
+ap_station_security_mode_OPEN = OPEN
+ap_station_security_mode_WPAPSKWPA2PSK = WPA-PSK/WPA2-PSK
+ap_station_security_mode_SHARED = SHARED
+ap_station_security_mode_WPAPSK = WPA-PSK
+ap_station_security_mode_WPA2PSK = WPA2-PSK
+ap_station_security_mode_EAPAKASIM = EAP-AKA/SIM
+ap_station_security_mode_EAP-SIM/AKA = EAP-SIM/AKA
+ap_station_security_mode_WPA3Personal = WPA3-Personal
+ap_station_security_mode_WPA2WPA3 = WPA2(AES)/WPA3-Personal
+ap_station_wep_default_key = 网络密钥
+ap_station_wep_key = WEP密钥
+ap_station_wep_key_0 = 密钥 1
+ap_station_wep_key_1 = 密钥 2
+ap_station_wep_key_2 = 密钥 3
+ap_station_wep_key_3 = 密钥 4
+ap_station_exceed_list_max = 最多可添加 {0} 个热点!
+ap_station_search_hotspot_fail = 搜索热点失败!
+ap_station_connect_change_alert = WAN连接将断开,要继续吗?
+ap_station_update_fail = 操作失败,该热点处于连接状态。
+ap_station_enable_confirm = 当Internet Wi-Fi使用时多重网络名称不能使用。如果开启Internet Wi-Fi,多重网络名称将自动关闭,是否修改设置?
+ap_station_processing = 后台忙,请重试。
+ap_station_exist = 存在同名热点。
+ap_connect_error = 无法连接上热点 {0}!
+
+#fastboot
+fastboot = 快速开机
+fastboot_setting = 快速开机设置
+fastboot_note = 如果启用了快速开机功能,设备将花费较短的时间开机。
+
+#notes
+wifi_channel_bandwidth = 频带宽度
+
+home_note = 表格中显示了已连接的无线终端设备信息。
+
+sms_setting_note_validity = 有效期:设置外发短信的有效期。
+sms_setting_note_center_number = 中心号码:请输入短信中心号码。如需详情请联系您的服务提供商。
+sms_setting_note_delivery_report = 发送报告:当短信已送达收件人时,接收或者拒绝送达提示。
+
+apn_note_whole_page = 您可以在该网页设置接入点名称 (APN)。
+apn_note_mode = 模式:如果您的服务提供商向您提供了固定的 APN,请选择“手动 APN”。如果没有提供,请选择“自动 APN”,该设备将会自动获取参数。
+apn_note_profile = 配置文件:包含了一个或多个配置文件名称。
+apn_note_pdp_type = PDP 类型:IPv4/IPv6/IPv4&IPv6。
+apn_note_profile_name = 配置文件名称:有关您指定的新的配置文件的名称。
+apn_note_apn = APN:接入点名称。有效字符包含:0-9 a-z A-Z . - 且开头和结尾不能是 . 或者 - 。
+apn_note_dns_mode = DNS 模式:如果您的服务提供商向您提供了固定的 IP 地址,请选择“手动 DNS”,如果没有提供,请选择“自动 DNS”,该设备将会自动获取参数。
+apn_note_authentication = 鉴权方式:由您的互联网服务提供商 (ISP) 来提供。密码验证协议 (PAP) 不用加密就可以通过两次握手建立对端的身份。询问握手认证协议(CHAP)通过三次握手周期性的校验对端的身份。
+apn_note_username = 用户名:用于建立连接时,从互联网服务提供商处获取验证。
+apn_note_password = 密码:用于建立连接时,从互联网服务提供商处获取验证。
+apn_note_set_default = 点击“设为默认”以将该配置文件设置为默认配置文件。
+
+wifi_basic_note_multi_ssid_switch = 多重网络名称开关:可以同时使用 2 个网络名称。
+wifi_basic_note_network_name = 网络名称(SSID):SSID可以简单地理解为无线网络的名称。修改SSID时,请在本框中输入一个最多不超过32个字符的字符串,该字符串由数字、字母(a-z、A-Z)、特殊字符(!#()+-./%=?@^_{|}~)和空格,且开头和结尾不能是空格。
+wifi_basic_note_network_name_input = 网络名称的有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~ 和空格且开头和结尾不能是空格。
+wifi_basic_note_broadcast = SSID 广播:启用后,设备将会广播其无线网络标识(SSID)。这样附近的计算机或其他无线客户端即可搜索到本路由器的无线信号并连接到该设备。
+wifi_basic_note_security_mode = 安全模式:
+wifi_basic_note_no_encryption = OPEN:无数据加密。这可能会导致网络被他人滥用,因此不推荐使用此方式。
+wifi_basic_note_shared = SHARED(WEP):链路认证方式为共享密钥认证方式,加密方式为WEP加密。
+wifi_basic_note_wpa_psk_aes = WPA2(AES)-PSK: WPA2(AES)-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。
+wifi_basic_note_wpa_psk = WPA-PSK/WPA2-PSK:WPA 预共享密钥 (WPA-PSK)。WPA2-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。
+wifi_basic_note_wpa3 = WPA3-Personal:WPA2加密协议的升级版本。
+wifi_basic_note_wpa2_wpa3 = WPA2(AES)/WPA3-Personal: WPA2-PSK 是 Wi-Fi 网络安全存取 (WPA) 的安全保护版本,该版本施行了802.11i 无线安全标准。WAP3是WPA2加密协议的升级版本。
+wifi_basic_note_pass_phrase = 密码:密码的有效字符包含:0-9 a-z A-Z ! # ( ) + - . / % = ? @ ^ _ { | } ~
+wifi_basic_note_max_station_number1 = 最大接入数:通过本操作,可以选择连接到该设备的最大无线终端接入数。通过Internet Wi-Fi功能连接的Wi-Fi热点也属于该设备的无线终端接入设备。
+wifi_basic_note_max_station_number = 最大接入数:通过本操作,可以选择连接到该设备的最大无线终端接入数。
+
+wifi_advanced_note_whole_page = 您可以在该网页设置 Wi-Fi 高级字符。
+wifi_advanced_note_band_selection = 频段选择:您可以为您的设备选择合适的频段。
+wifi_advanced_note_network_mode = 网络模式:选择合适的无线网络模式,该设备的无线性能会提高。
+wifi_advanced_note_country_code = 国家/地区码:您可以为您的设备选择合适的国家/地区码。
+wifi_advanced_note_frequency = 信道:选择合适的频道来优化Wi-Fi网络性能和覆盖范围。
+
+ap_station_note_info = 请确保您所连接的 Wi-Fi 热点的IP地址段与本设备的IP地址段不在同一范围内,否则您将无法通过该 Wi-Fi 热点连接网络。
+ap_station_note_disable_info = 如果开启“多重网络名称”,Internet Wi-Fi 功能将会停用。
+ap_station_on_info = Internet Wi-Fi 功能启用时无法进行该操作!
+
+wif_filter_note1 = 无线局域网地址过滤规则设置。
+wif_filter_note2 = 无规则:不启用无线局域网地址过滤规则。
+wif_filter_note3 = 白名单:允许MAC地址列表中的用户通过无线网络与本设备连接。
+wif_filter_note4 = 黑名单:不允许MAC地址列表中的用户通过无线网络与本设备连接。
+
+#restart
+restart = 重启
+restart_button = 重启设备
+restart_confirm = 确定重启设备吗?
+restarting = 设备重启中
+
+#diconneted_operate_note
+diconneted_operate_note = 要更改当前设置,请断开网络连接。
+diconneted_network_confirm = 当前操作将会断开网络,是否继续?
+
+#ota_update
+ota_update = 更新管理
+ota_title = 更新
+ota_no_new_version = 没有发现新版本。
+ota_new_version = 发现新版本,是否更新?
+ota_connect_server = 正在连接服务器
+ota_connect_server_successfully = 连接服务器成功
+ota_downloading = 正在下载...
+ota_download_failed = 下载失败
+ota_no_network = 无网络
+ota_network_disconnected = 请连接网络后更新!
+ota_interrupted_alert = 发现新版本,请登陆后更新!
+ota_interrupted = 是否恢复上次被中断的下载任务?
+ota_download_success = 下载完成,设备将重启,请稍候。升级过程中请不要断电、恢复出厂设置或关机。
+ota_pkg_download_success = 升级包已存在,设备将重启,请稍候。升级过程中请不要断电、恢复出厂设置或关机。
+ota_update_success = 更新成功。
+ota_update_failed = 更新失败。
+ota_connect_server_failed = 无法连接到服务器
+ota_download_warning = 请保持电量充足;请不要强制中断下载。
+ota_update_warning = 注意事项:请不要强制中断更新。
+ota_cancel = 更新已取消!
+ota_pkg_exceed = 更新包太大!
+ota_have_cancel = 你已经选择取消了!
+ota_roamming = 您尚未开启漫游设置。要开启漫游功能,请勾选本页复选框。
+ota_low_battery = 下载成功,设备电量不足,请充电后再升级!
+ota_pkg_low_battery = 升级包已存在,设备电量不足,请充电后再升级!
+ota_md5_error = 检测更新包失败。
+ota_version = 版本:
+ota_update_setting = 自动检测设置
+ota_auto_update_switch = 自动检测新版本
+ota_update_interval_day = 自动检测周期
+ota_roaming_setting = 漫游设置
+ota_update_roaming_remind = 勾选此项后,设备将在漫游状态下进行更新,并且会产生漫游费用。
+ota_update_manual = 检测新版本
+ota_check_new_version = 检测
+ota_check_new_version_desc = 点击“检测”按钮,立即检测新版本。
+ota_check_roaming_confirm = 当前处于漫游网络下,您确定要升级吗?
+ota_update_every_day = 每天
+ota_update_15_day = 15天
+ota_update_30_day = 30天
+ota_new_version_checking = 新版本检测中...
+ota_update_running = 检测已经在进行...
+ota_check_fail = 检测新版本失败!
+fota_package_already_download = 升级包已下载,待设备重启后完成升级
+software_upload = 软件升级
+upload_update_success = 升级文件上传成功,即将重启,请勿断电。
+upload_update_failed0 = 文件解析失败。
+upload_update_failed1 = 文件校验失败。
+upload_update_failed2 = 文件写入失败。
+upload_update_failed3 = 升级标志写入失败。
+upload_update_failed4 = Flash校验失败。
+error_file_selected = 请选择正确的升级文件
+upload_tip = 上传中,请勿关闭、刷新或多页面操作webui,直至重启。
+########CPE more wording##############
+opmode = 模式切换
+wds = WDS
+url_filter = URL过滤设置
+
+voip_settings = VoIP设置
+voip_user_details = 用户详情
+voip_advanced_settings = 高级设置
+voip_supplementary_service = 补充业务
+
+url_check = 无效的URL
+url_filter_check = 无效的URL过滤规则
+sntp_invalid_server_name = 无效的URL格式或者IP地址!
+server_alreay_exist = 该服务器已经存在!
+forwarding_uri_check = 无效值
+
+wifi_switch = Wi-Fi开关
+ap_isolation = AP 隔离
+#mac filter
+black_list = 黑名单
+black_list_switch = 黑名单开关
+block = 屏蔽
+black_list_max = 黑名单支持的最大个数是10!
+mac_repeat_tip = 请删除设置列表中重复的MAC地址!
+black_yourself_tip = 你不能屏蔽你自己!
+wifi_status11 = 用户数:11
+wifi_status12 = 用户数:12
+wifi_status13 = 用户数:13
+wifi_status14 = 用户数:14
+wifi_status15 = 用户数:15
+wifi_status16 = 用户数:16
+wifi_status17 = 用户数:17
+wifi_status18 = 用户数:18
+wifi_status19 = 用户数:19
+wifi_status20 = 用户数:20
+wifi_status21 = 用户数:21
+wifi_status22 = 用户数:22
+wifi_status23 = 用户数:23
+wifi_status24 = 用户数:24
+wifi_status25 = 用户数:25
+wifi_status26 = 用户数:26
+wifi_status27 = 用户数:27
+wifi_status28 = 用户数:28
+wifi_status29 = 用户数:29
+wifi_status30 = 用户数:30
+wifi_status31 = 用户数:31
+wifi_status32 = 用户数:32
+
+auto_connect = 自动连接
+manual_connect = 手动连接
+
+default_Gateway = 默认网关
+primary_dns = 首选 DNS
+secondary_dns = 备用 DNS
+gateway_check = 请输入有效的网关
+
+mac_filter_lable = MAC过滤规则
+
+wlan_mac_filter_0 = 无规则
+wlan_mac_filter_1 = 白名单
+wlan_mac_filter_2 = 黑名单
+black_enable= 黑名单
+white_list = 白名单
+white_enable = 白名单
+mac_white_address = MAC 地址
+max_white_list = 白名单最多只能添加6条。
+
+#SNTP
+local_current_time = 本地当前时间
+time_set_mode = 时间设置模式
+time_set_time_manual = 手动设置时间
+time_set_time_auto = 自动同步Sntp
+year = 年
+month = 月
+date = 日
+hour = 时
+minute = 分
+second = 秒
+sunday = 星期日
+monday = 星期一
+tuesday = 星期二
+wednesday = 星期三
+thursday = 星期四
+friday = 星期五
+saturday = 星期六
+stnp_server1 = SNTP 服务器1
+stnp_server2 = SNTP 服务器2
+stnp_server3 = SNTP 服务器3
+time_zone = 时区
+daylight_saving_time = 夏时制
+daylightsave_0 = 禁用
+daylightsave_1 = 启用
+sntp_syn_time_wan_connected = 联网后才可以使用sntp时间同步!
+operation_not_supported = 不支持该操作!
+network_terminated = 网络终止!
+upgrade_file_nomatch = 升级文件错误!
+upgrade_confirm = 您确认要升级吗?
+upgrading = 升级中,请稍等...
+upgrading_alert = 升级中,请勿切断电源。升级后,系统将会自动重启!
+upgrad_note = 请选择您要升级的版本,然后点击“应用”按钮后,开始升级。
+sntp_processing = 同步中,请稍等...
+sntp_req_success = 同步请求已发送!
+time_zone_<-12>12_0 = (GMT-12:00) 日界线西
+time_zone_SST11_0 = (GMT-11:00) 中途岛,萨摩亚群岛
+time_zone_<-10>10_0 = (GMT-10:00) 夏威夷
+time_zone_<-09>9_0 = (GMT-09:00) 阿拉斯加
+time_zone_PST8PDT,M3.2.0,M11.1.0_0 = (GMT-08:00) 太平洋时间(美国和加拿大),蒂华纳
+time_zone_<-07>7_0 = (GMT-07:00) 山地时间(美国和加拿大)
+time_zone_<-07>7_1 = (GMT-07:00) 亚利桑那
+time_zone_MST7MDT,M4.1.0,M10.5.0_2 = (GMT-07:00) 奇瓦瓦,拉巴斯,马扎特兰
+time_zone_<-06>6_0 = (GMT-06:00) 萨斯喀彻温
+time_zone_<-06>6_1 = (GMT-06:00) 中部时间(美国和加拿大)
+time_zone_<-06>6_2 = (GMT-06:00) 中美洲
+time_zone_<-06>6_3 = (GMT-06:00) 瓜达拉哈拉,墨西哥城,蒙特雷
+time_zone_<-05>5_0 = (GMT-05:00) 波哥大,利马,基多
+time_zone_<-05>5_1 = (GMT-05:00) 东部时间(美国和加拿大)
+time_zone_EST5EDT,M3.2.0,M11.1.0_2 = (GMT-05:00) 印第安纳州(东部)
+#time_zone_-4.5 = (GMT-04:30)
+time_zone_AST4ADT,M3.2.0,M11.1.0_0 = (GMT-04:00) 大西洋时间(加拿大)
+time_zone_<-04>4_1 = (GMT-04:00) 加拉加斯,拉巴斯
+time_zone_<-04>4<-03>,M8.2.6/24,M5.2.6/24_2 = (GMT-04:00) 圣地亚哥
+time_zone_NST3:30NDT,M3.2.0,M11.1.0_0 = (GMT-03:30) 纽芬兰
+time_zone_<-03>3_0 = (GMT-03:00) 巴西利亚
+time_zone_<-03>3_1 = (GMT-03:00) 布宜诺斯艾利斯,乔治敦
+time_zone_<-03>3_2 = (GMT-03:00) 格陵兰
+time_zone_<-02>2_0 = (GMT-02:00) 中大西洋
+time_zone_<-01>1_0 = (GMT-01:00) 佛得角群岛
+time_zone_<-01>1<+00>,M3.5.0/0,M10.5.0/1_1 = (GMT-01:00) 亚速尔群岛
+time_zone_GMT0IST,M3.5.0/1,M10.5.0_0 = (GMT) 格林威治标准时间:都柏林,爱丁堡,伦敦,里斯本
+time_zone_WET0WEST,M3.5.0,M10.5.0/3_1 = (GMT) 卡萨布兰卡,蒙罗维亚
+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_0 = (GMT+01:00) 阿姆斯特丹,柏林,伯尔尼,罗马,斯德哥尔摩,维也纳
+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_1 = (GMT+01:00) 贝尔格莱德,布拉迪斯拉发,布达佩斯,卢布尔雅那,布拉格
+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_2 = (GMT+01:00) 布鲁塞尔,哥本哈根,马德里,巴黎
+time_zone_CET-1CEST,M3.5.0,M10.5.0/3_3 = (GMT+01:00) 萨拉热窝,斯科普里,华沙,萨格勒布
+time_zone_<+01>-1_4 = (GMT+01:00) 中非西部
+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_0 = (GMT+02:00) 布加勒斯特
+time_zone_CAT-2_1 = (GMT+02:00) 哈拉雷,比勒陀利亚
+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_2 = (GMT+02:00) 赫尔辛基,基辅,里加,索非亚,塔林,维尔纽斯
+time_zone_EET-2_3 = (GMT+02:00) 开罗
+time_zone_EET-2EEST,M3.5.0/3,M10.5.0/4_4 = (GMT+02:00) 雅典,贝鲁特,伊斯坦布尔,明斯克
+time_zone_IST-2IDT,M3.4.5/02:00:00,M10.5.0/02:00:00_5 = (GMT+02:00) 耶路撒冷
+time_zone_<+03>-3_0 = (GMT+03:00) 巴格达
+time_zone_<+03>-3_1 = (GMT+03:00) 科威特,利雅得
+time_zone_<+03>-3_2 = (GMT+03:00) 莫斯科,圣彼得堡,伏尔加格勒
+time_zone_EAT-3_3 = (GMT+03:00) 内罗毕
+time_zone_<+0330>-3:30<+0430>,J80/0,J264/0_0 = (GMT+03:30) 德黑兰
+time_zone_<+04>-4_0 = (GMT+04:00) 阿布扎比,马斯喀特
+time_zone_<+04>-4_1 = (GMT+04:00) 巴库,第比利斯,埃里温
+time_zone_<+0430>-4:30_0 = (GMT+04:30) 喀布尔
+time_zone_<+05>-5_0 = (GMT+05:00) 叶卡捷琳堡
+time_zone_PKT-5_1 = (GMT+05:00) 伊斯兰堡,卡拉奇,塔什干
+time_zone_<+0530>-5:30_0 = (GMT+05:30) 马德拉斯,加尔各答,孟买,新德里
+time_zone_<+0545>-5:45_0 = (GMT+05:45) 加德满都
+time_zone_<+06>-6_0 = (GMT+06:00) 阿拉木图,新西伯利亚
+time_zone_<+06>-6_1 = (GMT+06:00) 阿斯塔纳,达卡
+time_zone_<+06>-6_2 = (GMT+06:00) 斯里哈亚华登尼普拉
+time_zone_<+0630>-6:30_0 = (GMT+06:30) 仰光
+time_zone_<+07>-7_0 = (GMT+07:00) 克拉斯诺亚尔斯克
+time_zone_<+07>-7_1 = (GMT+07:00) 曼谷,河内,雅加达
+time_zone_CST-8_0 = (GMT+08:00) 北京,重庆,香港特别行政区,乌鲁木齐
+time_zone_<+08>-8_1 = (GMT+08:00) 吉隆坡,新加坡
+time_zone_AWST-8_2 = (GMT+08:00) 珀斯
+time_zone_CST-8_3 = (GMT+08:00) 台北
+time_zone_<+08>-8_4 = (GMT+08:00) 伊尔库茨克,乌兰巴图
+time_zone_JST-9_0 = (GMT+09:00) 大阪,札幌,东京
+time_zone_KST-9_1 = (GMT+09:00) 汉城
+time_zone_<+09>-9_2 = (GMT+09:00) 雅库茨克
+time_zone_ACST-9:30ACDT,M10.1.0,M4.1.0/3_0 = (GMT+09:30) 阿德莱德
+time_zone_ACST-9:30_1 = (GMT+09:30) 达尔文
+time_zone_AEST-10_0 = (GMT+10:00) 布里斯班
+time_zone_<+10>-10_1 = (GMT+10:00) 弗拉迪沃斯托克
+time_zone_<+10>-10_2 = (GMT+10:00) 关岛,莫尔兹比港
+time_zone_AEST-10AEDT,M10.1.0,M4.1.0/3_3 = (GMT+10:00) 霍巴特
+time_zone_AEST-10AEDT,M10.1.0,M4.1.0/3_4 = (GMT+10:00) 堪培拉,墨尔本,悉尼
+time_zone_<+11>-11_0 = (GMT+11:00) 马加丹,所罗门群岛,新喀里多尼亚
+time_zone_<+12>-12_0 = (GMT+12:00) 奥克兰,惠灵顿
+time_zone_<+12>-12_1 = (GMT+12:00) 斐济,勘察加半岛,马绍尔群岛
+time_zone_<+13>-13_0 = (GMT+13:00) 努库阿洛法
+
+#operation mode
+opmode_auto = 自动模式
+opmode_bridge = 桥模式
+opmode_cable = 有线宽带模式
+opmode_gateway = 无线宽带模式
+EthPort_Status = 以太网端口状态
+change_mode = 选择模式
+current_mode = 当前模式:
+change = 改变
+change_mode_alert = 有线宽带模式只能使用Wi-Fi访问,请记住Wi-Fi SSID和密码!要继续吗?
+
+opmode_msg1 = 无线宽带模式下请将公网网线拔掉。
+opmode_msg2 = 改变工作模式后,设备会自动重启。
+#pppoe dial
+pppoe_mode = PPPoE
+pppoe_success = PPPoE拨号成功
+pppoe_fail = PPPoE拨号失败
+pppoe_processing = 正在进行PPPoE拨号
+static_success = 配置静态IP成功
+static_fail = 配置静态IP失败
+static_processing = 正在获取静态IP
+dyn_success = 动态获取IP成功
+dyn_fail = 动态获取IP失败
+dyn_processing = 正在获取动态IP
+pppoe_msg = 公网网线未连上
+pppoe_message_send_fail = 消息发送失败!
+ip_gate_not_same = IP地址和默认网关不可以相同!
+ip_innergate_not_same = IP地址和局域网的IP地址不可以在同一网段中!
+auto_success = 自动拨号成功
+auto_fail = 自动拨号失败
+auto_processing = 正在进行自动拨号
+#url filter
+url_filter_list = 当前系统的URL过滤规则
+url_filter_max = URL过滤规则最大数量为{0}
+url_repeated = URL已经存在。
+url_note1 = 您可以设置网页地址的过滤以过滤一些不良的网站。
+url_note2 = URL:设置需要过滤的url地址。
+
+#wds
+wds_mode = WDS模式
+wds_mode_0 = 禁用
+wds_mode_1 = RootAP 模式
+wds_mode_2 = Bridge 模式
+wds_mode_3 = Repeater 模式
+repeater_ssid = Repeater SSID
+wpa_algorithms = WPA算法
+enable_wds_confirm = 如果开启WDS,那么Wi-Fi基本设置将被禁用,继续吗?
+#sys log
+sys_log = 系统日志
+log_setting = 日志设置
+syslog_mode_all = 所有
+syslog_mode_wan_connect = WAN Connect
+syslog_mode_sms = SMS
+syslog_mode_tr069 = tr069
+syslog_mode_voip = VoIP
+syslog_mode_dlna = DLNA
+syslog_mode_wlan = Wi-Fi
+syslog_mode_router = Router
+view_log = 查看日志
+log_info = 日志信息
+
+#add at 2013.6.20
+periodic_inform = 周期性通知
+periodic_inform_interval = 周期性通知间隔
+periodic_inform_time = 周期性通知时间
+certificate_import = 证书
+import_certificate_btn = 导入
+certificate_file_nomatch = 证书文件错误
+#voip setting
+outbound_mode = Outbound模式
+outbound_server = Outbound服务器
+outbound_port = Outbound端口
+stun_mode = STUN模式
+stun_server = STUN服务器
+register_every = 注册有效期
+advanced_options = 高级选项
+sip_port = SIP端口
+rtp_port = RTP端口
+voip_outbound_port_check = 无效端口
+voip_time_check = 注册时间无效
+timeRange = [1,3600]秒
+voip_sip_port_check = 无效端口
+voip_port_compare = 无效的端口范围
+warn_information = VoIP参数设置成功,请重新注册。
+#voip user details
+user_details_title = SIP服务器和配置
+sip_register_server = SIP注册服务器
+sip_domain = SIP域
+sip_realm = SIP范围
+sip_proxy_mode = SIP代理模式
+sip_proxy_server = SIP代理服务器
+authorization = 鉴权
+display_name = 显示名称
+authorized_user_name = 鉴权用户名
+authorized_password = 授权密码
+voip_register_status = VoIP注册状态
+register_failed = 注册失败
+register_success = 注册成功
+register_connecting = 注册连接中
+unregister = 注销成功
+deregister = 注销
+sip_domain_check = SIP域地址无效!
+sip_realm_check = SIP域无效!
+sip_proxy_server_check = 代理服务器无效!
+display_name_check = 显示名称无效!
+authorized_username_check = 鉴权用户名无效!
+account_password_check = 密码无效!
+#voip advanced settings
+sip_advanced_options = 高级选项
+adv_sip_t38 = T.38传真编码
+sip_dtmf = DTMF
+voip_sip_dtmf_method_inband = InBand
+voip_sip_dtmf_method_rfc2833 = RFC2833
+voip_sip_dtmf_method_sipinfo = SIPInfo
+sip_encoder = 编码
+voip_sip_encoder_method_0 = G.711 u-Law
+voip_sip_encoder_method_1 = G.711 a-Law
+voip_sip_encoder_method_2 = G.722
+voip_sip_encoder_method_3 = G.729
+voip_sip_encoder_method_4 = G.726-16kps
+voip_sip_encoder_method_5 = G.726-24kps
+voip_sip_encoder_method_6 = G.726-32kps
+voip_sip_encoder_method_7 = G.726-40kps
+sip_vad = VAD
+sip_cng = CNG
+#voip supplementary service
+sip_protocol_voip = VoIP补充业务
+sip_protocol_call_forw = 呼叫转移
+voip_forwarding_mode_1 = 无条件呼叫转移
+voip_forwarding_mode_2 = 遇忙转移
+voip_forwarding_mode_3 = 无应答转移
+voip_forwarding_mode_0 = 禁止所有转移
+sip_protocol_forw_uri = 发送URI
+show_msg = 请在电话上按'*80'!
+sip_protocol_incoming_call = 免扰功能
+sip_protocol_call_waiting = 呼叫等待
+wds_note = WDS:无线分布式系统
+#voip user details
+connect_note = 请先连接网络,再使用VOIP功能!
+#fota
+upgrade_pack_fix_success = 升级成功!
+upgrade_pack_fix_failed = 升级失败!
+have_new_version = 发现新版本,设备将升级。
+######key same value different###########
+dmz_note_info = 如果终端设备无法通过该设备运行网络应用程序,请启用 DMZ,在输入框输入该终端设备的 IP 地址。
+dlna_note_info = DLNA: 数字生活网络联盟。
+dlna_note_httpshare = 您可以设置要在该网页上共享的数字媒体服务器 (DMS) 设备名称和媒体类型。
+#############串口转网口###################
+switch_port_title = 网口转串口
+open_serial_port = 开启网口转串口
+close_serial_port = 关闭网口转串口
+switching = 转换中...
+##############定时重启功能wording###################
+restart_schedule = 定时重启
+enable_reboot_switch = 启动定时重启功能
+restart_schedule_time = 定时重启时间
+enable_reboot_byday = 按天自动重启
+enable_reboot_byweek = 按周自动重启
+enable_reboot_bymonth = 按月自动重启
+synchronized = 已同步
+unsynchronized = 未同步
+week = 星期
+eyeryday = 每日
+login_password_length_check = 请输入至少4位字符。
+system_time_not_syn = 系统时间未同步!
+fota_note1 = 您可以为您的设备设置自动检测周期,使设备定时自动检测是否有新版本的软件。
+local_note = 您可以选择本地电脑中的升级文件,将设备软件升级到选中的版本,完成系统修复和优化。
+
+#new word
+modify_password = 修改登录密码
+
+#家长控制
+parental_control = 家长控制
+pc_children_group = 儿童组设备
+pc_children_group_manage = 儿童组管理
+pc_manage = 管理
+pc_no_children_device = 没有设置儿童组设备
+pc_children_group_desc = 添加到儿童组的所有设备将受到上网规则的限制
+pc_edit_host_name = 修改主机名:
+pc_internet_rule = 上网规则
+pc_time_limited = 上网时间设置
+pc_site_white_list = 网站白名单
+pc_manage_children_group = 管理儿童组设备
+pc_current_attached_devices =当前接入设备
+pc_action = 操作
+pc_remove = 移除
+pc_remove_all = 移除所有
+pc_add = 添加
+pc_leave = 离开
+pc_add_white_site = 添加白名单
+pc_in_child_group = 已在儿童组
+pc_forbid_time = 禁止上网时段
+pc_allow_time = 允许上网时段
+pc_setting_desc =可用鼠标点按设置禁止或允许上网时段
+pc_name = 网站名
+pc_link = 链接
+pc_not_save = 数据还未保存,请注意保存。
+pc_link_exist = 链接已存在!
+no_data = 没有数据
+sun = 周日
+mon = 周一
+tues = 周二
+wed = 周三
+thur = 周四
+fri = 周五
+sat = 周六
+
+#定时休眠唤醒
+tsw_settings = 定时休眠唤醒设置
+tsw = 定时休眠唤醒
+time_sleep_wake_up = 定时休眠唤醒设置
+tsw_timer_on = 定时唤醒时间
+tsw_timer_off = 定时休眠时间
+tsw_sys_time_mode_alert = 请先连接网络,使SNTP同步服务器时间后即可设置。
+tsw_time_interval_alert = 时间间隔不得小于10分钟。
+
+#new wording
+advanced_settings = 高级设置
+others = 其他
+others_restart_reset = 重启与复位
+others_note_info = 当重启或复位路由器后,你需要重新登陆
+
+pwd_sub_title = 管理你的无线路由器有关信息
+pwd_note = 当你登陆无线路由器时,需要输入此密码(不同于你的无线网络密码)
+current_network = 当前网络
+
+wifi_wireless_settings = Wi-Fi设置
+wifi_main_sub_title = 建立你的无线热点,以供手机或笔记本等无线设备上网使用
+wifi_broadcast_desc = SSID 广播
+wifi_isolated_desc = 将所有的无线客户端设备完全隔离
+
+detail_info = 详细信息
+sd_u_share = U盘共享
+
+settings_wireless = 设置无线内网
+settings_internet = 设置外网连接
+not_connect_network = 未连接网络
+
+traffic_data_plan = 流量统计
+traffic_pie_title = 流量套餐
+traffic_sub_title = 您可以在该页面创建流量计划、查询已用流量及剩余流量
+traffic_used = 已使用
+traffic_used_text = {0} 已使用
+traffic_limit_data = 流量套餐
+traffic_limit_data_text = {0} 流量套餐
+traffic_alert_reach_text = 当达到{0}%,{1} 时提醒我
+traffic_data_left_text = {0} 剩余
+traffic_when = 当达到
+traffic_remind_me = %,时提醒我
+traffic_remind_me_time = ,时提醒我
+traffic_limit_time_text = {0}套餐
+traffic_limit_time_h = {0} 小时套餐
+traffic_limit_time_m = {0} 分钟套餐
+traffic_not_set_limited = 未设置流量套餐,点按设置
+
+echarts_used = 已使用
+echarts_left1 = 未使用
+echarts_alert = 提醒值
+echarts_alarm = 已使用(超出提醒值)
+echarts_free = 未使用
+echarts_full = 流量超出
+echarts_no = 未设置
+
+3g = 3G
+wan = WAN
+connection_mode = 联网模式
+wireless_access_device = 无线接入设备
+cable_access_device = 有线接入设备
+station_info_sub_title = 本页面显示了连接到本路由器的所有无线终端,其中包括无线终端的设备名称、MAC(介质访问控制)地址
+station_info_desc = 更多的权限控制选项,请查看
+
+device_unit = 台
+ota_last_update_check = 最后更新时间:
+main_ssid_num = 主 SSID ({0})
+guest_ssid_num = 副 SSID ({0})
+wifi_slider_desc = * 拖动进度条已调整各SSID最大可接入数量
+wif_guest_disabled = 副SSID 没有开启
+
+phone_number = 号码
+equalToPin = 两次输入的PIN码不一致
+equalToPassword = 两次输入的密码不一致
+
+pppoe_mode_type_PPPOE = PPPoE
+pppoe_mode_type_STATIC = 静态IP
+pppoe_mode_type_DHCP = 动态IP
+pppoe_mode_type_AUTO = 自动
+
+tsw_note = 定时休眠唤醒功能,当定时休眠唤醒功能打开时,设备将进入休眠状态,此时设备的Wi-Fi功能将会自动关闭。
+tsw_note_on = 定时唤醒时间:您可以设置设备唤醒时间。
+tsw_note_off = 定时休眠时间:您可以设置设备定时休眠时间。
+
+parent_control_note_kids = 儿童组设备:显示当前儿童组设备。
+parent_control_note_manage = 儿童组管理:管理儿童组设备,您可以从当前连接设备列表添加儿童组设备。
+parent_control_note_time = 上网时间设置:设置儿童上网时间规则,即允许儿童设备上网的时间。
+parent_control_note_whitelist = 网站白名单:设置网站白名单,即允许儿童设备访问的网站。
+parent_control_note_siteName = 白名单网站名不能包含以下字符: < > [ ] * $ & : , ; " ' ` / \\ | ? ¥
+parent_control_note_siteLink = 白名单链接输入时请以“http://”或“https://”开头。
+firewal_note = 注意:防火墙相关的规则设置,可能不会立即生效,需等待几分钟或重启设备,如需立即生效,建议重启设备。
+
+wan_note_dial = 拨号方式:
+wan_note_connection_mode = 请为您的设备设置合适的网络连接方式:
+wan_note_connection_mode_pppoe = PPPoE:通过PPPoE方式接入外网,您需要向您的运营商咨询PPPoE用户名和密码。
+wan_note_connection_mode_dhcp = 动态IP:通过动态IP地址方式接入外网。
+wan_note_connection_mode_static = 静态IP:通过设置静态IP地址的方式接入外网,您需要设置IP地址、子网掩码、默认网关、首选DNS及备用DNS。
+wan_note_user_name = 用户名:填写您的PPPoE帐号。
+wan_note_password = 密码:填写您的PPPoE密码。
+wan_note_connection_mode_auto = 自动:自动选择动态IP或PPPoE方式接入外网,您需要向您的运营商咨询PPPoE用户名和密码。
+
+wps_pin_validator = 请输入有效的PIN码
+device_rename = 请输入有效的名称。
+
+turnoff_button = 关机
+others_turn_off = 关机
+turnoff_confirm = 确定关机吗?
+turnoff = 关机中...
+setting_no_change = 您的设置未发生变化。
+Extend_accessDevice = WIFI最大接入数不能小于当前接入设备数。
+TBcheck = 请输入一个介于1和4095之间的值。
+apn_pdptype_change_note = 如果该设置被改变,通过域名 {0} 访问Web页面可能存在打不开的风险,这时候请尝试 {1} 来访问。
+apn_alert = 当前操作将会重启设备。是否继续?
+apn_alert_restart = 默认APN设置成功,设备正在重启。
+apn_diconneted_network_confirm = 当前操作将会断开网络,是否继续?
+
+#super
+super = 锁小区设置
+lockCell_settings = 锁小区设置
+v4_settings = 机卡互锁 (V4 加密)
+
+cell_id1 = Cell Id 1
+cell_id2 = Cell Id 2
+cell_id3 = Cell Id 3
+cell_id4 = Cell Id 4
+cell_id5 = Cell Id 5
+
+v4_check = 无效字符,只能输入 0-9、a-z、A-Z
+v4_note = 您的设置将在设备重启后生效,您要继续吗?
+export_title = 导出设置
+band_3 = 频段 3
+band_8 = 频段 8
+band_38 = 频段 38
+band_39 = 频段 39
+band_40 = 频段 40
+band_info = 频段设置
+cell_id = 当前注册的小区
+lock_apply = 加锁
+unlock_apply= 解锁
+band_cell_settings = 频段小区设置
+export = 导出
+sinr = SINR
+cell_not_correct = 非锁定小区,联网失败!
+cell_id_lock = 已锁定的小区
+
+sip_uri_format = URI 模式
+user_name = 用户名
+pin_v4_encrypt = PIN 加密
+wep_cannot_2040 = 当主SSID或者副SSID的安全模式是OPEN (WEP)或者SHARED的时候,频带宽度不能是20MHz/40MHz!
+2040_cannot_wep = 当频带宽度是20MHz/40MHz的时候,SSID的安全模式不能为OPEN (WEP)或者SHARED。
+wifi_device_busy = Wi-Fi驱动繁忙中,请稍等...
+v4_settings = 机卡互锁 (V4 加密)
+manufactory_code = 厂商代码
+key_version_number = 密钥版本号
+key_value = 密钥值
+
+LockCell_note1 = 锁小区功能是用于对LTE网络的小区锁定,当前注册小区与锁定小区一致时允许联网,当前注册小区与锁定小区不一致时禁止发起联网。
+LockCell_note2 = 锁定小区功能开启且保存的锁定小区不为空时,每天开机和定时(8:00/14:00/20:00)比对当前注册的网络小区与锁定小区是否相同,如果不同则做断网处理。
+mac_blank = MAC地址不能为空
+
+vlan_switch = VLAN开关
+vlan_notice = 如果您要停用该功能,重启后才生效。请问您是否继续?
+vlan_notice2 = 如果您要开启该功能,多重网络名称开关必须是开启状态。请问您是否开启多重网络名称开关并开启VLAN功能?
+ap_hide = AP隐藏
+
+urlparent = 主域名后面不能再跟随以/开始的内容。
+not_change_mode = 设备正在后台配置相关参数,请稍后尝试
+
+
+#device
+device_status = 设备加密状态
+device_status_0 = 已解密
+device_status_1 = 未解密
+
+######DDNS###########
+ddns = DDNS
+Hash value is empty = Hash 值为空!
+DDNS Provider is empty = DDNS 服务器为空!
+register successful = 注册成功
+login error = 登陆错误
+network error = 网络错误
+registering = 正在注册
+not registered = 未注册
+error registering = 注册失败
+error = 错误
+ddns_set_mode = DDNS
+mode_set_mode_1 = 启用
+mode_set_mode_0 = 禁用
+mode_select_auto = 自动
+mode_select_manual = 手动
+ddns_mode = DDNS 模式
+Auto = 自动
+Manual = 手动
+DDNS_Status = DDNS 状态
+DDNSHashValue = Hash 值
+ddns_ProviderList = 动态DNS服务器
+ddns_account = 用户
+ddns_passwd = 密码
+ddns_domainName = 域名
+ddns_hashvalue_check = 无效字符,只能输入 0-9、a-z、A-Z 或 =
+ddns_note1 = 您可以设置动态域名服务,为动态WAN IP地址分配一个固定域名。
+ddns_note2 = 动态DNS服务器:设置提供动态域名服务的服务器。
+ddns_note3 = 密码:密码的有效字符包含:0-9 a-z A-Z ! # $ * + , - . % : = ? @ [ ] ^ _ { | } ~
+ddns_note4 = 域名:设置要申请的域名。
+ddns_note5 = Hash 值:DDNS哈希值,在使用freedns服务器的时候需要。有效字符包含:0-9 a-z A-Z 或 =
diff --git a/lynq/R305/ap/app/zte_webui/js/com.js b/lynq/R305/ap/app/zte_webui/js/com.js
new file mode 100755
index 0000000..70ea0b9
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/js/com.js
@@ -0,0 +1,11213 @@
+
+define("service","underscore jquery set CryptoJS".split(" "), function (_, $, config, CryptoJS) {
+ function addTimerSomething(querys, cb) {
+ if (_.isArray(querys)) {
+ for (var i = 0; i < querys.length; i++) {
+ addQueryString(querys[i]);
+ }
+ } else {
+ addQueryString(querys);
+ }
+ addCallback(cb);
+ }
+ function removeTimerSomething(querys, cb) {
+ if (_.isArray(querys)) {
+ for (var i = 0; i < querys.length; i++) {
+ removeQueryString(querys[i]);
+ }
+ } else {
+ removeQueryString(querys);
+ }
+ removeCallback(cb);
+ }
+ function getCurretnMAC() {
+ return getUserMacAddr({}).get_user_mac_addr;
+ }
+ function getDdnsParams(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: 1,
+ cmd: "DDNS_Enable,DDNS_Mode,DDNSProvider,DDNSAccount,DDNSPassword,DDNS,DDNS_Hash_Value"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ DDNS_Enable: paramD.DDNS_Enable,
+ DDNS_Mode: paramD.DDNS_Mode,
+ DDNSProvider: paramD.DDNSProvider,
+ DDNSAccount: paramD.DDNSAccount,
+ DDNSPassword: paramD.DDNSPassword,
+ DDNS: paramD.DDNS,
+ DDNS_Hash_Value: paramD.DDNS_Hash_Value
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setDDNSForward() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = $.extend({}, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getLoginData() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "modem_main_state,puknumber,pinnumber,blc_wan_mode,blc_wan_auto_mode,psw_fail_num_str,login_lock_time,psw_changed";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.blc_wan_mode == "AUTO") {
+ paramD.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
+ } else {
+ paramD.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
+ }
+ paramD.psw_fail_num_str = paramD.psw_fail_num_str == '' ? config.MAX_LOGIN_COUNT : paramD.psw_fail_num_str;
+ paramD.login_lock_time = paramD.login_lock_time == '' ? '300' : paramD.login_lock_time;
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function login() {
+ return stuffMake(arguments, {}, prepare, deal, {
+ errorType: 'badPassword'
+ }, true);
+ function prepare(values, isPost) {
+ var obj = {
+ goformId: "LOGIN",
+ password: config.PASSWORD_ENCODE ? Base64.encode(values.password) : values.password
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && (paramD.result == "0" || paramD.result == "4")) {
+ informationAll.isLoggedIn = true;
+ return {
+ result: true
+ };
+ } else {
+ var loginError = {};
+ switch (paramD.result) {
+ case "1":
+ loginError = {
+ errorType: "Login Fail"
+ };
+ break;
+ case "2":
+ loginError = {
+ errorType: "duplicateUser"
+ };
+ break;
+ case "3":
+ loginError = {
+ errorType: "badPassword"
+ };
+ break;
+ default:
+ loginError = {
+ errorType: "Login Fail"
+ };
+ break;
+ }
+ informationAll.isLoggedIn = false;
+ return $.extend(errUnknownObj, loginError);
+ }
+ }
+ }
+ function getLoginStatus() {
+ if (informationAll.isLoggedIn != undefined) {
+ return stuffMake(arguments, {
+ status: informationAll.isLoggedIn ? 'loggedIn' : 'loggedOut'
+ });
+ } else {
+ var resultObject = {};
+ if (!config.HAS_LOGIN) {
+ resultObject.status = 'loggedIn';
+ resultObject.errorType = 'no_login';
+ informationAll.isLoggedIn = true;
+ }
+ return stuffMake(arguments, resultObject, prepare, deal, null, false);
+ }
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "loginfo";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.loginfo || paramD.loginfo == "") {
+ var loginStatus = {};
+ switch (paramD.loginfo) {
+ case "ok":
+ informationAll.isLoggedIn = true;
+ loginStatus.status = "loggedIn";
+ break;
+ default:
+ informationAll.isLoggedIn = false;
+ loginStatus.status = "loggedOut";
+ break;
+ }
+ return loginStatus;
+ } else {
+ informationAll.isLoggedIn = undefined;
+ return $.extend(errUnknownObj, {
+ errorType: "LoginStatusError"
+ });
+ }
+ }
+ }
+ function enterPIN() {
+ return stuffMake(arguments, {}, prepare, deal, {}, true);
+ function prepare(values, isPost) {
+ var obj = {};
+ obj.goformId = "ENTER_PIN";
+ obj.PinNumber = values.PinNumber;
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result === "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function enterPUK() {
+ return stuffMake(arguments, {}, prepare, deal, {}, true);
+ function prepare(values, isPost) {
+ var obj = {};
+ obj.goformId = "ENTER_PUK";
+ obj.PUKNumber = values.PUKNumber;
+ obj.PinNumber = values.PinNumber;
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result === "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+
+ function getStatusInfo() {
+ if (informationAll.isLoggedIn === undefined) {
+ var loginStatus = getLoginStatus();
+ return {
+ networkType: informationAll.networkType,
+ signalImg: informationAll.signalImg,
+ networkOperator: informationAll.networkOperator,
+ spn_b1_flag: informationAll.spn_b1_flag,
+ spn_name_data: informationAll.spn_name_data,
+ spn_b2_flag: informationAll.spn_b2_flag,
+ connectStatus: informationAll.connectStatus,
+ rj45ConnectStatus: informationAll.rj45ConnectStatus,
+ ssid1AttachedNum: informationAll.ssid1AttachedNum,
+ ssid2AttachedNum: informationAll.ssid2AttachedNum,
+ wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,
+ roamingStatus: informationAll.roamingStatus,
+ wifiStatus: informationAll.wifiStatus,
+ simStatus: informationAll.simStatus,
+ pinStatus: informationAll.pinStatus,
+ batteryStatus: informationAll.batteryStatus,
+ batteryLevel: informationAll.batteryLevel,
+ batteryPers: informationAll.batteryPers,
+ batteryTime: informationAll.batteryTime,
+ ssid: informationAll.ssid,
+ authMode: informationAll.authMode,
+ data_counter: informationAll.data_counter,
+ isLoggedIn: loginStatus.status == "loggedIn",
+ newSmsReceived: informationAll.newSmsReceived,
+ smsReportReceived: informationAll.smsReportReceived,
+ smsUnreadCount: informationAll.smsUnreadCount,
+ limitVolumeEnable: informationAll.limitVolumeEnable,
+ limitVolumeType: informationAll.limitVolumeType,
+ limitVolumePercent: informationAll.limitVolumePercent,
+ limitVolumeSize: informationAll.limitVolumeSize,
+ connectWifiProfile: informationAll.connectWifiProfile,
+ connectWifiSSID: informationAll.connectWifiSSID,
+ connectWifiStatus: informationAll.connectWifiStatus,
+ multi_ssid_enable: informationAll.multi_ssid_enable,
+ roamMode: informationAll.roamMode,
+ blc_wan_mode: informationAll.blc_wan_mode,
+ current_upgrade_state: informationAll.current_upgrade_state,
+ is_mandatory: informationAll.is_mandatory,
+ new_version_state: informationAll.new_version_state,
+ allowRoamingUpdate: informationAll.allowRoamingUpdate,
+ ap_station_enable: informationAll.ap_station_enable,
+ ap_station_mode: informationAll.ap_station_mode,
+ dialMode: informationAll.dialMode,
+ fota_package_already_download: informationAll.fota_package_already_download,
+ ethWanMode: informationAll.ethWanMode,
+ fota_user_selector: informationAll.fota_user_selector,
+ defaultWanName: informationAll.defaultWanName
+ };
+ }
+ return {
+ networkType: informationAll.networkType,
+ signalImg: informationAll.signalImg,
+ networkOperator: informationAll.networkOperator,
+ spn_b1_flag: informationAll.spn_b1_flag,
+ spn_name_data: informationAll.spn_name_data,
+ spn_b2_flag: informationAll.spn_b2_flag,
+ connectStatus: informationAll.connectStatus,
+ rj45ConnectStatus: informationAll.rj45ConnectStatus,
+ ssid1AttachedNum: informationAll.ssid1AttachedNum,
+ ssid2AttachedNum: informationAll.ssid2AttachedNum,
+ wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,
+ roamingStatus: informationAll.roamingStatus,
+ wifiStatus: informationAll.wifiStatus,
+ simStatus: informationAll.simStatus,
+ pinStatus: informationAll.pinStatus,
+ batteryStatus: informationAll.batteryStatus,
+ batteryLevel: informationAll.batteryLevel,
+ batteryPers: informationAll.batteryPers,
+ batteryTime: informationAll.batteryTime,
+ ssid: informationAll.ssid,
+ authMode: informationAll.authMode,
+ data_counter: informationAll.data_counter,
+ isLoggedIn: informationAll.isLoggedIn,
+ newSmsReceived: informationAll.newSmsReceived,
+ smsReportReceived: informationAll.smsReportReceived,
+ smsUnreadCount: informationAll.smsUnreadCount,
+ limitVolumeEnable: informationAll.limitVolumeEnable,
+ limitVolumeType: informationAll.limitVolumeType,
+ limitVolumePercent: informationAll.limitVolumePercent,
+ limitVolumeSize: informationAll.limitVolumeSize,
+ connectWifiProfile: informationAll.connectWifiProfile,
+ connectWifiSSID: informationAll.connectWifiSSID,
+ connectWifiStatus: informationAll.connectWifiStatus,
+ multi_ssid_enable: informationAll.multi_ssid_enable,
+ blc_wan_mode: informationAll.blc_wan_mode,
+ roamMode: informationAll.roamMode,
+ current_upgrade_state: informationAll.current_upgrade_state,
+ is_mandatory: informationAll.is_mandatory,
+ new_version_state: informationAll.new_version_state,
+ allowRoamingUpdate: informationAll.allowRoamingUpdate,
+ ap_station_enable: informationAll.ap_station_enable,
+ ap_station_mode: informationAll.ap_station_mode,
+ dialMode: informationAll.dialMode,
+ fota_package_already_download: informationAll.fota_package_already_download,
+ ethWanMode: informationAll.ethWanMode,
+ fota_user_selector: informationAll.fota_user_selector,
+ defaultWanName: informationAll.defaultWanName
+ };
+ }
+ function getConnectionInfo() {
+ var isData = informationAll.limitVolumeType == '1';
+ var result = {
+ data_counter: informationAll.data_counter,
+ connectStatus: informationAll.connectStatus,
+ rj45ConnectStatus: informationAll.rj45ConnectStatus,
+ limitVolumeEnable: informationAll.limitVolumeEnable,
+ limitVolumeType: informationAll.limitVolumeType,
+ limitVolumePercent: informationAll.limitVolumePercent,
+ networkType: informationAll.networkType
+ };
+ if (isData) {
+ result.limitDataMonth = informationAll.limitVolumeSize;
+ result.limitTimeMonth = 0;
+ } else {
+ result.limitTimeMonth = informationAll.limitVolumeSize;
+ result.limitDataMonth = 0;
+ }
+ result.blc_wan_mode = informationAll.blc_wan_mode;
+ return result;
+ }
+ function resetNewSmsReceivedVar() {
+ informationAll.newSmsReceived = false;
+ }
+ function resetSmsReportReceivedVar() {
+ informationAll.smsReportReceived = false;
+ }
+ function getSmsCapability() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "sms_capacity_info";
+ return valueReq;
+ }
+ function deal(paramD) {
+ return {
+ nvTotal: parseInt(paramD.sms_nv_total, 10),
+ nvUsed: parseInt(paramD.sms_nv_rev_total, 10) + parseInt(paramD.sms_nv_send_total, 10) + parseInt(paramD.sms_nv_draftbox_total, 10),
+ simTotal: parseInt(paramD.sms_sim_total, 10),
+ simUsed: parseInt(paramD.sms_sim_rev_total, 10) + parseInt(paramD.sms_sim_send_total, 10) + parseInt(paramD.sms_sim_draftbox_total, 10),
+ nvReceive: parseInt(paramD.sms_nv_rev_total, 10),
+ nvSend: parseInt(paramD.sms_nv_send_total, 10),
+ nvDraft: parseInt(paramD.sms_nv_draftbox_total, 10),
+ simReceive: parseInt(paramD.sms_sim_rev_total, 10),
+ simSend: parseInt(paramD.sms_sim_send_total, 10),
+ simDraft: parseInt(paramD.sms_sim_draftbox_total, 10)
+ };
+ }
+ }
+ function connect() {
+ var callback = arguments[1];
+ var checkPoint = 0;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.notCallback = true;
+ valueReq.goformId = "CONNECT_NETWORK";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ checkPoint = new Date().getTime();
+ addCallback(checkConnectStatus);
+ } else {
+ callback({
+ result: false
+ });
+ }
+ }
+ function checkConnectStatus(paramD) {
+ if (paramD.ppp_status == "ppp_connecting") {
+ informationAll.connectStatus = "ppp_connecting";
+ } else if (paramD.ppp_status == "ppp_connected") {
+ removeCallback(checkConnectStatus);
+ informationAll.connectStatus = "ppp_connected";
+ callback({
+ result: true,
+ status: informationAll.connectStatus
+ });
+ } else if (new Date().getTime() - checkPoint < 1e4) {
+ informationAll.connectStatus = "ppp_connecting";
+ } else {
+ removeCallback(checkConnectStatus);
+ callback({
+ result: false
+ });
+ }
+ }
+ }
+ function disconnect() {
+ var callback = arguments[1];
+ var checkPoint = 0;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.notCallback = true;
+ valueReq.goformId = "DISCONNECT_NETWORK";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ checkPoint = new Date().getTime();
+ addCallback(checkDisconnectStatus);
+ } else {
+ callback({
+ result: false
+ });
+ }
+ }
+ function checkDisconnectStatus(paramD) {
+ if (paramD.ppp_status == "ppp_disconnecting") {
+ informationAll.connectStatus = "ppp_disconnecting";
+ } else if (paramD.ppp_status == "ppp_disconnected") {
+ removeCallback(checkDisconnectStatus);
+ informationAll.connectStatus = "ppp_disconnected";
+ callback({
+ result: true,
+ status: informationAll.connectStatus
+ });
+ } else if (new Date().getTime() - checkPoint < 1e4) {
+ informationAll.connectStatus = "ppp_disconnecting";
+ } else {
+ removeCallback(checkDisconnectStatus);
+ callback({
+ result: false
+ });
+ }
+ }
+ }
+ function getApnSettings() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "APN_configtmp0,APN_configtmp1,APN_configtmp2,APN_configtmp3,APN_configtmp4,APN_configtmp5,APN_configtmp6,APN_configtmp7,APN_configtmp8,APN_configtmp9," + "APN_configtmp10,APN_configtmp11,APN_configtmp12,APN_configtmp13,APN_configtmp14,APN_configtmp15,APN_configtmp16,APN_configtmp17,APN_configtmp18,APN_configtmp19," + "ipv6_APN_configtmp0,ipv6_APN_configtmp1,ipv6_APN_configtmp2,ipv6_APN_configtmp3,ipv6_APN_configtmp4,ipv6_APN_configtmp5,ipv6_APN_configtmp6,ipv6_APN_configtmp7,ipv6_APN_configtmp8,ipv6_APN_configtmp9," + "ipv6_APN_configtmp10,ipv6_APN_configtmp11,ipv6_APN_configtmp12,ipv6_APN_configtmp13,ipv6_APN_configtmp14,ipv6_APN_configtmp15,ipv6_APN_configtmp16,ipv6_APN_configtmp17,ipv6_APN_configtmp18,ipv6_APN_configtmp19," + "m_profile_name,profile_name,wan_dial,pdp_type,pdp_select,index,Current_index,apn_auto_config,ipv6_apn_auto_config," + "apn_mode,wan_apn,ppp_auth_mode,ppp_username,ppp_passtmp," + "ipv6_wan_apn,ipv6_pdp_type,ipv6_ppp_auth_mode,ipv6_ppp_username,ipv6_ppp_passtmp,apn_num_preset";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(result) {
+ if (result) {
+ return {
+ APNs: result.APN_configtmp0 + "||" + result.APN_configtmp1 + "||" + result.APN_configtmp2 + "||" + result.APN_configtmp3 + "||" + result.APN_configtmp4 + "||"
+ +result.APN_configtmp5 + "||" + result.APN_configtmp6 + "||" + result.APN_configtmp7 + "||" + result.APN_configtmp8 + "||" + result.APN_configtmp9 + "||"
+ +result.APN_configtmp10 + "||" + result.APN_configtmp11 + "||" + result.APN_configtmp12 + "||" + result.APN_configtmp13 + "||" + result.APN_configtmp14 + "||"
+ +result.APN_configtmp15 + "||" + result.APN_configtmp16 + "||" + result.APN_configtmp17 + "||" + result.APN_configtmp18 + "||" + result.APN_configtmp19,
+ ipv6APNs: result.ipv6_APN_configtmp0 + "||" + result.ipv6_APN_configtmp1 + "||" + result.ipv6_APN_configtmp2 + "||" + result.ipv6_APN_configtmp3 + "||" + result.ipv6_APN_configtmp4 + "||"
+ +result.ipv6_APN_configtmp5 + "||" + result.ipv6_APN_configtmp6 + "||" + result.ipv6_APN_configtmp7 + "||" + result.ipv6_APN_configtmp8 + "||" + result.ipv6_APN_configtmp9 + "||"
+ +result.ipv6_APN_configtmp10 + "||" + result.ipv6_APN_configtmp11 + "||" + result.ipv6_APN_configtmp12 + "||" + result.ipv6_APN_configtmp13 + "||" + result.ipv6_APN_configtmp14 + "||"
+ +result.ipv6_APN_configtmp15 + "||" + result.ipv6_APN_configtmp16 + "||" + result.ipv6_APN_configtmp17 + "||" + result.ipv6_APN_configtmp18 + "||" + result.ipv6_APN_configtmp19,
+ apnMode: result.apn_mode,
+ profileName: result.m_profile_name || result.profile_name,
+ wanDial: result.wan_dial,
+ pdpType: result.pdp_type == 'IP' ? 'IP' : result.ipv6_pdp_type,
+ pdpSelect: result.pdp_select,
+ index: result.index,
+ currIndex: result.Current_index,
+ autoApns: result.apn_auto_config,
+ autoApnsV6: result.ipv6_apn_auto_config,
+ wanApn: result.wan_apn,
+ authMode: result.ppp_auth_mode.toLowerCase(),
+ username: result.ppp_username,
+ password: result.ppp_passtmp,
+ dnsMode: "",
+ dns1: "",
+ dns2: "",
+ wanApnV6: result.ipv6_wan_apn,
+ authModeV6: result.ipv6_ppp_auth_mode.toLowerCase(),
+ usernameV6: result.ipv6_ppp_username,
+ passwordV6: result.ipv6_ppp_passtmp,
+ dnsModeV6: "",
+ dns1V6: "",
+ dns2V6: "",
+ apnNumPreset: result.apn_num_preset
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function deleteApn() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ apn_action: "delete",
+ apn_mode: "manual",
+ index: values.index
+ };
+ valueReq.goformId = "APN_PROC_EX";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function setDefaultApn() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var requestParam = {
+ goformId: "APN_PROC_EX",
+ apn_mode: values.apnMode
+ };
+ if (values.apnMode == 'manual') {
+ requestParam.apn_action = "set_default";
+ requestParam.set_default_flag = "1";
+ requestParam.pdp_type = values.pdpType;
+ requestParam.index = values.index;
+ }
+ return requestParam;
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function addOrEditApn() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "APN_PROC_EX",
+ apn_action: "save",
+ apn_mode: "manual",
+ profile_name: values.profileName,
+ wan_dial: '*99#',
+ pdp_type: values.pdpType,
+ pdp_select: 'auto',
+ index: values.index
+ };
+ if (values.pdpType == "IP") {
+ $.extend(valueReq, {
+ wan_apn: values.wanApn,
+ ppp_auth_mode: values.authMode,
+ ppp_username: values.username,
+ ppp_passtmp: values.password,
+ });
+ } else if (values.pdpType == "IPv6") {
+ $.extend(valueReq, {
+ ipv6_wan_apn: values.wanApnV6,
+ ipv6_ppp_auth_mode: values.authModeV6,
+ ipv6_ppp_username: values.usernameV6,
+ ipv6_ppp_passtmp: values.passwordV6
+ });
+ } else {
+ $.extend(valueReq, {
+ wan_apn: values.wanApn,
+ ppp_auth_mode: values.authMode,
+ ppp_username: values.username,
+ ppp_passtmp: values.password,
+ dns_mode: values.dnsMode,
+ prefer_dns_manual: values.dns1,
+ standby_dns_manual: values.dns2,
+ ipv6_wan_apn: values.wanApnV6,
+ ipv6_ppp_auth_mode: values.authModeV6,
+ ipv6_ppp_username: values.usernameV6,
+ ipv6_ppp_passtmp: values.passwordV6
+ });
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ var timerQueryString = ["modem_main_state", "pin_status", "blc_wan_mode", "blc_wan_auto_mode", "loginfo", "fota_new_version_state", "fota_current_upgrade_state", "fota_upgrade_selector", "network_provider", "is_mandatory", "sta_count", "m_sta_count"];
+ var loginTimerQueryString = ["signalbar", "network_type", "sub_network_type", "ppp_status", "rj45_state", "EX_SSID1", "sta_ip_status", "EX_wifi_profile", "m_ssid_enable", "wifi_cur_state", "SSID1", "simcard_roam", "lan_ipaddr", "battery_charging", "battery_vol_percent", "battery_pers", "spn_name_data", "spn_b1_flag", "spn_b2_flag", "realtime_tx_bytes", "realtime_rx_bytes", "realtime_time", "realtime_tx_thrpt", "realtime_rx_thrpt", "monthly_rx_bytes", "monthly_tx_bytes", "traffic_alined_delta", "monthly_time", "date_month", "data_volume_limit_switch", "data_volume_limit_size", "data_volume_alert_percent", "data_volume_limit_unit", "roam_setting_option", "upg_roam_switch", "fota_package_already_download", 'ssid', 'dial_mode', 'ethwan_mode', 'default_wan_name'];
+ if (config.HAS_SMS) {
+ $.merge(loginTimerQueryString, ["sms_received_flag", "sts_received_flag", 'sms_unread_num']);
+ }
+ var timerCallbackStack = [];
+ var timerCallbacks = [timerUpdateStatus];
+ function timerUpdater() {
+ if (!updateTimerFlag) {
+ setTimeout(function () {
+ timerUpdater();
+ }, 1000);
+ return;
+ }
+ var queryParams = checkTimerUpdaterParameters();
+ reqAsync(queryParams, function (paramD) {
+ for (var i = 0; i < timerCallbacks.length; i++) {
+ if (typeof timerCallbacks[i] === "function") {
+ timerCallbacks[i](paramD);
+ }
+ }
+ $.merge(timerCallbacks, timerCallbackStack);
+ timerCallbackStack = [];
+ setTimeout(function () {
+ timerUpdater();
+ }, 1000);
+ }, function () {
+ timerUpdaterErrorCallback();
+ setTimeout(function () {
+ timerUpdater();
+ }, 1000);
+ }, false);
+ }
+ function checkTimerUpdaterParameters() {
+ var queryParams = {
+ multi_data: 1,
+ };
+ if (window.location.hash && window.location.hash != '#entry' && informationAll.isLoggedIn) {
+ if (config.HAS_SMS) {
+ queryParams.sms_received_flag_flag = 0;
+ queryParams.sts_received_flag_flag = 0;
+ }
+ if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) == -1) {
+ $.each(loginTimerQueryString, function (i, n) {
+ timerQueryString.push(n);
+ });
+ }
+ } else {
+ if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) != -1) {
+ timerQueryString = _.without(timerQueryString, loginTimerQueryString);
+ }
+ }
+ queryParams.cmd = timerQueryString.join(",");
+ return queryParams;
+ }
+ function addCallback(cb) {
+ if (_.indexOf(timerCallbackStack, cb) == -1) {
+ timerCallbackStack.push(cb);
+ }
+ }
+ function removeCallback(cb) {
+ timerCallbacks = _.without(timerCallbacks, cb);
+ if (timerCallbacks.length == 0) {
+ timerCallbacks.push(timerUpdateStatus);
+ }
+ return timerCallbackStack;
+ }
+ function addQueryString(query) {
+ if (_.indexOf(timerQueryString, query) == -1) {
+ timerQueryString.push(query);
+ }
+ }
+ function removeQueryString(query) {
+ timerQueryString = _.without(timerQueryString, query);
+ return timerQueryString;
+ }
+ function timerUpdateStatus(paramD) {
+ informationAll.defaultWanName = paramD.default_wan_name;
+ informationAll.signalImg = typeof paramD.signalbar == 'undefined' ? '0' : paramD.signalbar;
+ informationAll.networkType = paramD.sub_network_type ? paramD.sub_network_type : (paramD.network_type ? paramD.network_type : '');
+ if (informationAll.networkType.toLowerCase().indexOf("limited_service") != -1 || informationAll.networkType.toLowerCase().indexOf("limited service") != -1) {
+ informationAll.networkType = "limited_service";
+ } else if (informationAll.networkType.toLowerCase().indexOf("no_service") != -1 || informationAll.networkType.toLowerCase().indexOf("no service") != -1) {
+ informationAll.networkType = "no_service";
+ }
+ informationAll.networkOperator = paramD.network_provider ? paramD.network_provider : '';
+ informationAll.spn_b1_flag = paramD.spn_b1_flag;
+ informationAll.spn_b2_flag = paramD.spn_b2_flag;
+ informationAll.spn_name_data = paramD.spn_name_data;
+ informationAll.connectStatus = typeof paramD.ppp_status == 'undefined' ? 'ppp_disconnected' : paramD.ppp_status;
+ informationAll.rj45ConnectStatus = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;
+ informationAll.ethWanMode = paramD.ethwan_mode;
+ informationAll.ssid1AttachedNum = paramD.sta_count == "" ? 0 : parseInt(paramD.sta_count, 10);
+ informationAll.ssid2AttachedNum = paramD.m_sta_count == "" ? 0 : parseInt(paramD.m_sta_count, 10);
+ informationAll.roamingStatus = getRoamStatus(informationAll.networkType, paramD.modem_main_state, paramD.simcard_roam);
+ informationAll.wifiStatus = paramD.wifi_cur_state == "1";
+ informationAll.simStatus = paramD.modem_main_state;
+ informationAll.pinStatus = paramD.pin_status;
+ var needMinutes = 3 * 60 * 60;
+ var batteryLevel = (paramD.battery_vol_percent && paramD.battery_vol_percent.length > 0) ? paramD.battery_vol_percent : 100;
+ informationAll.batteryPers = paramD.battery_pers;
+ var remainMinutes = Math.round(needMinutes * (1 - batteryLevel / 100));
+ informationAll.batteryStatus = (typeof paramD.battery_charging == 'undefined') ? '0' : paramD.battery_charging;
+ informationAll.batteryLevel = batteryLevel;
+ informationAll.batteryTime = remainMinutes.toString();
+ informationAll.data_counter = {
+ uploadRate: paramD.realtime_tx_thrpt == '' ? 0 : paramD.realtime_tx_thrpt,
+ downloadRate: paramD.realtime_rx_thrpt == '' ? 0 : paramD.realtime_rx_thrpt,
+ currentSent: paramD.realtime_tx_bytes == '' ? 0 : paramD.realtime_tx_bytes,
+ currentReceived: paramD.realtime_rx_bytes == '' ? 0 : paramD.realtime_rx_bytes,
+ currentConnectedTime: paramD.realtime_time == '' ? 0 : paramD.realtime_time,
+ monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,
+ monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,
+ traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta,
+ monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,
+ month: paramD.date_month == '' ? 1 : paramD.date_month
+ };
+ informationAll.ssid = paramD.SSID1;
+ informationAll.authMode = paramD.AuthMode;
+ informationAll.isLoggedIn = config.HAS_LOGIN ? paramD.loginfo == "ok" : true;
+ if (config.HAS_SMS) {
+ if (!informationAll.newSmsReceived) {
+ informationAll.newSmsReceived = paramD.sms_received_flag > 0;
+ }
+ if (!informationAll.smsReportReceived) {
+ informationAll.smsReportReceived = paramD.sts_received_flag > 0;
+ }
+ if (typeof paramD.sms_dev_unread_num != "undefined") {
+ informationAll.smsUnreadCount = config.SMS_UNREAD_NUM_INCLUDE_SIM ? parseInt(paramD.sms_dev_unread_num | 0, 10) + parseInt(paramD.sms_sim_unread_num | 0, 10) : parseInt(paramD.sms_dev_unread_num | 0, 10);
+ } else {
+ informationAll.smsUnreadCount = parseInt(paramD.sms_unread_num | 0, 10)
+ }
+ }
+ if (paramD.data_volume_limit_switch == '1') {
+ informationAll.limitVolumeEnable = true;
+ informationAll.limitVolumeType = paramD.data_volume_limit_unit == 'data' ? '1' : '0';
+ informationAll.limitVolumePercent = paramD.data_volume_alert_percent;
+ if (paramD.data_volume_limit_unit == 'data') {
+ var limitMonth = paramD.data_volume_limit_size.split("_");
+ informationAll.limitVolumeSize = limitMonth[0] * limitMonth[1] * 1024 * 1024;
+ } else {
+ informationAll.limitVolumeSize = paramD.data_volume_limit_size * 60 * 60;
+ }
+ } else {
+ informationAll.limitVolumeEnable = false;
+ informationAll.limitVolumeType = '1';
+ informationAll.limitVolumePercent = '100';
+ informationAll.limitVolumeSize = '0';
+ }
+ informationAll.connectWifiProfile = paramD.EX_wifi_profile;
+ informationAll.connectWifiSSID = paramD.EX_SSID1;
+ informationAll.connectWifiStatus = paramD.sta_ip_status;
+ informationAll.multi_ssid_enable = paramD.m_ssid_enable;
+ informationAll.roamMode = paramD.roam_setting_option;
+ if (paramD.blc_wan_mode == "AUTO") {
+ informationAll.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
+ } else {
+ informationAll.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
+ }
+ informationAll.new_version_state = paramD.fota_new_version_state == "has_critical" || paramD.fota_new_version_state == "has_optional" || paramD.fota_new_version_state == "already_has_pkg";
+ informationAll.current_upgrade_state = paramD.fota_current_upgrade_state;
+ if (informationAll.current_upgrade_state == "verify_failed") {
+ informationAll.current_upgrade_state = "upgrade_pack_error";
+ }
+ informationAll.fota_user_selector = paramD.fota_upgrade_selector;
+ informationAll.is_mandatory = paramD.is_mandatory == "1" || paramD.fota_new_version_state == "has_critical";
+ informationAll.allowRoamingUpdate = paramD.upg_roam_switch;
+ informationAll.dialMode = paramD.dial_mode;
+ informationAll.fota_package_already_download = paramD.fota_package_already_download;
+ }
+ function timerUpdaterErrorCallback() {
+ informationAll.batteryStatus = '0';
+ }
+ function getRoamStatus(networkType, modemState, simcardRoam) {
+ if (("" == $.trim(networkType)) || "no_service" == networkType.toLowerCase() || "limited_service" == networkType.toLowerCase() || "modem_sim_undetected" == modemState || "modem_waitpin" == modemState || "modem_waitpuk" == modemState) {
+ return false;
+ }
+ if ("Internal" == simcardRoam || "International" == simcardRoam) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ $(document).ready(function () {
+ setTimeout(function () {
+ timerUpdater();
+ }, 0);
+ });
+ function setNetwork(strNetworkNumber, nRat, nSubAct, callback) {
+ if ((typeof(strNetworkNumber) !== "string") || (strNetworkNumber === "") || (typeof(nRat) !== "number") || (isNaN(nRat))) {
+ if (typeof(callback) === "function") {
+ callback(false);
+ return;
+ }
+ }
+ var nRat1 = -1;
+ if (nRat === 0) {
+ nRat1 = 0;
+ } else if (nRat === 2) {
+ nRat1 = 2;
+ } else if (nRat == 7) {
+ nRat1 = 7;
+ } else {
+ nRat1 = -1;
+ }
+ if (-1 === nRat1) {
+ if (typeof(callback) === "function") {
+ callback(false);
+ return;
+ }
+ }
+ var SubAct;
+ if (nSubAct.toString() == "NaN") {
+ SubAct = "";
+ } else {
+ SubAct = nSubAct;
+ }
+ reqAsync({
+ goformId: "SET_NETWORK",
+ NetworkNumber: strNetworkNumber,
+ Rat: nRat,
+ nSubrat: SubAct
+ }, function (paramD) {
+ if (paramD && paramD.result == "success") {
+ var flag;
+ var counter = 0;
+ var timer = setInterval(function () {
+ var obj = reqSync({
+ cmd: 'm_netselect_result',
+ }, false);
+ if (!obj) {
+ callback(false);
+ return;
+ }
+ if (obj.m_netselect_result == "manual_success") {
+ flag = "1";
+ window.clearInterval(timer);
+ callback(true);
+ } else if (obj.m_netselect_result == "manual_fail") {
+ flag = "0";
+ window.clearInterval(timer);
+ callback(false);
+ } else if (counter < 120) {
+ counter++;
+ } else {
+ window.clearInterval(timer);
+ callback(false);
+ }
+ }, 1000);
+ } else {
+ callback(false);
+ }
+ }, function (paramD) {
+ callback(false);
+ }, true);
+ }
+ function savePhoneBook() {
+ var callback = arguments[1];
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.notCallback = true;
+ valueReq.goformId = "PBM_CONTACT_ADD";
+ valueReq.location = values.location;
+ valueReq.name = encodeMessage(values.name);
+ valueReq.mobilephone_num = values.mobile_phone_number;
+ if (valueReq.location == 1) {
+ valueReq.add_index_pc = values.index;
+ valueReq.homephone_num = values.home_phone_number;
+ valueReq.officephone_num = values.office_phone_number;
+ valueReq.email = encodeMessage(values.mail);
+ valueReq.groupchoose = values.group;
+ if (!valueReq.groupchoose) {
+ valueReq.groupchoose = "common";
+ }
+ } else {
+ valueReq.edit_index = values.index;
+ }
+ if (values.delId != undefined) {
+ valueReq.delId = values.delId;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ addTimerSomething("pbm_write_flag", checkSavePhoneBook);
+ } else {
+ callback(paramD);
+ }
+ }
+ function checkSavePhoneBook(paramD) {
+ checkPbmWriteFlag(paramD, callback, checkSavePhoneBook);
+ }
+ }
+ function checkPbmWriteFlag(paramD, callback, fn) {
+ if (paramD.pbm_write_flag == "0") {
+ removeTimerSomething("pbm_write_flag", fn);
+ callback({
+ result: "success"
+ });
+ } else if (paramD.pbm_write_flag == "6" || paramD.pbm_write_flag == "7" || paramD.pbm_write_flag == "8" || paramD.pbm_write_flag == "9" || paramD.pbm_write_flag == "10" || paramD.pbm_write_flag == "11" || paramD.pbm_write_flag == "14") {
+ removeTimerSomething("pbm_write_flag", fn);
+ callback({
+ result: "fail"
+ });
+ } else {}
+ }
+ function deletePhoneBooks() {
+ var callback = arguments[1];
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.notCallback = true;
+ valueReq.goformId = "PBM_CONTACT_DEL";
+ valueReq.del_option = "delete_num";
+ valueReq.delete_id = values.indexs.join(",");
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ addTimerSomething("pbm_write_flag", checkDeletePhoneBooks);
+ } else {
+ callback(paramD);
+ }
+ }
+ function checkDeletePhoneBooks(paramD) {
+ checkPbmWriteFlag(paramD, callback, checkDeletePhoneBooks);
+ }
+ }
+ function deleteAllPhoneBooks() {
+ var callback = arguments[1];
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.notCallback = true;
+ valueReq.goformId = "PBM_CONTACT_DEL";
+ valueReq.del_option = "delete_all";
+ valueReq.del_all_location = values.location;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooks);
+ } else {
+ callback(paramD);
+ }
+ }
+ function checkDeleteAllPhoneBooks(paramD) {
+ checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooks);
+ }
+ }
+ function deleteAllPhoneBooksByGroup() {
+ var callback = arguments[1];
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.notCallback = true;
+ valueReq.goformId = "PBM_CONTACT_DEL";
+ valueReq.del_option = "delete_all_by_group";
+ valueReq.del_all_location = 3;
+ valueReq.del_group = values.group;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooksByGroup);
+ } else {
+ callback(paramD);
+ }
+ }
+ function checkDeleteAllPhoneBooksByGroup(paramD) {
+ checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooksByGroup);
+ }
+ }
+ function setConnectionMode() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SET_CONNECTION_MODE";
+ valueReq.ConnectionMode = values.connectionMode;
+ valueReq.roam_setting_option = values.isAllowedRoaming;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ callback(paramD);
+ }
+ }
+ }
+ function getConnectionMode() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "ConnectionMode";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.connectionMode = paramD.connectionMode;
+ result.isAllowedRoaming = paramD.autoConnectWhenRoaming;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function _getPhoneBooks(array, location) {
+ if (array[0].data_per_page == 0) {
+ return {
+ "pbm_data": []
+ };
+ }
+ return stuffMake(array, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.mem_store = location;
+ if (location == 2) {
+ valueReq.cmd = "pbm_data_total";
+ } else {
+ valueReq.cmd = "pbm_data_info";
+ }
+ valueReq.page = values.page;
+ valueReq.data_per_page = values.data_per_page;
+ valueReq.orderBy = values.orderBy;
+ valueReq.isAsc = values.isAsc;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.pbm_data) {
+ var books = [];
+ $.each(paramD.pbm_data, function (i) {
+ books.push({
+ pbm_id: paramD.pbm_data[i].pbm_id,
+ pbm_location: paramD.pbm_data[i].pbm_location,
+ pbm_number: paramD.pbm_data[i].pbm_number,
+ pbm_anr: paramD.pbm_data[i].pbm_anr,
+ pbm_anr1: paramD.pbm_data[i].pbm_anr1,
+ pbm_group: paramD.pbm_data[i].pbm_group,
+ pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),
+ pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)
+ });
+ });
+ return {
+ pbm_data: books
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getPhoneBooksByGroup() {
+ if (arguments[0].data_per_page == 0) {
+ return {
+ "pbm_data": []
+ };
+ }
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "pbm_data_total";
+ valueReq.mem_store = 3;
+ valueReq.pbm_group = values.group;
+ valueReq.page = values.page;
+ valueReq.data_per_page = values.data_per_page;
+ valueReq.orderBy = values.orderBy;
+ valueReq.isAsc = values.isAsc;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.pbm_data) {
+ var books = [];
+ $.each(paramD.pbm_data, function (i) {
+ books.push({
+ pbm_id: paramD.pbm_data[i].pbm_id,
+ pbm_location: paramD.pbm_data[i].pbm_location,
+ pbm_number: paramD.pbm_data[i].pbm_number,
+ pbm_anr: paramD.pbm_data[i].pbm_anr,
+ pbm_anr1: paramD.pbm_data[i].pbm_anr1,
+ pbm_group: paramD.pbm_data[i].pbm_group,
+ pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),
+ pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)
+ });
+ });
+ return {
+ pbm_data: books
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getDevicePhoneBooks() {
+ return _getPhoneBooks(arguments, 1);
+ }
+ function getSIMPhoneBooks() {
+ return _getPhoneBooks(arguments, 0);
+ }
+ function getPhoneBooks() {
+ return _getPhoneBooks(arguments, 2);
+ }
+ function getPhoneBookReady() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "pbm_init_flag";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getPhoneBookCapacity(array, isSIM) {
+ return stuffMake(array, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "pbm_capacity_info";
+ if (isSIM) {
+ valueReq.pbm_location = "pbm_sim";
+ } else {
+ valueReq.pbm_location = "pbm_native";
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSIMPhoneBookCapacity() {
+ var paramD = getPhoneBookCapacity(arguments, true);
+ return {
+ simPbmTotalCapacity: parseInt(paramD.pbm_sim_max_record_num),
+ simPbmUsedCapacity: parseInt(paramD.pbm_sim_used_record_num),
+ simType: paramD.pbm_sim_type,
+ maxNameLen: parseInt(paramD.pbm_sim_max_name_len),
+ maxNumberLen: parseInt(paramD.pbm_sim_max_number_len) > 40 ? 40 : parseInt(paramD.pbm_sim_max_number_len)
+ };
+ }
+ function getDevicePhoneBookCapacity() {
+ var paramD = getPhoneBookCapacity(arguments, false);
+ return {
+ pcPbmTotalCapacity: parseInt(paramD.pbm_dev_max_record_num),
+ pcPbmUsedCapacity: parseInt(paramD.pbm_dev_used_record_num)
+ };
+ }
+ function getAttachedCableDevices() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var obj = {
+ cmd: "lan_station_list"
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ var deviceArr = [];
+ var attachedDevices = paramD.lan_station_list || paramD.station_list;
+ for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {
+ var obj = {};
+ obj.macAddress = attachedDevices[i].mac_addr;
+ var hostname = attachedDevices[i].hostname;
+ obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;
+ obj.ipAddress = attachedDevices[i].ip_addr;
+ deviceArr.push(obj);
+ }
+ return {
+ attachedDevices: deviceArr
+ };
+ }
+ }
+ function getCurrentlyAttachedDevicesInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var obj = {
+ cmd: "station_list"
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ var deviceArr = [];
+ var attachedDevices = paramD.station_list;
+ for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {
+ var obj = {};
+ obj.macAddress = attachedDevices[i].mac_addr;
+ var hostname = attachedDevices[i].hostname;
+ obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;
+ obj.ipAddress = attachedDevices[i].ip_addr;
+ deviceArr.push(obj);
+ }
+ return {
+ attachedDevices: deviceArr
+ };
+ }
+ }
+
+ function setLanguage() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SET_WEB_LANGUAGE";
+ valueReq.Language = values.Language;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getLanguage() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "Language";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.Language = (paramD && paramD.Language) ? paramD.Language : "en";
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+
+ function setBearerPreference() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SET_BEARER_PREFERENCE";
+ valueReq.BearerPreference = values.strBearerPreference;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function scanForNetwork(callback) {
+ $.post("/reqproc/proc_post", {
+ goformId: "SCAN_NETWORK"
+ }, function (paramD) {
+ if (paramD.result == "success") {
+ checkScanStatus();
+ } else {
+ callback(false, []);
+ }
+ }, "json").error(function () {
+ callback(false, []);
+ });
+ function checkScanStatus() {
+ $.getJSON("/reqproc/proc_get", {
+ cmd: "m_netselect_status",
+ "_": new Date().getTime()
+ }, function (paramD) {
+ if (paramD.m_netselect_status == "manual_selecting") {
+ setTimeout(checkScanStatus, 1000);
+ } else {
+ $.getJSON("/reqproc/proc_get", {
+ cmd: "m_netselect_contents",
+ "_": new Date().getTime()
+ }, function (paramD2) {
+ if (trim(paramD2.m_netselect_contents) != "") {
+ parseScanResult(paramD2.m_netselect_contents);
+ } else {
+ callback(false, []);
+ }
+ }).error(function () {
+ callback(false, []);
+ });
+ }
+ }).error(function () {
+ callback(false, []);
+ });
+ }
+ function parseScanResult(result) {
+ var pattern = /([^,;]*),([^,]*),([^,]*),([^,]*),([^,;]*)/g;
+ var listNetwork = [];
+ var mts;
+ var unit = result.split(";");
+ var unitString = "";
+ for (i = 0; i < unit.length; i++) {
+ var unitLength = unit[i].split(",").length;
+ if (unitLength == 4) {
+ unitString += unit[i] + ",NON;";
+ } else {
+ unitString += unit[i] + ";";
+ }
+ }
+ while (mts = pattern.exec(unitString)) {
+ if (mts != null) {
+ listNetwork.push({
+ strShortName: mts[2].replace(/\"/g, ''),
+ strNumeric: mts[3].replace(/\D/g, ''),
+ nRat: parseInt(mts[4], 10),
+ nState: parseInt(mts[1], 10),
+ SubAct: parseInt(mts[5], 10)
+ });
+ }
+ }
+ callback(true, listNetwork);
+ }
+ }
+ function getNetSelectInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "current_network_mode,m_netselect_save,net_select_mode,m_netselect_contents,net_select,ppp_status,modem_main_state";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.current_network_mode = paramD.current_network_mode;
+ result.net_select_mode = paramD.net_select_mode;
+ result.m_netselect_save = paramD.m_netselect_save;
+ result.m_netselect_contents = paramD.m_netselect_contents;
+ result.net_select = paramD.net_select;
+ result.ppp_status = paramD.ppp_status;
+ result.modem_main_state = paramD.modem_main_state;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+
+ function getSMSMessages() {
+ return stuffMake(arguments, {}, prepare, deal, {}, false);
+ function prepare(values, isPost) {
+ var obj = {
+ cmd: "sms_data_total",
+ page: values.page,
+ data_per_page: config.SMS_DATABASE_SORT_SUPPORT ? values.smsCount : 500,
+ mem_store: values.nMessageStoreType,
+ tags: values.tags,
+ order_by: values.orderBy
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.messages && paramD.messages.length > 0) {
+ return {
+ messages: parseMessages(paramD.messages)
+ };
+ } else {
+ return {
+ messages: []
+ };
+ }
+ }
+ }
+ function parseMessages(messages, isReport) {
+ var result = [];
+ for (var i = 0; i < messages.length; i++) {
+ if (!config.SHOW_UN_COMPLETE_CONCAT_SMS && typeof messages[i].received_all_concat_sms != "undefined" && messages[i].received_all_concat_sms == '0') {
+ continue;
+ }
+ var oneMessage = {};
+ oneMessage.id = messages[i].id;
+ oneMessage.number = messages[i].number;
+ oneMessage.content = isReport ? messages[i].content : decodeMessageContent(messages[i].content);
+ oneMessage.time = transTime('20' + messages[i].date);
+ oneMessage.isNew = messages[i].tag == "1";
+ oneMessage.groupId = messages[i].draft_group_id;
+ oneMessage.tag = messages[i].tag;
+ oneMessage.receivedAll = messages[i].received_all_concat_sms == '1';
+ result.push(oneMessage);
+ }
+ if (!config.SMS_DATABASE_SORT_SUPPORT) {
+ var ids = [];
+ var tmpResult = [];
+ for (var i = result.length; i--; ) {
+ var n = result[i];
+ var idx = $.inArray(n.id, ids);
+ if (idx == -1) {
+ ids.push(n.id);
+ tmpResult.push(n);
+ } else {
+ if (n.content.length > tmpResult[idx].content.length) {
+ tmpResult[idx] = n;
+ }
+ }
+ }
+ return _.sortBy(tmpResult, function (n) {
+ return 0 - n.id;
+ });
+ } else {
+ return result;
+ }
+ }
+ function decodeMessageContent(msgContent) {
+ return decodeMessage(escapeMessage(msgContent));
+ }
+ function sendSMS() {
+ var callback = arguments[1];
+ var errorCabllback = arguments[2] ? arguments[2] : callback;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = {
+ goformId: "SEND_SMS",
+ notCallback: true,
+ Number: values.number,
+ sms_time: getCurrentTimeString(),
+ MessageBody: escapeMessage(encodeMessage(values.message)),
+ ID: values.id,
+ encode_type: getEncodeType(values.message).encodeType
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (!paramD) {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "sendFail",
+ errorText: "send_fail_try_again"
+ }));
+ return;
+ }
+ if (paramD.result == "success") {
+ setTimeout(function () {
+ getSmsStatusInfo({
+ smsCmd: 4,
+ errorType: "sendFail",
+ errorText: "send_fail_try_again"
+ }, callback, errorCabllback);
+ }, 1000);
+ } else {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "sendFail",
+ errorText: "send_fail_try_again"
+ }));
+ }
+ }
+ }
+ function saveSMS() {
+ var callback = arguments[1];
+ var errorCabllback = arguments[2] ? arguments[2] : callback;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = {
+ notCallback: true,
+ goformId: "SAVE_SMS",
+ SMSMessage: escapeMessage(encodeMessage(values.message)),
+ SMSNumber: values.numbers.join(";") + ";",
+ Index: values.index,
+ encode_type: getEncodeType(values.message).encodeType,
+ sms_time: values.currentTimeString,
+ draft_group_id: values.groupId
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (!paramD) {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "saveFail",
+ errorText: "save_fail"
+ }));
+ return;
+ }
+ if (paramD.result == "success") {
+ getSmsStatusInfo({
+ smsCmd: 5,
+ errorType: "saveFail",
+ errorText: "save_fail"
+ }, callback, errorCabllback);
+ } else {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "saveFail",
+ errorText: "save_fail"
+ }));
+ }
+ }
+ }
+ function deleteAllMessages() {
+ var callback = arguments[1];
+ var errorCabllback = arguments[2] ? arguments[2] : callback;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = {
+ goformId: "ALL_DELETE_SMS",
+ notCallback: true,
+ which_cgi: values.location
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (!paramD) {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "deleteFail",
+ errorText: "delete_fail_try_again"
+ }));
+ return;
+ }
+ if (paramD.result == "success") {
+ addTimerSomething("sms_cmd_status_info", checkDeleteStatus);
+ } else {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "deleteFail",
+ errorText: "delete_fail_try_again"
+ }));
+ }
+ }
+ function checkDeleteStatus(paramD) {
+ var status = paramD.sms_cmd_status_info;
+ if (status == "2") {
+ removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "deleteFail",
+ errorText: "delete_fail_try_again"
+ }));
+ } else if (status == "3") {
+ removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);
+ callback({
+ result: true
+ });
+ }
+ }
+ }
+ function deleteMessage() {
+ var callback = arguments[1];
+ var errorCabllback = arguments[2] ? arguments[2] : callback;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var msgIds = values.ids.join(";") + ";";
+ var obj = {
+ goformId: "DELETE_SMS",
+ msg_id: msgIds,
+ notCallback: true
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (!paramD) {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "deleteFail",
+ errorText: "delete_fail_try_again"
+ }));
+ return;
+ }
+ if (paramD.result == "success") {
+ getSmsStatusInfo({
+ smsCmd: 6,
+ errorType: "deleteFail",
+ errorText: "delete_fail_try_again"
+ }, callback, errorCabllback);
+ } else {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "deleteFail",
+ errorText: "delete_fail_try_again"
+ }));
+ }
+ }
+ }
+ function getSmsStatusInfo(obj, callback, errorCabllback) {
+ reqAsync({
+ cmd: "sms_cmd_status_info",
+ sms_cmd: obj.smsCmd,
+ }, function (paramD) {
+ if (paramD) {
+ var status = paramD.sms_cmd_status_result;
+ if (status == "2") {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: obj.errorType,
+ errorText: obj.errorText
+ }));
+ } else if (status == "3") {
+ callback({
+ result: "success"
+ });
+ } else {
+ window.setTimeout(function () {
+ getSmsStatusInfo(obj, callback, errorCabllback);
+ }, 1000);
+ }
+ } else {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: obj.errorType,
+ errorText: obj.errorText
+ }));
+ }
+ }, function (paramD) {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: obj.errorType,
+ errorText: obj.errorText
+ }));
+ }, false);
+ }
+ function getSMSReady() {
+ if (config.smsIsReady) {
+ var callback = arguments[1];
+ if (callback) {
+ return callback({
+ "sms_cmd": "1",
+ "sms_cmd_status_result": "3"
+ });
+ } else {
+ return {
+ "sms_cmd": "1",
+ "sms_cmd_status_result": "3"
+ };
+ }
+ } else {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ }
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "sms_cmd_status_info";
+ valueReq.sms_cmd = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.sms_cmd_status_result == "3") {
+ config.smsIsReady = true;
+ }
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSmsRead() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var msgIds = values.ids.join(";");
+ if (values.ids.length > 0) {
+ msgIds += ";";
+ }
+ var obj = {
+ goformId: "SET_MSG_READ",
+ msg_id: msgIds,
+ tag: 0
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function getSMSDeliveryReport() {
+ return stuffMake(arguments, {}, prepare, deal, {}, false);
+ function prepare(values, isPost) {
+ var obj = {
+ cmd: "sms_status_rpt_data",
+ page: values.page,
+ data_per_page: values.smsCount
+ };
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ messages: parseMessages(paramD.messages, true)
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function logout() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = $.extend({}, values);
+ obj.goformId = "LOGOUT";
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ informationAll.isLoggedIn = false;
+ return {
+ result: true
+ };
+ } else {
+ return $.extend(errUnknownObj, {
+ errorType: "loggedOutError"
+ });
+ }
+ }
+ }
+ function changeManageInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = {};
+ obj.newPassword = config.PASSWORD_ENCODE ? Base64.encode(values.newValue) : values.newValue;
+ obj.oldPassword = config.PASSWORD_ENCODE ? Base64.encode(values.oldValue) : values.oldValue;
+ obj.goformId = "CHANGE_PASSWORD";
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result === "success") {
+ return {
+ result: true
+ };
+ } else {
+ return $.extend(errUnknownObj, {
+ errorType: "badPassword"
+ });
+ }
+ }
+ }
+ function getPinData() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "pinnumber,pin_status,puknumber";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function enablePin() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = {};
+ obj.goformId = "ENABLE_PIN";
+ obj.OldPinNumber = values.oldPin;
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result === "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function disablePin() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = {};
+ obj.goformId = "DISABLE_PIN";
+ obj.OldPinNumber = values.oldPin;
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result === "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function changePin() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var obj = {};
+ obj.goformId = "ENABLE_PIN";
+ obj.OldPinNumber = values.oldPin;
+ obj.NewPinNumber = values.newPin;
+ return obj;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result === "success") {
+ return {
+ result: true
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function getLanInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "lan_ipaddr,lan_netmask,mac_address,dhcpEnabled,dhcpStart,dhcpEnd,dhcpLease_hour";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.ipAddress = paramD.lan_ipaddr;
+ result.subnetMask = paramD.lan_netmask;
+ result.macAddress = paramD.mac_address;
+ result.dhcpServer = paramD.dhcpEnabled;
+ result.dhcpStart = paramD.dhcpStart;
+ result.dhcpEnd = paramD.dhcpEnd;
+ result.dhcpLease = parseInt(paramD.dhcpLease_hour, 10);
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setLanInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "DHCP_SETTING";
+ valueReq.lanIp = values.ipAddress;
+ valueReq.lanNetmask = values.subnetMask;
+ valueReq.lanDhcpType = values.dhcpServer == "1" ? "SERVER" : "DISABLE";
+ if (valueReq.lanDhcpType == "SERVER") {
+ valueReq.dhcpStart = values.dhcpStart;
+ valueReq.dhcpEnd = values.dhcpEnd;
+ valueReq.dhcpLease = values.dhcpLease;
+ }
+ valueReq.dhcp_reboot_flag = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSmsSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "sms_parameter_info";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.centerNumber = paramD.sms_para_sca;
+ result.memStroe = paramD.sms_para_mem_store;
+ result.deliveryReport = paramD.sms_para_status_report;
+ switch (parseInt(paramD.sms_para_validity_period, 10)) {
+ case 143:
+ result.validity = "twelve_hours";
+ break;
+ case 167:
+ result.validity = "one_day";
+ break;
+ case 173:
+ result.validity = "one_week";
+ break;
+ case 244:
+ result.validity = "largest";
+ break;
+ case 255:
+ result.validity = "largest";
+ break;
+ default:
+ result.validity = "twelve_hours";
+ break;
+ }
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSmsSetting() {
+ var callback = arguments[1];
+ var errorCabllback = arguments[2] ? arguments[2] : callback;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SET_MESSAGE_CENTER";
+ valueReq.save_time = values.validity;
+ valueReq.MessageCenter = values.centerNumber;
+ valueReq.status_save = values.deliveryReport;
+ valueReq.save_location = 'native';
+ valueReq.notCallback = true;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (!paramD) {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "smsSettingFail",
+ errorText: "error_info"
+ }));
+ return;
+ }
+ if (paramD.result == "success") {
+ getSmsStatusInfo({
+ smsCmd: 3,
+ errorType: "smsSettingFail",
+ errorText: "error_info"
+ }, callback, errorCabllback);
+ } else {
+ errorCabllback($.extend(errUnknownObj, {
+ errorType: "deleteFail",
+ errorText: "delete_fail_try_again"
+ }));
+ }
+ }
+ }
+ function restoreFactorySettings() {
+ var preErrorObj = {};
+ if (config.HAS_PARENTAL_CONTROL && config.currentUserInChildGroup != false) {
+ preErrorObj = {
+ errorType: 'no_auth'
+ };
+ }
+ return stuffMake(arguments, preErrorObj, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "RESTORE_FACTORY_SETTINGS";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function checkRestoreStatus(successCallback) {
+ var valueReq = {};
+ valueReq.cmd = "restore_flag";
+ valueReq.multi_data = 1;
+ reqAsync(valueReq, function (paramD) {
+ if (paramD && paramD.restore_flag === "1") {
+ successCallback();
+ } else {
+ setTimeout(function () {
+ checkRestoreStatus(successCallback);
+ }, 5000);
+ }
+ }, function () {
+ setTimeout(function () {
+ checkRestoreStatus(successCallback);
+ }, 5000);
+ }, false);
+ }
+ function getWpsInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "wifi_wps_index,WscModeOption,AuthMode,wifi_cur_state,EncrypType,wps_mode,WPS_SSID,m_ssid_enable,SSID1,m_SSID,m_EncrypType,m_AuthMode,wifi_sta_connection";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.wpsFlag = paramD.WscModeOption;
+ result.authMode = paramD.AuthMode;
+ result.wpsType = paramD.wps_mode;
+ result.radioFlag = paramD.wifi_cur_state == "1" ? "1" : "0";
+ result.encrypType = paramD.EncrypType;
+ result.wpsSSID = paramD.WPS_SSID;
+ result.ssidEnable = paramD.m_ssid_enable;
+ result.ssid = paramD.SSID1;
+ result.multiSSID = paramD.m_SSID;
+ result.m_encrypType = paramD.m_EncrypType;
+ result.wifi_wps_index = paramD.wifi_wps_index;
+ result.AuthMode = paramD.AuthMode;
+ result.m_AuthMode = paramD.m_AuthMode;
+ result.ap_station_enable = paramD.wifi_sta_connection;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function openWps() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "WIFI_WPS_SET";
+ valueReq.WPS_SSID = values.wpsSSID;
+ valueReq.wps_mode = values.wpsType;
+ valueReq.wifi_wps_index = values.wpsIndex;
+ if (valueReq.wps_mode == 'PIN') {
+ valueReq.wps_pin = values.wpsPin;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function openWps_5g() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "WIFI_M_WPS_SET";
+ valueReq.m_WPS_SSID = values.wpsSSID;
+ valueReq.m_wps_mode = values.wpsType;
+ valueReq.m_wifi_wps_index = values.wpsIndex;
+ if (valueReq.m_wps_mode == 'PIN') {
+ valueReq.m_wps_pin = values.wpsPin;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSleepMode() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "Sleep_interval";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.sleepMode = paramD.Sleep_interval;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSleepMode() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SET_WIFI_SLEEP_INFO";
+ valueReq.sysIdleTimeToSleep = values.sleepMode;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSysSecurity() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "RemoteManagement,WANPingFilter";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.remoteFlag = paramD.RemoteManagement == "1" ? "1" : "0";
+ result.pingFlag = paramD.WANPingFilter == "1" ? "1" : "0";
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSysSecurity() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "FW_SYS";
+ valueReq.remoteManagementEnabled = values.remoteFlag;
+ valueReq.pingFrmWANFilterEnabled = values.pingFlag;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getPortForward() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "PortForwardEnable,PortForwardRules_0,PortForwardRules_1,PortForwardRules_2,PortForwardRules_3,PortForwardRules_4,PortForwardRules_5,PortForwardRules_6,PortForwardRules_7,PortForwardRules_8,PortForwardRules_9";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.portForwardEnable = paramD.PortForwardEnable;
+ var rules = [];
+ if (paramD.PortForwardRules_0 != "") {
+ rules.push([0, paramD.PortForwardRules_0]);
+ }
+ if (paramD.PortForwardRules_1 != "") {
+ rules.push([1, paramD.PortForwardRules_1]);
+ }
+ if (paramD.PortForwardRules_2 != "") {
+ rules.push([2, paramD.PortForwardRules_2]);
+ }
+ if (paramD.PortForwardRules_3 != "") {
+ rules.push([3, paramD.PortForwardRules_3]);
+ }
+ if (paramD.PortForwardRules_4 != "") {
+ rules.push([4, paramD.PortForwardRules_4]);
+ }
+ if (paramD.PortForwardRules_5 != "") {
+ rules.push([5, paramD.PortForwardRules_5]);
+ }
+ if (paramD.PortForwardRules_6 != "") {
+ rules.push([6, paramD.PortForwardRules_6]);
+ }
+ if (paramD.PortForwardRules_7 != "") {
+ rules.push([7, paramD.PortForwardRules_7]);
+ }
+ if (paramD.PortForwardRules_8 != "") {
+ rules.push([8, paramD.PortForwardRules_8]);
+ }
+ if (paramD.PortForwardRules_9 != "") {
+ rules.push([9, paramD.PortForwardRules_9]);
+ }
+ result.portForwardRules = parsePortForwardRules(rules);
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ function parsePortForwardRules(paramD) {
+ var rules = [];
+ if (paramD && paramD.length > 0) {
+ for (var i = 0; i < paramD.length; i++) {
+ var aRule = {};
+ var elements = paramD[i][1].split(",");
+ aRule.index = paramD[i][0];
+ aRule.ipAddress = elements[0];
+ aRule.portRange = elements[1] + ' - ' + elements[2];
+ aRule.protocol = transProtocol(elements[3]);
+ aRule.comment = elements[4];
+ rules.push(aRule);
+ }
+ }
+ return rules;
+ }
+ }
+ function setPortForward() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "FW_FORWARD_ADD";
+ valueReq.ipAddress = values.ipAddress;
+ valueReq.portStart = values.portStart;
+ valueReq.portEnd = values.portEnd;
+ valueReq.protocol = values.protocol;
+ valueReq.comment = values.comment;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function deleteForwardRules() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "FW_FORWARD_DEL";
+ valueReq.delete_id = values.indexs.join(';') + ";";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function enableVirtualServer() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "VIRTUAL_SERVER";
+ valueReq.PortForwardEnable = values.portForwardEnable;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function wifiDecode(fact1,fact2,encode_aes) {//wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes,paramD.m_WPAPSK1_enaes);
+ var kstr = fact1 + fact2 + "FFFFFFFFFFFFFFFFFFFFFFFF";
+ var kstr_final;
+ var kiv_final;
+
+ kstr_final = kstr.substring(0, 24);
+ kiv_final = kstr.substring(0, 16);
+
+ var tkey = CryptoJS.enc.Latin1.parse(kstr_final);
+ var tiv = CryptoJS.enc.Latin1.parse(kiv_final);
+ var decdata = CryptoJS.AES.decrypt(encode_aes, tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString(CryptoJS.enc.Utf8);
+
+ return decdata;
+ }
+ function getQuickSettingInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ var wpask = config.PASSWORD_ENCODE ? ",WPAPSK1_encode" : ",imei,rnum_js,WPAPSK1_enaes";
+ valueReq.cmd = "pdp_type,ipv6_pdp_type,wifi_cur_state,SSID1,HideSSID,AuthMode,WscModeOption,ppp_status,apn_index,ipv6_apn_index,ipv6_APN_index,m_profile_name,apn_mode,EncrypType,DefaultKeyID,Key1Str1,Key2Str1,Key3Str1,Key4Str1" + wpask + ",APN_configtmp0,APN_configtmp1,APN_configtmp2,APN_configtmp3,APN_configtmp4,APN_configtmp5,APN_configtmp6,APN_configtmp7,APN_configtmp8,APN_configtmp9,APN_configtmp10,APN_configtmp11,APN_configtmp12,APN_configtmp13,APN_configtmp14,APN_configtmp15,APN_configtmp16,APN_configtmp17,APN_configtmp18,APN_configtmp19" + ",ipv6_APN_configtmp0,ipv6_APN_configtmp1,ipv6_APN_configtmp2,ipv6_APN_configtmp3,ipv6_APN_configtmp4,ipv6_APN_configtmp5,ipv6_APN_configtmp6,ipv6_APN_configtmp7,ipv6_APN_configtmp8,ipv6_APN_configtmp9,ipv6_APN_configtmp10,ipv6_APN_configtmp11,ipv6_APN_configtmp12,ipv6_APN_configtmp13,ipv6_APN_configtmp14,ipv6_APN_configtmp15,ipv6_APN_configtmp16,ipv6_APN_configtmp17,ipv6_APN_configtmp18,ipv6_APN_configtmp19";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (config.PASSWORD_ENCODE) {
+ paramD.WPAPSK1 = Base64.decode(paramD.WPAPSK1_encode);
+ } else {
+ paramD.WPAPSK1 = wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes);
+ }
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setQuickSetting4IPv6() {
+ stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
+ function prepare(values) {
+ var valueReq = {
+ goformId: "QUICK_SETUP_EX",
+ index: values.apn_index,
+ pdp_type: values.pdp_type,
+ apn_mode: values.apnMode,
+ profile_name: values.profile_name,
+ wan_apn: values.wan_apn,
+ ppp_auth_mode: values.ppp_auth_mode,
+ ppp_username: values.ppp_username,
+ ppp_passtmp: values.ppp_passtmp,
+ ipv6_wan_apn: values.ipv6_wan_apn,
+ ipv6_ppp_auth_mode: values.ipv6_ppp_auth_mode,
+ ipv6_ppp_username: values.ipv6_ppp_username,
+ ipv6_ppp_passtmp: values.ipv6_ppp_passtmp,
+ SSID_name: values.SSID_name,
+ SSID_Broadcast: values.SSID_Broadcast,
+ Encryption_Mode_hid: values.Encryption_Mode_hid,
+ security_shared_mode: values.security_shared_mode,
+ WPA_PreShared_Key: config.PASSWORD_ENCODE ? Base64.encode(values.WPA_PreShared_Key) : values.WPA_PreShared_Key,
+ wep_default_key: values.wep_default_key,
+ WPA_ENCRYPTION_hid: values.WPA_ENCRYPTION_hid
+ }
+ valueReq.wep_key_1 = values.wep_key_1;
+ valueReq.wep_key_2 = values.wep_key_2;
+ valueReq.wep_key_3 = values.wep_key_3;
+ valueReq.wep_key_4 = values.wep_key_4;
+ if (values.wep_default_key == '1') {
+ valueReq.WEP2Select = values.WEP2Select;
+ } else if (values.wep_default_key == '2') {
+ valueReq.WEP3Select = values.WEP3Select;
+ } else if (values.wep_default_key == '3') {
+ valueReq.WEP4Select = values.WEP4Select;
+ } else {
+ valueReq.WEP1Select = values.WEP1Select;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return $.extend(errUnknownObj, {
+ errorType: "SetSetUpError"
+ });
+ }
+ }
+ }
+ function stuffMakeAndCheckServerIsOnline(arg, prepare, deal) {
+ var isServerOnline = false;
+ var isCallbackExecuted = false;
+ var values = prepare(arg[0]);
+ var callback = arg[1];
+ var successCallback = function (paramD) {
+ isServerOnline = true;
+ if (!isCallbackExecuted && callback) {
+ callback(deal(paramD));
+ }
+ isCallbackExecuted = true;
+ };
+ var errorMethod = arg[2];
+ var errorCallback = function () {
+ isServerOnline = true;
+ if (errorMethod) {
+ errorMethod();
+ }
+ };
+ reqAsync(values, successCallback, errorCallback, true);
+ addTimeout(function () {
+ if (isServerOnline == false) {
+ var timer = addInterval(function () {
+ if (isServerOnline == false) {
+ getLanguage({}, function (paramD) {
+ window.clearInterval(timer);
+ successCallback({
+ result: "success"
+ });
+ });
+ }
+ }, 1000);
+ }
+ }, 5000);
+ }
+ function getSDConfiguration() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "sdcard_mode_option,sd_card_state,HTTP_SHARE_STATUS,HTTP_SHARE_WR_AUTH,HTTP_SHARE_FILE",
+ multi_data: 1
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var fileToShare;
+ if ("mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2/" == paramD.HTTP_SHARE_FILE) {
+ fileToShare = "1";
+ } else {
+ fileToShare = "0";
+ }
+ var result = {
+ sd_mode: paramD.sdcard_mode_option == "1" ? "0" : "1",
+ sd_status: paramD.sd_card_state,
+ share_status: paramD.HTTP_SHARE_STATUS == "Enabled" ? "1" : "0",
+ share_auth: paramD.HTTP_SHARE_WR_AUTH == "readOnly" ? "0" : "1",
+ file_to_share: fileToShare,
+ share_file: paramD.HTTP_SHARE_FILE
+ };
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSdCardMode() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "HTTPSHARE_MODE_SET",
+ mode_set: values.mode == "0" ? "http_share_mode" : "usb_mode"
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return {
+ result: 'success'
+ };
+ } else if (paramD && paramD.result == 'processing') {
+ return {
+ result: 'processing'
+ };
+ } else {
+ return {
+ result: false
+ };
+ }
+ }
+ }
+ function checkFileExists() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "GOFORM_HTTPSHARE_CHECK_FILE",
+ path_SD_CARD: values.path
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.result == "no_sdcard") {
+ return {
+ status: "no_sdcard"
+ };
+ } else if (paramD.result == "noexist") {
+ return {
+ status: "noexist"
+ };
+ } else if (paramD.result == "processing") {
+ return {
+ status: "processing"
+ };
+ } else {
+ return {
+ status: "exist"
+ };
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getFileList() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "HTTPSHARE_ENTERFOLD",
+ path_SD_CARD: values.path,
+ indexPage: values.index
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.result == 'failure') {
+ return $.extend(errUnknownObj, {
+ errorType: "get_file_list_failure"
+ });
+ } else if (paramD.result == "no_sdcard") {
+ return $.extend(errUnknownObj, {
+ errorType: "no_sdcard"
+ });
+ } else {
+ return parseSdCardFile(paramD.result);
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ function parseSdCardFile(result) {
+ var fileInfo = {};
+ fileInfo.totalRecord = result.totalRecord;
+ var fileArr = [];
+ var details = result.fileInfo;
+ for (var i = 0; details && i < details.length; i++) {
+ if (details[i].fileName == "") {
+ continue;
+ }
+ var obj = {};
+ obj.fileName = details[i].fileName;
+ obj.attribute = details[i].attribute;
+ obj.size = details[i].size;
+ obj.lastUpdateTime = details[i].lastUpdateTime;
+ fileArr.push(obj);
+ }
+ fileInfo.details = fileArr;
+ return fileInfo;
+ }
+ }
+ function fileRename() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var d = new Date();
+ var currentTime = d.getTime();
+ var zoneOffsetSeconds = d.getTimezoneOffset() * 60;
+ return {
+ goformId: "HTTPSHARE_FILE_RENAME",
+ path_SD_CARD: values.path,
+ OLD_NAME_SD_CARD: values.oldPath,
+ NEW_NAME_SD_CARD: values.newPath,
+ path_SD_CARD_time: transUnixTime(currentTime),
+ path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.result == "success") {
+ return {
+ result: true
+ };
+ } else if (paramD.result == "no_sdcard") {
+ return $.extend(errUnknownObj, {
+ errorType: "no_sdcard"
+ });
+ } else if (paramD.result == "noexist") {
+ return $.extend(errUnknownObj, {
+ errorType: "no_exist"
+ });
+ } else if (paramD.result == "processing") {
+ return $.extend(errUnknownObj, {
+ errorType: "sd_file_processing_cant_rename"
+ });
+ } else {
+ return {
+ result: false
+ };
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSdMemorySizes() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "HTTPSHARE_GETCARD_VALUE"
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (!paramD || (paramD.result && paramD.result == "no_sdcard")) {
+ return $.extend(errUnknownObj, {
+ errorType: "no_sdcard"
+ });
+ } else {
+ return {
+ totalMemorySize: paramD.sd_card_total_size == "" ? 0 : paramD.sd_card_total_size * 32 * 1024,
+ availableMemorySize: paramD.sd_card_avi_space == "" ? 0 : paramD.sd_card_avi_space * 32 * 1024
+ };
+ }
+ }
+ }
+ function deleteFilesAndFolders() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var currentTime = new Date().getTime();
+ var valueReq = {
+ goformId: "HTTPSHARE_DEL",
+ path_SD_CARD: values.path,
+ name_SD_CARD: values.names,
+ path_SD_CARD_time: transUnixTime(currentTime),
+ path_SD_CARD_time_unix: Math.round(currentTime / 1e3)
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD.result && paramD.result == "failure") {
+ return {
+ status: "failure"
+ };
+ } else if (paramD.result && paramD.result == "no_sdcard") {
+ return {
+ status: "no_sdcard"
+ };
+ } else if (paramD.result && paramD.result == "processing") {
+ return {
+ status: "processing"
+ };
+ } else if (paramD.result && paramD.result == "success") {
+ return {
+ status: "success"
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function createFolder() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var d = new Date();
+ var currentTime = d.getTime();
+ var zoneOffsetSeconds = d.getTimezoneOffset() * 60;
+ return {
+ goformId: "HTTPSHARE_NEW",
+ path_SD_CARD: values.path,
+ path_SD_CARD_time: transUnixTime(currentTime),
+ path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)
+ };
+ }
+ function deal(paramD) {
+ if (paramD.result && paramD.result == "failure") {
+ return $.extend(errUnknownObj, {
+ errorType: "create_folder_failure"
+ });
+ } else if (paramD.result && paramD.result == "no_sdcard") {
+ return $.extend(errUnknownObj, {
+ errorType: "no_sdcard"
+ });
+ } else if (paramD.result && paramD.result == "success") {
+ return {
+ result: true
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSdCardSharing() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "HTTPSHARE_AUTH_SET",
+ HTTP_SHARE_STATUS: values.share_status == "1" ? "Enabled" : "Disabled",
+ HTTP_SHARE_WR_AUTH: values.share_auth == "1" ? "readWrite" : "readOnly",
+ HTTP_SHARE_FILE: values.share_file
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.result == "no_sdcard") {
+ return $.extend(errUnknownObj, {
+ errorType: "no_sdcard"
+ });
+ } else {
+ return {
+ result: true
+ };
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getPortFilter() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "IPPortFilterEnable,DefaultFirewallPolicy,IPPortFilterRules_0,IPPortFilterRules_1,IPPortFilterRules_2,IPPortFilterRules_3,IPPortFilterRules_4,IPPortFilterRules_5,IPPortFilterRules_6,IPPortFilterRules_7,IPPortFilterRules_8,IPPortFilterRules_9";
+ valueReq.cmd += ",IPPortFilterRulesv6_0,IPPortFilterRulesv6_1,IPPortFilterRulesv6_2,IPPortFilterRulesv6_3,IPPortFilterRulesv6_4,IPPortFilterRulesv6_5,IPPortFilterRulesv6_6,IPPortFilterRulesv6_7,IPPortFilterRulesv6_8,IPPortFilterRulesv6_9";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.portFilterEnable = paramD.IPPortFilterEnable;
+ result.defaultPolicy = paramD.DefaultFirewallPolicy;
+ var rules = [];
+ if (paramD.IPPortFilterRules_0 != "") {
+ rules.push([0, paramD.IPPortFilterRules_0]);
+ }
+ if (paramD.IPPortFilterRules_1 != "") {
+ rules.push([1, paramD.IPPortFilterRules_1]);
+ }
+ if (paramD.IPPortFilterRules_2 != "") {
+ rules.push([2, paramD.IPPortFilterRules_2]);
+ }
+ if (paramD.IPPortFilterRules_3 != "") {
+ rules.push([3, paramD.IPPortFilterRules_3]);
+ }
+ if (paramD.IPPortFilterRules_4 != "") {
+ rules.push([4, paramD.IPPortFilterRules_4]);
+ }
+ if (paramD.IPPortFilterRules_5 != "") {
+ rules.push([5, paramD.IPPortFilterRules_5]);
+ }
+ if (paramD.IPPortFilterRules_6 != "") {
+ rules.push([6, paramD.IPPortFilterRules_6]);
+ }
+ if (paramD.IPPortFilterRules_7 != "") {
+ rules.push([7, paramD.IPPortFilterRules_7]);
+ }
+ if (paramD.IPPortFilterRules_8 != "") {
+ rules.push([8, paramD.IPPortFilterRules_8]);
+ }
+ if (paramD.IPPortFilterRules_9 != "") {
+ rules.push([9, paramD.IPPortFilterRules_9]);
+ }
+ result.portFilterRules = parsePortFilterRules(rules, "IPv4");
+ var v6Rules = [];
+ if (paramD.IPPortFilterRulesv6_0 != "") {
+ v6Rules.push([10, paramD.IPPortFilterRulesv6_0]);
+ }
+ if (paramD.IPPortFilterRulesv6_1 != "") {
+ v6Rules.push([11, paramD.IPPortFilterRulesv6_1]);
+ }
+ if (paramD.IPPortFilterRulesv6_2 != "") {
+ v6Rules.push([12, paramD.IPPortFilterRulesv6_2]);
+ }
+ if (paramD.IPPortFilterRulesv6_3 != "") {
+ v6Rules.push([13, paramD.IPPortFilterRulesv6_3]);
+ }
+ if (paramD.IPPortFilterRulesv6_4 != "") {
+ v6Rules.push([14, paramD.IPPortFilterRulesv6_4]);
+ }
+ if (paramD.IPPortFilterRulesv6_5 != "") {
+ v6Rules.push([15, paramD.IPPortFilterRulesv6_5]);
+ }
+ if (paramD.IPPortFilterRulesv6_6 != "") {
+ v6Rules.push([16, paramD.IPPortFilterRulesv6_6]);
+ }
+ if (paramD.IPPortFilterRulesv6_7 != "") {
+ v6Rules.push([17, paramD.IPPortFilterRulesv6_7]);
+ }
+ if (paramD.IPPortFilterRulesv6_8 != "") {
+ v6Rules.push([18, paramD.IPPortFilterRulesv6_8]);
+ }
+ if (paramD.IPPortFilterRulesv6_9 != "") {
+ v6Rules.push([19, paramD.IPPortFilterRulesv6_9]);
+ }
+ result.portFilterRules = _.union(result.portFilterRules, parsePortFilterRules(v6Rules, "IPv6"));
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ function parsePortFilterRules(paramD, ipTypeTmp) {
+ var rules = [];
+ if (paramD && paramD.length > 0) {
+ for (var i = 0; i < paramD.length; i++) {
+ var aRule = {};
+ var elements = paramD[i][1].split(",");
+ aRule.index = paramD[i][0];
+ aRule.macAddress = elements[11];
+ aRule.destIpAddress = elements[4] == "any/0" ? "" : elements[4];
+ aRule.sourceIpAddress = elements[0] == "any/0" ? "" : elements[0];
+ aRule.destPortRange = elements[6] == '0' ? '' : elements[6] + " - " + elements[7];
+ aRule.sourcePortRange = elements[2] == '0' ? '' : elements[2] + " - " + elements[3];
+ aRule.action = elements[9] == 1 ? "filter_accept" : "filter_drop";
+ aRule.protocol = transProtocol(elements[8]);
+ aRule.comment = elements[10];
+ aRule.ipType = ipTypeTmp;
+ rules.push(aRule);
+ }
+ }
+ return rules;
+ }
+ }
+ function setPortFilterBasic() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "BASIC_SETTING";
+ valueReq.portFilterEnabled = values.portFilterEnable;
+ valueReq.defaultFirewallPolicy = values.defaultPolicy;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setPortFilter() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "ADD_IP_PORT_FILETER_V4V6";
+ valueReq.ip_version = values.ipType;
+ valueReq.mac_address = values.macAddress;
+ valueReq.dip_address = values.destIpAddress;
+ valueReq.sip_address = values.sourceIpAddress;
+ valueReq.dFromPort = values.destPortStart;
+ valueReq.dToPort = values.destPortEnd;
+ valueReq.sFromPort = values.sourcePortStart;
+ valueReq.sToPort = values.sourcePortEnd;
+ valueReq.action = values.action;
+ valueReq.protocol = values.protocol;
+ valueReq.comment = values.comment;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function deleteFilterRules() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ var deleteIds = _.filter(values.indexs, function (item) {
+ return item.length == 1;
+ });
+ valueReq.goformId = "DEL_IP_PORT_FILETER_V4V6";
+ var deletev6Ids = [];
+ _.each(values.indexs, function (item) {
+ if (item.length == 2) {
+ deletev6Ids.push(item.substring(1));
+ }
+ });
+ valueReq.delete_id_v6 = deletev6Ids.length > 0 ? deletev6Ids.join(';') + ";" : "";
+ valueReq.delete_id = deleteIds.length > 0 ? deleteIds.join(';') + ";" : "";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getWifiAdvance() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "WirelessMode,CountryCode,Channel,HT_MCS,wifi_band,wifi_11n_cap,MAX_Access_num,m_MAX_Access_num,MAX_Station_num,wifi_sta_connection";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {
+ mode: paramD.WirelessMode,
+ countryCode: paramD.CountryCode,
+ channel: paramD.Channel,
+ rate: paramD.HT_MCS,
+ wifiBand: paramD.wifi_band == 'a' ? 'a' : 'b',
+ bandwidth: paramD.wifi_11n_cap,
+ MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,
+ MAX_Access_num: paramD.MAX_Access_num,
+ m_MAX_Access_num: paramD.m_MAX_Access_num,
+ ap_station_enable: paramD.wifi_sta_connection
+ };
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setWifiAdvance() {
+ stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
+ function prepare(values) {
+ var valueReq = {
+ goformId: "SET_WIFI_INFO",
+ wifiMode: values.mode,
+ countryCode: values.countryCode,
+ MAX_Access_num: values.station,
+ m_MAX_Access_num: values.m_station
+ };
+ if (config.WIFI_BAND_SUPPORT) {
+ valueReq.wifi_band = values.wifiBand;
+ }
+ if (config.WIFI_BAND_SUPPORT && values.wifiBand == 'a') {
+ valueReq.selectedChannel = 'auto';
+ } else {
+ valueReq.selectedChannel = values.channel;
+ valueReq.abg_rate = values.rate;
+ }
+ if (config.WIFI_BANDWIDTH_SUPPORT) {
+ valueReq.wifi_11n_cap = values.bandwidth;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getDeviceInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var wpask = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";
+ var valueReq = {
+ cmd: "wifi_coverage,m_ssid_enable,imei,network_type,sub_network_type,rssi,rscp,lte_rsrp,imsi,sim_imsi,cr_version,hw_version,MAX_Access_num," + wpask + "SSID1,AuthMode,m_SSID,m_AuthMode,m_HideSSID,m_MAX_Access_num,lan_ipaddr," + "mac_address,msisdn,LocalDomain,wan_ipaddr,static_wan_ipaddr,ipv6_wan_ipaddr,ipv6_pdp_type,pdp_type,ppp_status,sta_ip_status,rj45_state,ethwan_mode",
+ multi_data: 1
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ ssid: paramD.SSID1,
+ authMode: paramD.AuthMode,
+ passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),
+ m_ssid: paramD.m_SSID,
+ m_AuthMode: paramD.m_AuthMode,
+ m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),
+ m_max_access_num: paramD.m_MAX_Access_num,
+ multi_ssid_enable: paramD.m_ssid_enable,
+ ipAddress: paramD.lan_ipaddr,
+ wanIpAddress: paramD.wan_ipaddr,
+ staticWanIpAddress: paramD.static_wan_ipaddr,
+ ipv6WanIpAddress: paramD.ipv6_wan_ipaddr,
+ ipv6PdpType: paramD.ipv6_pdp_type,
+ macAddress: paramD.mac_address,
+ simSerialNumber: paramD.msisdn,
+ lanDomain: paramD.LocalDomain,
+ imei: paramD.imei,
+ signal: convertSignal(paramD),
+ imsi: paramD.imsi || paramD.sim_imsi,
+ sw_version: paramD.cr_version,
+ hw_version: paramD.hw_version,
+ max_access_num: paramD.MAX_Access_num,
+ wifiRange: paramD.wifi_coverage,
+ pdpType: paramD.pdp_type,
+ rj45ConnectStatus: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,
+ blc_wan_mode: informationAll.blc_wan_mode,
+ connectStatus: paramD.ppp_status,
+ wifiConStatus: paramD.sta_ip_status,
+ ethwan_mode: paramD.ethwan_mode.toUpperCase()
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getDeviceInfoLow() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "imei,rnum_js",
+ multi_data: 1
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var kstr = paramD.rnum_js + paramD.imei + "FFFFFFFFFFFFFFFFFFFFFFFF";
+ var kstr_final;
+ var kiv_final;
+
+ kstr_final = kstr.substring(0, 24);
+ kiv_final = kstr.substring(0, 16);
+
+ return {
+ skey: kstr_final,
+ siv: kiv_final
+ };
+ } else {
+
+ return {
+ skey: "FFFFFFFFFFFFFFFFFFFFFFFF",
+ siv: "FFFFFFFFFFFFFFFF"
+ };
+ }
+ }
+ }
+ function getWifiRange() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "wifi_coverage";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.wifiRangeMode = paramD.wifi_coverage;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setWifiRange() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SET_WIFI_COVERAGE";
+ valueReq.wifi_coverage = values.wifiRangeMode;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getUpnpSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "upnpEnabled";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.upnpSetting = paramD.upnpEnabled == "1" ? "1" : "0";
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setUpnpSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "UPNP_SETTING";
+ valueReq.upnp_setting_option = values.upnpSetting;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getDmzSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "DMZEnable,DMZIPAddress";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.dmzSetting = paramD.DMZEnable == "1" ? "1" : "0";
+ result.ipAddress = paramD.DMZIPAddress;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setDmzSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "DMZ_SETTING";
+ valueReq.DMZEnabled = values.dmzSetting;
+ if (valueReq.DMZEnabled == '1') {
+ valueReq.DMZIPAddress = values.ipAddress;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getPortMap() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "PortMapEnable,PortMapRules_0,PortMapRules_1,PortMapRules_2,PortMapRules_3,PortMapRules_4,PortMapRules_5,PortMapRules_6,PortMapRules_7,PortMapRules_8,PortMapRules_9",
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.portMapEnable = paramD.PortMapEnable;
+ var rules = [];
+ if (paramD.PortMapRules_0 != "") {
+ rules.push([0, paramD.PortMapRules_0]);
+ }
+ if (paramD.PortMapRules_1 != "") {
+ rules.push([1, paramD.PortMapRules_1]);
+ }
+ if (paramD.PortMapRules_2 != "") {
+ rules.push([2, paramD.PortMapRules_2]);
+ }
+ if (paramD.PortMapRules_3 != "") {
+ rules.push([3, paramD.PortMapRules_3]);
+ }
+ if (paramD.PortMapRules_4 != "") {
+ rules.push([4, paramD.PortMapRules_4]);
+ }
+ if (paramD.PortMapRules_5 != "") {
+ rules.push([5, paramD.PortMapRules_5]);
+ }
+ if (paramD.PortMapRules_6 != "") {
+ rules.push([6, paramD.PortMapRules_6]);
+ }
+ if (paramD.PortMapRules_7 != "") {
+ rules.push([7, paramD.PortMapRules_7]);
+ }
+ if (paramD.PortMapRules_8 != "") {
+ rules.push([8, paramD.PortMapRules_8]);
+ }
+ if (paramD.PortMapRules_9 != "") {
+ rules.push([9, paramD.PortMapRules_9]);
+ }
+ result.portMapRules = parsePortMapRules(rules);
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ function parsePortMapRules(paramD) {
+ var rules = [];
+ if (paramD && paramD.length > 0) {
+ for (var i = 0; i < paramD.length; i++) {
+ var aRule = {};
+ var elements = paramD[i][1].split(",");
+ aRule.index = paramD[i][0];
+ aRule.sourcePort = elements[1];
+ aRule.destIpAddress = elements[0];
+ aRule.destPort = elements[2];
+ aRule.protocol = transProtocol(elements[3]);
+ aRule.comment = elements[4];
+ rules.push(aRule);
+ }
+ }
+ return rules;
+ }
+ }
+ function setPortMap() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "ADD_PORT_MAP";
+ valueReq.portMapEnabled = values.portMapEnable;
+ valueReq.fromPort = values.sourcePort;
+ valueReq.ip_address = values.destIpAddress;
+ valueReq.toPort = values.destPort;
+ valueReq.protocol = values.protocol;
+ valueReq.comment = values.comment;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function enablePortMap() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "ADD_PORT_MAP";
+ valueReq.portMapEnabled = values.portMapEnable;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function deleteMapRules() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "DEL_PORT_MAP";
+ valueReq.delete_id = values.indexs.join(';') + ";";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getTrafficAlertInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ cmd: "data_volume_limit_switch,data_volume_limit_unit,data_volume_limit_size,data_volume_alert_percent,monthly_tx_bytes,monthly_rx_bytes,monthly_time,traffic_alined_delta",
+ multi_data: 1
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var isData = paramD.data_volume_limit_unit == 'data';
+ var result = {
+ dataLimitChecked: paramD.data_volume_limit_switch,
+ dataLimitTypeChecked: isData ? '1' : '0',
+ limitDataMonth: isData ? paramD.data_volume_limit_size : '0',
+ alertDataReach: isData ? paramD.data_volume_alert_percent : '0',
+ limitTimeMonth: isData ? '0' : paramD.data_volume_limit_size,
+ alertTimeReach: isData ? '0' : paramD.data_volume_alert_percent,
+ monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,
+ monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,
+ monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,
+ traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta
+ };
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setTrafficAlertInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var isData = values.dataLimitTypeChecked == '1';
+ var valueReq = {
+ goformId: "DATA_LIMIT_SETTING",
+ data_volume_limit_switch: values.dataLimitChecked
+ };
+ if (values.dataLimitChecked == '1') {
+ valueReq.data_volume_limit_unit = isData ? 'data' : 'time';
+ valueReq.data_volume_limit_size = isData ? values.limitDataMonth : values.limitTimeMonth;
+ valueReq.data_volume_alert_percent = isData ? values.alertDataReach : values.alertTimeReach;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getUSSDResponse() {
+ var callback = arguments[1];
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ if (values.sendOrReply == "send") {
+ return {
+ goformId: "USSD_PROCESS",
+ USSD_operator: values.operator,
+ USSD_send_number: values.strUSSDCommand,
+ notCallback: true
+ };
+ } else if (values.sendOrReply == "reply") {
+ return {
+ goformId: "USSD_PROCESS",
+ USSD_operator: values.operator,
+ USSD_reply_number: values.strUSSDCommand,
+ notCallback: true
+ };
+ }
+ }
+ function deal(paramD) {
+ if (!paramD) {
+ callback(false, "ussd_fail");
+ return;
+ }
+ if (paramD.result == "success") {
+ callbackTemp = callback;
+ getResponse();
+ } else {
+ callback(false, "ussd_fail");
+ }
+ }
+ }
+ function getResponse() {
+ $.ajax({
+ url: "/reqproc/proc_get",
+ data: {
+ cmd: "ussd_write_flag"
+ },
+ cache: false,
+ async: true,
+ dataType: "json",
+ success: function (result) {
+ if (result.ussd_write_flag == "1") {
+ callbackTemp(false, "ussd_no_service");
+ } else if (result.ussd_write_flag == "4" || result.ussd_write_flag == "unknown" || result.ussd_write_flag == "3") {
+ callbackTemp(false, "ussd_timeout");
+ } else if (result.ussd_write_flag == "15") {
+ setTimeout(getResponse, 1000);
+ } else if (result.ussd_write_flag == "10") {
+ callbackTemp(false, "ussd_retry");
+ } else if (result.ussd_write_flag == "99") {
+ callbackTemp(false, "ussd_unsupport");
+ } else if (result.ussd_write_flag == "41") {
+ callbackTemp(false, "operation_not_supported");
+ } else if (result.ussd_write_flag == "2") {
+ callbackTemp(false, "network_terminated");
+ } else if (result.ussd_write_flag == "16") {
+ $.ajax({
+ url: "/reqproc/proc_get",
+ data: {
+ cmd: "ussd_data_info"
+ },
+ dataType: "json",
+ async: true,
+ cache: false,
+ success: function (paramD) {
+ var content = {};
+ content.data = paramD.ussd_data;
+ content.ussd_action = paramD.ussd_action;
+ content.ussd_dcs = paramD.ussd_dcs;
+ callbackTemp(true, content);
+ },
+ error: function () {
+ callbackTemp(false, "ussd_info_error");
+ }
+ });
+ } else {
+ callbackTemp(false, "ussd_fail");
+ }
+ },
+ error: function () {
+ callbackTemp(false, "ussd_fail");
+ }
+ });
+ }
+ function USSDReplyCancel(callback) {
+ $.ajax({
+ url: "/reqproc/proc_post",
+ data: {
+ goformId: "USSD_PROCESS",
+ USSD_operator: "ussd_cancel"
+ },
+ cache: false,
+ dataType: "json",
+ success: function (paramD) {
+ if (paramD.result == "success") {
+ getCancelResponse();
+ } else {
+ callback(false);
+ }
+ }
+ });
+ function getCancelResponse() {
+ $.ajax({
+ url: "/reqproc/proc_get",
+ data: {
+ cmd: "ussd_write_flag"
+ },
+ cache: false,
+ async: true,
+ dataType: "json",
+ success: function (result) {
+ if (result.ussd_write_flag == "15") {
+ setTimeout(getCancelResponse, 1000);
+ } else if (result.ussd_write_flag == "13") {
+ callback(true);
+ } else {
+ callback(false);
+ }
+ },
+ error: function () {
+ callback(false);
+ }
+ });
+ }
+ }
+ function unlockNetwork() {
+ var callback = arguments[1];
+ var checkPoint = 0;
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ return {
+ goformId: "UNLOCK_NETWORK",
+ notCallback: true,
+ unlock_network_code: values.unlock_network_code
+ };
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ addCallback(checkUnlockNetworkStatus);
+ } else {
+ callback({
+ result: 'fail'
+ });
+ }
+ }
+ function checkUnlockNetworkStatus() {
+ if (checkPoint > 5) {
+ removeCallback(checkUnlockNetworkStatus);
+ callback({
+ result: 'fail'
+ });
+ } else if (informationAll.simStatus != 'modem_imsi_waitnck') {
+ removeCallback(checkUnlockNetworkStatus);
+ callback({
+ result: 'success'
+ });
+ }
+ checkPoint++;
+ }
+ }
+ function getNetworkUnlockTimes() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ cmd: "unlock_nck_time"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setUpdateInfoWarning() {
+ var callback = arguments[1];
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ return {
+ goformId: "SET_UPGRADE_NOTICE",
+ upgrade_notice_flag: values.upgrade_notice_flag,
+ notCallback: true
+ };
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ callback(true);
+ } else {
+ callback(false);
+ }
+ }
+ }
+ function getUpdateInfoWarning() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ cmd: "upgrade_notice_flag"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getAPStationBasic() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: 1,
+ cmd: "wifi_sta_connection,pswan_priority,wifiwan_priority,ethwan_priority"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ ap_station_enable: paramD.wifi_sta_connection,
+ ap_station_mode: parseInt(paramD.wifiwan_priority, 10) > parseInt(paramD.pswan_priority, 10) ? "wifi_pref" : "dial_pref"
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setAPStationBasic() {
+ var tmp = arguments[0];
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ return {
+ goformId: "WIFI_STA_CONTROL",
+ wifi_sta_connection: values.ap_station_enable
+ };
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ informationAll.ap_station_enable = tmp.ap_station_enable == 1;
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function refreshAPStationStatus() {
+ return getAPStationBasic({}, function (paramD) {
+ informationAll.ap_station_enable = paramD.ap_station_enable == 1;
+ informationAll.ap_station_mode = paramD.ap_station_mode;
+ });
+ }
+ function getHotspotList() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var cmdStr = "wifi_profile_num,wifi_profile";
+ for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
+ cmdStr = cmdStr + ",wifi_profile" + i;
+ }
+ return {
+ multi_data: 1,
+ cmd: cmdStr
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var wifiList = [];
+ for (var i = 0; i < config.AP_STATION_LIST_LENGTH; i++) {
+ var wifiStr = "";
+ if (i == 0) {
+ wifiStr = paramD.wifi_profile;
+ } else {
+ wifiStr = paramD["wifi_profile" + i];
+ }
+ var wifiArray = wifiStr.split(";");
+ for (var j = 0; j < wifiArray.length; j++) {
+ var item = wifiArray[j].split(",");
+ if (!item[0]) {
+ break;
+ }
+ var wifiJson = {
+ profileName: item[0],
+ fromProvider: item[1],
+ connectStatus: item[2],
+ signal: item[3],
+ ssid: item[4],
+ authMode: item[5],
+ encryptType: item[6],
+ password: item[7] == "0" ? "" : item[7],
+ keyID: item[8],
+ mac: item[9]
+ };
+ wifiList.push(wifiJson);
+ }
+ }
+ return {
+ hotspotList: wifiList
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function searchHotspot() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ return {
+ goformId: "WLAN_SET_STA_REFRESH"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSearchHotspotList() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: 1,
+ cmd: "scan_finish,EX_APLIST,EX_APLIST1"
+ }
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.scan_finish == "0") {
+ return {
+ scan_finish: "0",
+ hotspotList: []
+ };
+ }
+ if (paramD.scan_finish == "2") {
+ return {
+ scan_finish: "2",
+ hotspotList: []
+ };
+ }
+ var wifiList = [];
+ for (var i = 0; i <= 1; i++) {
+ var wifiStr;
+ if (i == 0) {
+ wifiStr = paramD.EX_APLIST;
+ } else {
+ wifiStr = paramD.EX_APLIST1;
+ }
+ var wifiArray = wifiStr.split(";");
+ for (var j = 0; j < wifiArray.length; j++) {
+ var item = wifiArray[j].split(",");
+ if (!item[0]) {
+ break;
+ }
+ var wifiJson = {
+ fromProvider: item[0],
+ connectStatus: item[1],
+ ssid: item[2],
+ signal: item[3],
+ channel: item[4],
+ authMode: item[5],
+ encryptType: item[6],
+ mac: item[7]
+ }
+ wifiList.push(wifiJson);
+ }
+ }
+ return {
+ scan_finish: "1",
+ hotspotList: wifiList
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function creatHotspotString(hotspot) {
+ var tmp = [];
+ tmp.push(hotspot.profileName);
+ tmp.push(hotspot.fromProvider || "0");
+ tmp.push(hotspot.connectStatus || "0");
+ tmp.push(hotspot.signal);
+ tmp.push(hotspot.ssid);
+ tmp.push(hotspot.authMode);
+ tmp.push(hotspot.encryptType);
+ tmp.push(hotspot.password || "0");
+ tmp.push(hotspot.keyID);
+ tmp.push(hotspot.mac);
+ return tmp.join(",");
+ }
+ function saveHotspot() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var apList = values.apList;
+ var action = "modify";
+ if (values.profileName == "") {
+ action = "add";
+ var newName = (jQuery.fn.jquery + Math.random()).replace(/\D/g, "");
+ values.profileName = newName;
+ apList.push({
+ profileName: newName,
+ fromProvider: "0",
+ connectStatus: "0",
+ signal: values.signal,
+ ssid: values.ssid,
+ authMode: values.authMode,
+ encryptType: values.encryptType,
+ password: values.password || "0",
+ keyID: values.keyID,
+ mac: values.mac
+ });
+ }
+ var wifi = {
+ "profile0": []
+ };
+ for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
+ wifi["profile" + i] = [];
+ }
+ var activeHotspotStr = "";
+ for (var i = 0; i < apList.length; i++) {
+ var hotspotStr = "";
+ if (values.profileName == apList[i].profileName) {
+ hotspotStr = creatHotspotString(values);
+ activeHotspotStr = hotspotStr;
+ } else {
+ hotspotStr = creatHotspotString(apList[i]);
+ }
+ var index = parseInt(i % 10);
+ wifi["profile" + index].push(hotspotStr);
+ }
+ var profileParams = {
+ wifi_profile: wifi.profile0.join(";")
+ };
+ for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
+ profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");
+ }
+ var valueReq = $.extend({
+ goformId: "WIFI_SPOT_PROFILE_UPDATE",
+ wifi_profile_num: apList.length,
+ wifi_update_profile: activeHotspotStr,
+ action: action
+ }, profileParams);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function deleteHotspot() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var apList = values.apList;
+ var wifi = {
+ "profile0": []
+ };
+ for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
+ wifi["profile" + i] = [];
+ }
+ var foundDelete = false;
+ var activeHotspotStr = "";
+ for (var i = 0; i < apList.length; i++) {
+ var hotspotStr = creatHotspotString(apList[i]);
+ if (apList[i].profileName == values.profileName) {
+ foundDelete = true;
+ activeHotspotStr = hotspotStr;
+ continue;
+ }
+ var idIndex = i;
+ if (foundDelete) {
+ idIndex = i - 1;
+ }
+ var index = parseInt(idIndex % 10);
+ wifi["profile" + index].push(hotspotStr);
+ }
+ var num = foundDelete ? apList.length - 1 : apList.length;
+ var profileParams = {
+ wifi_profile: wifi.profile0.join(";")
+ };
+ for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
+ profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");
+ }
+ var valueReq = $.extend({
+ goformId: "WIFI_SPOT_PROFILE_UPDATE",
+ wifi_profile_num: num,
+ wifi_update_profile: activeHotspotStr,
+ action: "delete"
+ }, profileParams);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function connectHotspot() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ return {
+ goformId: "WLAN_SET_STA_CON",
+ EX_SSID1: values.EX_SSID1,
+ EX_AuthMode: values.EX_AuthMode,
+ EX_EncrypType: values.EX_EncrypType,
+ EX_DefaultKeyID: values.EX_DefaultKeyID,
+ EX_WEPKEY: values.EX_WEPKEY,
+ EX_WPAPSK1: values.EX_WPAPSK1,
+ EX_wifi_profile: values.EX_wifi_profile,
+ EX_mac: values.EX_mac
+ };
+ }
+ function deal(paramD) {
+ if (paramD && (paramD.result == "success" || paramD.result == "processing")) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function disconnectHotspot() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ return {
+ goformId: "WLAN_SET_STA_DISCON"
+ };
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getOpMode() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: 1,
+ cmd: "blc_wan_mode,blc_wan_auto_mode,loginfo,ppp_status,rj45_state,ethwan_mode"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ if (paramD.blc_wan_mode == 'AUTO') {
+ result.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
+ } else {
+ result.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
+ }
+ result.loginfo = paramD.loginfo;
+ result.ppp_status = paramD.ppp_status;
+ result.rj45_state = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;
+ result.ethwan_mode = paramD.ethwan_mode.toUpperCase();
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getRj45PlugState() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ cmd: "rj45_plug"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.rj45_plug = paramD.rj45_plug == "" ? "wan_lan_off" : paramD.rj45_plug;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function checkOpMode(opmode, rj45state) {
+ if (config.RJ45_SUPPORT) {
+ if (rj45state == "dead" || rj45state == "") {
+ return 'PPP';
+ } else if (!opmode || opmode == "undefined") {
+ if (rj45state == "working") {
+ return 'PPPOE';
+ } else {
+ return 'PPP';
+ }
+ } else {
+ return opmode;
+ }
+ } else {
+ return 'PPP';
+ }
+ }
+ function SetOperationMode(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({
+ goformId: "OPERATION_MODE"
+ }, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getPppoeParams() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: 1,
+ cmd: "opms_wan_auto_mode,ethwan_mode,pppoe_username,pppoe_cc,ethwan_dialmode,ppp_status,static_wan_ipaddr,static_wan_netmask,static_wan_gateway,static_wan_primary_dns,static_wan_secondary_dns,rj45_state,lan_ipaddr,lan_netmask"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ opms_wan_auto_mode: paramD.opms_wan_auto_mode,
+ ethwan_mode: paramD.ethwan_mode.toUpperCase(),
+ pppoe_username: paramD.pppoe_username,
+ pppoe_cc: paramD.pppoe_cc,
+ ethwan_dialmode: paramD.ethwan_dialmode == "manual" ? "manual_dial" : "auto_dial",
+ ppp_status: paramD.ppp_status,
+ static_wan_ipaddr: paramD.static_wan_ipaddr,
+ static_wan_netmask: paramD.static_wan_netmask,
+ static_wan_gateway: paramD.static_wan_gateway,
+ static_wan_primary_dns: paramD.static_wan_primary_dns,
+ static_wan_secondary_dns: paramD.static_wan_secondary_dns,
+ rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,
+ lan_ipaddr: paramD.lan_ipaddr,
+ lan_netmask: paramD.lan_netmask
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setPppoeDialMode(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({
+ notCallback: true
+ }, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD.result == "success") {
+ callback({
+ result: true
+ });
+ } else {
+ callback({
+ result: false
+ });
+ }
+ }
+ }
+ function getSntpParams(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: 1,
+ cmd: "sntp_year,sntp_month,sntp_day,sntp_hour,sntp_minute,sntp_second,sntp_time_set_mode,sntp_static_server0,sntp_static_server1,sntp_static_server2,sntp_server0,sntp_server1,sntp_server2,sntp_server3,sntp_server4,sntp_server5,sntp_server6,sntp_server7,sntp_server8,sntp_server9,sntp_other_server0,sntp_other_server1,sntp_other_server2,sntp_timezone,sntp_timezone_index,sntp_dst_enable,ppp_status,sntp_process_result,rj45_state"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var sntp_servers = getSntpServers(paramD);
+ return {
+ sntp_year: paramD.sntp_year,
+ sntp_month: paramD.sntp_month,
+ sntp_day: paramD.sntp_day,
+ sntp_hour: paramD.sntp_hour,
+ sntp_minute: paramD.sntp_minute,
+ sntp_second: paramD.sntp_second,
+ sntp_time_set_mode: paramD.sntp_time_set_mode,
+ sntp_servers: sntp_servers,
+ sntp_server0: paramD.sntp_server0,
+ sntp_server1: paramD.sntp_server1,
+ sntp_server2: paramD.sntp_server2,
+ sntp_static_server0: paramD.sntp_static_server0,
+ sntp_static_server1: paramD.sntp_static_server1,
+ sntp_static_server2: paramD.sntp_static_server2,
+ sntp_other_server0: paramD.sntp_other_server0,
+ sntp_other_server1: paramD.sntp_other_server1,
+ sntp_other_server2: paramD.sntp_other_server2,
+ sntp_timezone: paramD.sntp_timezone,
+ sntp_timezone_index: paramD.sntp_timezone_index ? paramD.sntp_timezone_index : "0",
+ sntp_dst_enable: paramD.sntp_dst_enable,
+ ppp_status: paramD.ppp_status,
+ blc_wan_mode: informationAll.blc_wan_mode,
+ sntp_process_result: paramD.sntp_process_result,
+ rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ function getSntpServers(paramD) {
+ var serverArray = [];
+ for (var i = 0; i < 3; i++) {
+ var tmp = "sntp_static_server" + (i).toString();
+ if (paramD[tmp] != "") {
+ var obj = {};
+ obj.name = paramD[tmp];
+ obj.value = paramD[tmp];
+ serverArray.push(obj);
+ }
+ }
+ var otherArray = [{
+ name: "Other",
+ value: "Other"
+ }, {
+ name: "NONE",
+ value: ""
+ }
+ ];
+ for (var j = 0; j < 2; j++) {
+ serverArray.push(otherArray[j]);
+ }
+ return serverArray;
+ }
+ }
+ function setSNTPDate(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({}, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSntpSetting(values, callback) {
+ var valueReq = $.extend({}, values); {
+ $.post("reqproc/proc_post", valueReq, function (paramD) {
+ if (paramD && paramD.result == "success") {
+ if (values.manualsettime == "auto") {
+ setTimeout(checkSyncStatus, 2000);
+ callback(paramD);
+ } else {
+ callback(true);
+ }
+ } else if (paramD && paramD.result == "processing") {
+ callback(paramD);
+ } else {
+ callback(false);
+ }
+ }, "json");
+ }
+ function checkSyncStatus() {
+ $.ajax({
+ url: "reqproc/proc_get",
+ dataType: "json",
+ data: {
+ cmd: "sntp_process_result"
+ },
+ cache: false,
+ async: false,
+ success: function (paramD) {
+ if (paramD.sntp_process_result == "failure") {
+ callback(false);
+ } else if (paramD.sntp_process_result == "success") {
+ callback(true);
+ } else {
+ setTimeout(checkSyncStatus, 2000);
+ }
+ },
+ error: function () {
+ callback(false);
+ }
+ });
+ }
+ }
+ function addUrlFilterRule(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({}, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getUrlFilterList() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ cmd: "websURLFilters"
+ };
+ }
+ function deal(paramD) {
+ var urlFilterRules = [];
+ if (paramD) {
+ if (paramD.websURLFilters.length == 0) {
+ return {
+ urlFilterRules: []
+ };
+ } else {
+ var tempArray = paramD.websURLFilters.split(";");
+ for (var i = 0; i < tempArray.length; i++) {
+ var aRule = {};
+ aRule.index = i;
+ aRule.url = tempArray[i];
+ urlFilterRules.push(aRule);
+ }
+ return {
+ urlFilterRules: urlFilterRules
+ };
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function deleteSelectedRules(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({}, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getWdsInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: "1",
+ cmd: "wifi_wds_mode,wifi_wds_ssid,wifi_wds_AuthMode,wifi_wds_EncrypType,wifi_wds_WPAPSK1,wifi_cur_state "
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ currentMode: paramD.wifi_wds_mode,
+ wdsSSID: paramD.wifi_wds_ssid,
+ wdsAuthMode: paramD.wifi_wds_AuthMode,
+ wdsEncrypType: paramD.wifi_wds_EncrypType,
+ wdsWPAPSK1: paramD.wifi_wds_WPAPSK1,
+ RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0"
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setWDS(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({}, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSyslogInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: "1",
+ cmd: "syslog_mode,debug_level"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ currentMode: paramD.syslog_mode,
+ debugLevel: paramD.debug_level
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setSysLog(values, callback) {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({}, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getMacFilterInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ return {
+ multi_data: "1",
+ cmd: "ACL_mode,wifi_mac_black_list,wifi_hostname_black_list,wifi_cur_state,user_ip_addr,client_mac_address,wifi_mac_white_list"
+ };
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ ACL_mode: paramD.ACL_mode,
+ wifi_mac_black_list: paramD.wifi_mac_black_list,
+ wifi_hostname_black_list: paramD.wifi_hostname_black_list,
+ RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0",
+ user_ip_addr: paramD.user_ip_addr,
+ client_mac_address: paramD.client_mac_address,
+ wifi_mac_white_list: paramD.wifi_mac_white_list
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setMacFilter() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ var valueReq = $.extend({
+ goformId: 'WIFI_MAC_FILTER',
+ }, values);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getFastbootSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values) {
+ return {
+ cmd: "mgmt_quicken_power_on,need_hard_reboot,need_sim_pin",
+ multi_data: 1
+ };
+ }
+ function deal(paramD) {
+ return {
+ fastbootEnabled: paramD.mgmt_quicken_power_on == '1' ? '1' : '0',
+ need_hard_reboot: paramD.need_hard_reboot,
+ need_sim_pin: paramD.need_sim_pin == 'yes' ? 'yes' : 'no'
+ };
+ }
+ }
+ function setFastbootSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values) {
+ return {
+ goformId: "MGMT_CONTROL_POWER_ON_SPEED",
+ mgmt_quicken_power_on: values.fastbootEnabled
+ };
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function turnOffDevice() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "TURN_OFF_DEVICE";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function restart() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "REBOOT_DEVICE";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getScheduleSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "schedule_restart_enable,schedule_restart_hour,schedule_restart_minute";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.scheduleSetting = paramD.schedule_restart_enable == "1" ? "1" : "0";
+ result.scheduleHour = paramD.schedule_restart_hour;
+ result.scheduleMinute = paramD.schedule_restart_minute;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setScheduleSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SCHEDULE_SETTING";
+ valueReq.scheduleEnabled = values.scheduleSetting;
+ if (valueReq.scheduleEnabled == '1') {
+ valueReq.scheduleHour = values.scheduleHour;
+ valueReq.scheduleMinute = values.scheduleMinute;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getNewVersionState() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "fota_new_version_state,fota_current_upgrade_state,fota_package_already_download";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var hasNewVersion = (paramD.fota_new_version_state == 'has_critical' || paramD.fota_new_version_state == 'has_optional' || paramD.fota_new_version_state == 'already_has_pkg');
+ paramD.hasNewVersion = hasNewVersion;
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getMandatory() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ if (config.UPGRADE_TYPE == "OTA") {
+ valueReq.cmd = "is_mandatory";
+ } else {
+ valueReq.cmd = "fota_new_version_state";
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (config.UPGRADE_TYPE == "OTA") {
+ return {
+ "is_mandatory": paramD.is_mandatory == "1"
+ };
+ } else {
+ return {
+ "is_mandatory": paramD.fota_new_version_state == "has_critical"
+ };
+ }
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getUpgradeResult() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "upgrade_result";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getCurrentUpgradeState() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "fota_current_upgrade_state";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ paramD.current_upgrade_state = paramD.fota_current_upgrade_state;
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getPackSizeInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "fota_pkg_total_size,fota_dl_pkg_size";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setUpgradeSelectOp() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "IF_UPGRADE";
+ valueReq.select_op = values.selectOp;
+ if (valueReq.select_op == 'check') {
+ valueReq.ota_manual_check_roam_state = 1;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getOTAUpdateSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "fota_updateMode,fota_updateIntervalDay,fota_allowRoamingUpdate";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return {
+ updateMode: paramD.fota_updateMode,
+ updateIntervalDay: paramD.fota_updateIntervalDay,
+ allowRoamingUpdate: paramD.fota_allowRoamingUpdate
+ };
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setOTAUpdateSetting() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SetUpgAutoSetting";
+ valueReq.UpgMode = values.updateMode;
+ valueReq.UpgIntervalDay = values.updateIntervalDay;
+ valueReq.UpgRoamPermission = values.allowRoamingUpdate;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getOTAlastCheckTime() {
+ return getParams({
+ nv: ['dm_last_check_time']
+ }, arguments[1], arguments[2]);
+ }
+ function getSignalStrength() {
+ return getParams({
+ nv: ['network_type', 'sub_network_type', 'rssi', 'rscp', 'lte_rsrp']
+ }, arguments[1], arguments[2]);
+ }
+ function clearUpdateResult() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "RESULT_RESTORE";
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function childGroupList() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "childGroupList"
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && (paramD.childGroupList || paramD.devices)) {
+ return paramD;
+ } else {
+ return {
+ devices: []
+ };
+ }
+ }
+ }
+ function addChildGroup() {
+ return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
+ : {
+ errorType: 'no_auth'
+ }, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "ADD_DEVICE",
+ mac: values.macAddress
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function removeChildGroup() {
+ return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
+ : {
+ errorType: 'no_auth'
+ }, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "DEL_DEVICE",
+ mac: values.mac
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function checkCurrentUserInChildGroup(devices) {
+ if (typeof config.currentUserInChildGroup == "undefined") {
+ var childGroupDevice = [];
+ if (typeof devices != "undefined") {
+ childGroupDevice = devices;
+ } else {
+ childGroupDevice = childGroupList({}).devices;
+ }
+ var userMacAddr = getUserMacAddr({}).get_user_mac_addr;
+ var found = _.find(childGroupDevice, function (item) {
+ return item.mac == userMacAddr;
+ });
+ config.currentUserInChildGroup = typeof found != 'undefined';
+ return {
+ result: typeof found != 'undefined'
+ };
+ }
+ return {
+ result: config.currentUserInChildGroup
+ };
+ }
+ function getUserMacAddr() {
+ return getParams({
+ nv: 'get_user_mac_addr'
+ }, arguments[1], arguments[2]);
+ }
+ function getHostNameList() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "hostNameList"
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && (paramD.hostNameList || paramD.devices)) {
+ return paramD;
+ } else {
+ return {
+ devices: []
+ };
+ }
+ }
+ }
+ function editHostName() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "EDIT_HOSTNAME",
+ mac: values.mac,
+ hostname: values.hostname
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getSiteWhiteList() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "site_white_list"
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && (paramD.site_white_list || paramD.siteList)) {
+ return paramD;
+ } else {
+ return {
+ siteList: []
+ };
+ }
+ }
+ }
+ function removeSiteWhite() {
+ return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
+ : {
+ errorType: 'no_auth'
+ }, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "REMOVE_WHITE_SITE",
+ ids: values.ids.join(',')
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function saveSiteWhite() {
+ return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
+ : {
+ errorType: 'no_auth'
+ }, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "ADD_WHITE_SITE",
+ name: values.name,
+ site: values.site
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getTimeLimited() {
+ var defaultResult = {
+ '0': [],
+ '1': [],
+ '2': [],
+ '3': [],
+ '4': [],
+ '5': [],
+ '6': []
+ };
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "time_limited"
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return parseTimeLimited(paramD);
+ } else {
+ return defaultResult;
+ }
+ }
+ function parseTimeLimited(paramD) {
+ if (paramD.time_limited == '') {
+ return {
+ time_limited: []
+ };
+ }
+ var weeks = paramD.time_limited.split(';');
+ _.each(weeks, function (week) {
+ var weekTime = week.split('+');
+ if (weekTime.length == 2) {
+ defaultResult[weekTime[0]] = weekTime[1].split(',');
+ }
+ });
+ return defaultResult;
+ }
+ }
+ function saveTimeLimited() {
+ return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
+ : {
+ errorType: 'no_auth'
+ }, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "SAVE_TIME_LIMITED",
+ time_limited: values.time
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getTsw() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "openEnable,closeEnable,openTime,closeTime",
+ multi_data: '1'
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ if (paramD.openTime.indexOf(':') != -1) {
+ var open = paramD.openTime.split(':');
+ paramD.openH = leftInsert(open[0], 2, '0');
+ paramD.openM = leftInsert(open[1], 2, '0');
+ } else {
+ paramD.openH = '06';
+ paramD.openM = '00';
+ }
+ if (paramD.closeTime.indexOf(':') != -1) {
+ var close = paramD.closeTime.split(':');
+ paramD.closeH = leftInsert(close[0], 2, '0');
+ paramD.closeM = leftInsert(close[1], 2, '0');
+ } else {
+ paramD.closeH = '22';
+ paramD.closeM = '00';
+ }
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function saveTsw() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "SAVE_TSW",
+ openEnable: values.openEnable,
+ closeEnable: values.closeEnable
+ };
+ if (values.openEnable == '1') {
+ valueReq.openTime = values.openTime;
+ valueReq.closeTime = values.closeTime;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else if (paramD && paramD.result == 'failure') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function trafficCalibration() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {
+ goformId: "FLOW_CALIBRATION_MANUAL",
+ calibration_way: values.way,
+ time: values.way == 'time' ? values.value : 0,
+ data: values.way == 'data' ? values.value : 0
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == 'success') {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getParams() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ if (_.isArray(values.nv)) {
+ valueReq.cmd = values.nv.join(',');
+ valueReq.multi_data = 1;
+ } else {
+ valueReq.cmd = values.nv;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getRedirectData() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "vwim_mc_state,traffic_overrun,detect_new_version";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.vwim_mc_state = paramD.vwim_mc_state;
+ result.traffic_overrun = paramD.traffic_overrun;
+ result.detect_new_version = paramD.detect_new_version;
+ result.blc_wan_mode = informationAll.blc_wan_mode;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function clearRedirectFlag() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "CLEAR_REDIRECT_FLAG";
+ valueReq.flag_id = values.redirectFlags;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getV4Switch() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "lock_zone_enable,pin_interlock_and_V4_lock";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setV4Switch() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "PIN_LOCK_V4_ENCODE";
+ valueReq.pin_interlock_and_V4_lock = values.pin_interlock_and_V4_lock;
+ valueReq.TspLock_key_data = values.TspLock_key_data;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getCellId() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "cell_id_list,global_cell_id,network_type,sub_network_type,cell_not_correct";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setCellIdSwitch() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "LOCK_ZONE";
+ valueReq.lock_zone_enable = values.lock_zone_enable;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD && paramD.result == "success") {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getUpdateType() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {
+ cmd: "update_type"
+ };
+ return valueReq;
+ }
+ function deal(paramD) {
+ return {
+ update_type: paramD.update_type ? paramD.update_type : "mifi_fota"
+ }
+ }
+ }
+ function getSecurityInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.cmd = "AuthMode,passPhrase";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {};
+ result.AuthMode = paramD.AuthMode;
+ result.passPhrase = config.PASSWORD_ENCODE ? Base64.decode(paramD.passPhrase) : paramD.passPhrase;
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ //can delete
+ function setSecurityInfo() {
+ return stuffMake(arguments, {}, prepare, deal, null, true);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ valueReq.goformId = "SET_WIFI_SECURITY_INFO";
+ valueReq.AuthMode = values.AuthMode;
+ if (valueReq.AuthMode == "WPAPSKWPA2PSK") {
+ valueReq.passPhrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setWifiBasic() {
+ stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
+ function prepare(values) {
+ var valueReq = {
+ goformId: "SET_WIFI_SSID1_SETTINGS",
+ ssid: values.SSID,
+ broadcastSsidEnabled: values.broadcast,
+ MAX_Access_num: values.station,
+ security_mode: values.AuthMode,
+ cipher: values.cipher,
+ NoForwarding: values.NoForwarding,
+ show_qrcode_flag: values.show_qrcode_flag
+ };
+ if (config.WIFI_WEP_SUPPORT) {
+ valueReq.wep_default_key = values.wep_default_key;
+ valueReq.wep_key_1 = values.wep_key_1;
+ valueReq.wep_key_2 = values.wep_key_2;
+ valueReq.wep_key_3 = values.wep_key_3;
+ valueReq.wep_key_4 = values.wep_key_4;
+ if (values.wep_default_key == '1') {
+ valueReq.WEP2Select = values.WEP2Select;
+ } else if (values.wep_default_key == '2') {
+ valueReq.WEP3Select = values.WEP3Select;
+ } else if (values.wep_default_key == '3') {
+ valueReq.WEP4Select = values.WEP4Select;
+ } else {
+ valueReq.WEP1Select = values.WEP1Select;
+ }
+ }
+ if (values.AuthMode == "WPAPSK" || values.AuthMode == "WPA2PSK" || values.AuthMode == "WPAPSKWPA2PSK" || values.AuthMode == "WPA3Personal" || values.AuthMode == "WPA2WPA3") {
+ valueReq.security_shared_mode = values.cipher;
+ valueReq.passphrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
+ } else if (values.AuthMode == "SHARED") {
+ valueReq.security_shared_mode = "WEP";
+ valueReq.security_mode = "SHARED";
+ } else {
+ if (values.encryptType == "WEP") {
+ valueReq.security_shared_mode = "WEP";
+ valueReq.security_mode = "OPEN";
+ } else {
+ valueReq.security_shared_mode = "NONE";
+ }
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setWifiBasic4SSID2() {
+ stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
+ function prepare(values) {
+ var valueReq = {
+ goformId: "SET_WIFI_SSID2_SETTINGS",
+ m_SSID: values.m_SSID,
+ m_HideSSID: values.m_broadcast,
+ m_MAX_Access_num: values.m_station,
+ m_AuthMode: values.m_AuthMode,
+ cipher: values.m_cipher,
+ m_NoForwarding: values.m_NoForwarding,
+ m_show_qrcode_flag: values.m_show_qrcode_flag
+ };
+ if (config.WIFI_WEP_SUPPORT) {
+ valueReq.m_DefaultKeyID = values.m_wep_default_key;
+ valueReq.m_Key1Str1 = values.m_wep_key_1;
+ valueReq.m_Key2Str1 = values.m_wep_key_2;
+ valueReq.m_Key3Str1 = values.m_wep_key_3;
+ valueReq.m_Key4Str1 = values.m_wep_key_4;
+ if (values.m_wep_default_key == '1') {
+ valueReq.m_Key2Type = values.m_WEP2Select;
+ } else if (values.m_wep_default_key == '2') {
+ valueReq.m_Key3Type = values.m_WEP3Select;
+ } else if (values.m_wep_default_key == '3') {
+ valueReq.m_Key4Type = values.m_WEP4Select;
+ } else {
+ valueReq.m_Key1Type = values.m_WEP1Select;
+ }
+ }
+ if (values.m_AuthMode == "WPAPSK" || values.m_AuthMode == "WPA2PSK" || values.m_AuthMode == "WPAPSKWPA2PSK" || values.m_AuthMode == "WPA3Personal" || values.m_AuthMode == "WPA2WPA3") {
+ valueReq.m_EncrypType = values.m_cipher;
+ valueReq.m_WPAPSK1 = config.PASSWORD_ENCODE ? Base64.encode(values.m_passPhrase) : values.m_passPhrase;
+ } else if (values.m_AuthMode == "SHARED") {
+ valueReq.m_EncrypType = "WEP";
+ valueReq.m_security_mode = "SHARED";
+ } else {
+ if (values.m_encryptType == "WEP") {
+ valueReq.m_EncrypType = "WEP";
+ valueReq.m_security_mode = "OPEN";
+ } else {
+ valueReq.m_EncrypType = "NONE";
+ }
+ }
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function getWifiBasic() {
+ return stuffMake(arguments, {}, prepare, deal, null, false);
+ function prepare(values, isPost) {
+ var valueReq = {};
+ var wpapsk = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "imei,rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";
+ valueReq.cmd = "m_ssid_enable,wifi_cur_state,NoForwarding,m_NoForwarding," + wpapsk + "MAX_Station_num," + "SSID1,AuthMode,HideSSID,MAX_Access_num,show_qrcode_flag,EncrypType,Key1Str1,Key2Str1,Key3Str1,Key4Str1,DefaultKeyID," + "m_SSID,m_AuthMode,m_HideSSID,m_MAX_Access_num,m_EncrypType,m_show_qrcode_flag,m_DefaultKeyID,m_Key1Str1,m_Key2Str1,m_Key3Str1,m_Key4Str1,rotationFlag,wifi_sta_connection";
+ valueReq.multi_data = 1;
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ var result = {
+ wifi_enable: paramD.wifi_cur_state == "1" ? "1" : "0",
+ multi_ssid_enable: paramD.m_ssid_enable,
+ MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,
+ AuthMode: paramD.AuthMode,
+ SSID: paramD.SSID1,
+ broadcast: paramD.HideSSID,
+ apIsolation: paramD.NoForwarding,
+ passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),
+ MAX_Access_num: paramD.MAX_Access_num,
+ cipher: paramD.EncrypType == "TKIP" ? "0" : paramD.EncrypType == "AES" ? 1 : 2,
+ encryptType: paramD.EncrypType,
+ show_qrcode_flag: paramD.show_qrcode_flag == "1" ? true : false,
+ keyID: paramD.DefaultKeyID,
+ Key1Str1: paramD.Key1Str1,
+ Key2Str1: paramD.Key2Str1,
+ Key3Str1: paramD.Key3Str1,
+ Key4Str1: paramD.Key4Str1,
+ m_SSID: paramD.m_SSID,
+ m_broadcast: paramD.m_HideSSID,
+ m_apIsolation: paramD.m_NoForwarding,
+ m_MAX_Access_num: paramD.m_MAX_Access_num,
+ m_AuthMode: paramD.m_AuthMode,
+ m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),
+ m_cipher: paramD.m_EncrypType == "TKIP" ? "0" : paramD.m_EncrypType == "AES" ? 1 : 2,
+ m_show_qrcode_flag: paramD.m_show_qrcode_flag == "1" ? true : false,
+ m_encryptType: paramD.m_EncrypType,
+ m_keyID: paramD.m_DefaultKeyID,
+ m_Key1Str1: paramD.m_Key1Str1,
+ m_Key2Str1: paramD.m_Key2Str1,
+ m_Key3Str1: paramD.m_Key3Str1,
+ m_Key4Str1: paramD.m_Key4Str1,
+ rotationFlag: paramD.rotationFlag,
+ ap_station_enable: paramD.wifi_sta_connection
+ };
+ return result;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function setWifiBasicMultiSSIDSwitch() {
+ stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
+ function prepare(values) {
+ var paraTemp = values;
+ if (values.wifiEnabled == '0') {
+ paraTemp = {
+ wifiEnabled: values.wifiEnabled
+ }
+ }
+ var valueReq = $.extend({
+ goformId: "SET_WIFI_INFO",
+ }, paraTemp);
+ return valueReq;
+ }
+ function deal(paramD) {
+ if (paramD) {
+ return paramD;
+ } else {
+ return errUnknownObj;
+ }
+ }
+ }
+ function stuffMake(array, result, prepare, dealMethod, errorObject, isPost) {
+ var values = array[0],
+ callback = array[1],
+ errorCallback = array[2];
+ var objectToReturn;
+ if (result && typeof result.errorType === 'string') {
+ objectToReturn = $.extend(errUnknownObj, result);
+ if (!callback) {
+ return objectToReturn;
+ }
+ doCallback(objectToReturn, callback, errorCallback);
+ } else {
+ objectToReturn = $.extend({}, result);
+ var valueReq;
+ if (prepare) {
+ valueReq = prepare(values, isPost);
+ } else {
+ valueReq = values;
+ }
+ if (!callback) {
+ if (valueReq && (valueReq.cmd || valueReq.goformId)) {
+ var r = reqSync(valueReq, isPost);
+ if (dealMethod) {
+ objectToReturn = $.extend({}, dealMethod(r));
+ } else {
+ objectToReturn = r;
+ }
+ }
+ return objectToReturn;
+ } else {
+ if (valueReq && (valueReq.cmd || valueReq.goformId)) {
+ reqAsync(valueReq, function (paramD) {
+ if (dealMethod) {
+ objectToReturn = $.extend({}, dealMethod(paramD));
+ } else {
+ objectToReturn = $.extend({}, paramD);
+ }
+ if (!valueReq.notCallback) {
+ doCallback(objectToReturn, callback, errorCallback);
+ }
+ }, function () {
+ if (errorObject) {
+ objectToReturn = $.extend(errUnknownObj, errorObject);
+ } else {
+ objectToReturn = $.extend(errUnknownObj, {
+ errorType: 'Unknown'
+ });
+ }
+ doCallback(objectToReturn, callback, errorCallback);
+ }, isPost);
+ } else {
+ doCallback(objectToReturn, callback, errorCallback);
+ }
+ }
+ }
+ function doCallback(resultToReturn, callback, errorCallback) {
+ errorCallback = errorCallback ? errorCallback : callback;
+ if (isErrorObject(resultToReturn)) {
+ switch (resultToReturn.errorType) {
+ case 'cellularNetworkError':
+ case 'deviceError':
+ case 'wifiConnectionError':
+ window.receivedNonSpecificError(resultToReturn);
+ break;
+ default:
+ errorCallback(resultToReturn);
+ }
+ } else {
+ callback(resultToReturn);
+ }
+ }
+ }
+ function reqSync(values, isPost) {
+ return reqAJAX(values, null, null, false, isPost);
+ }
+ function reqAsync(values, successCallback, errorCallback, isPost) {
+ reqAJAX(values, successCallback, errorCallback, true, isPost);
+ }
+ function getString(values){
+ var regexp = /^[A-z0-9]+$/;
+ var matches = values.match(regexp);
+ if (matches == null){
+ return "error";
+ } else {
+ return values;
+ }
+ }
+ function reqAJAX(values, successCallback, errorCallback, async, isPost) {
+ var result = null;
+ $.ajax({
+ type: !!isPost ? "POST" : "GET",
+ url: isPost ? "/reqproc/proc_post" : values.cmd ? "/reqproc/proc_get" : "/reqproc/proc_post",
+ data: values,
+ dataType: "json",
+ async: !!async,
+ cache: false,
+ error: function (paramD) {
+ if (async) {
+ errorCallback(paramD);
+ } else if (paramD.status == 200) {
+ result = jQuery.parseJSON('(' + getString(paramD.responseText) + ')');
+ }
+ },
+ success: function (paramD) {
+ if (async) {
+ successCallback(paramD);
+ } else {
+ result = paramD;
+ }
+ }
+ });
+ if (!async) {
+ return result;
+ }
+ }
+ var informationAll = {
+ networkType: "",
+ signalImg: "0",
+ spn_b1_flag: "1",
+ spn_name_data: "",
+ spn_b2_flag: "1",
+ networkOperator: "China Mobile",
+ connectStatus: "ppp_disconnected",
+ rj45ConnectStatus: "rj45_dead",
+ attachedDevices: [],
+ ssid1AttachedNum: 0,
+ ssid2AttachedNum: 0,
+ data_counter: {
+ uploadRate: 0,
+ downloadRate: 0,
+ totalSent: 0,
+ totalReceived: 0,
+ totalConnectedTime: 0,
+ currentSent: 0,
+ currentReceived: 0,
+ currentConnectedTime: 0,
+ monthlySent: 0,
+ monthlyReceived: 0,
+ monthlyConnectedTime: 0,
+ month: ''
+ },
+ newSmsReceived: false,
+ smsReportReceived: false,
+ smsUnreadCount: "0",
+ isLoggedIn: undefined,
+ limitVolumeEnable: false,
+ limitVolumeType: '1',
+ limitVolumePercent: "100",
+ limitVolumeSize: "0",
+ allowRoamingUpdate: "0",
+ blc_wan_mode: "",
+ ap_station_enable: undefined,
+ ap_station_mode: undefined,
+ dialMode: '',
+ ethWanMode: 'AUTO',
+ fota_user_selector: '',
+ defaultWanName: ""
+ };
+ var errUnknownObj = {
+ errorType: 'UnknownError',
+ errorId: '123',
+ errorText: 'UnknownError'
+ };
+ var updateTimerFlag = true;
+ return {
+ clearRedirectFlag: clearRedirectFlag,
+ connect: connect,
+ disconnect: disconnect,
+ getSIMPhoneBookCapacity: getSIMPhoneBookCapacity,
+ getDevicePhoneBookCapacity: getDevicePhoneBookCapacity,
+ getDevicePhoneBooks: getDevicePhoneBooks,
+ getSIMPhoneBooks: getSIMPhoneBooks,
+ getPhoneBooks: getPhoneBooks,
+ getPhoneBookReady: getPhoneBookReady,
+ getPhoneBooksByGroup: getPhoneBooksByGroup,
+ deletePhoneBooks: deletePhoneBooks,
+ deleteAllPhoneBooks: deleteAllPhoneBooks,
+ deleteAllPhoneBooksByGroup: deleteAllPhoneBooksByGroup,
+ savePhoneBook: savePhoneBook,
+ deleteAllMessages: deleteAllMessages,
+ deleteMessage: deleteMessage,
+ setSmsRead: setSmsRead,
+ sendSMS: sendSMS,
+ saveSMS: saveSMS,
+ getSMSReady: getSMSReady,
+ getSMSMessages: getSMSMessages,
+ getSMSDeliveryReport: getSMSDeliveryReport,
+ getSmsCapability: getSmsCapability,
+ resetNewSmsReceivedVar: resetNewSmsReceivedVar,
+ resetSmsReportReceivedVar: resetSmsReportReceivedVar,
+ getSmsSetting: getSmsSetting,
+ setSmsSetting: setSmsSetting,
+ getAttachedCableDevices: getAttachedCableDevices,
+ getCurrentlyAttachedDevicesInfo: getCurrentlyAttachedDevicesInfo,
+ getConnectionInfo: getConnectionInfo,
+ getRedirectData: getRedirectData,
+ getLanguage: getLanguage,
+ setLanguage: setLanguage,
+ getNetSelectInfo: getNetSelectInfo,
+ getSecurityInfo: getSecurityInfo,
+ setSecurityInfo: setSecurityInfo,
+ getStatusInfo: getStatusInfo,
+ getConnectionMode: getConnectionMode,
+ setConnectionMode: setConnectionMode,
+ getWifiBasic: getWifiBasic,
+ setWifiBasic: setWifiBasic,
+ setWifiBasic4SSID2: setWifiBasic4SSID2,
+ setWifiBasicMultiSSIDSwitch: setWifiBasicMultiSSIDSwitch,
+ getWpsInfo: getWpsInfo,
+ openWps: openWps,
+ getSleepMode: getSleepMode,
+ setSleepMode: setSleepMode,
+ getWifiAdvance: getWifiAdvance,
+ setWifiAdvance: setWifiAdvance,
+ getWifiRange: getWifiRange,
+ setWifiRange: setWifiRange,
+
+ getLoginStatus: getLoginStatus,
+ getLoginData: getLoginData,
+ login: login,
+ logout: logout,
+ changeManageInfo: changeManageInfo,
+ getPinData: getPinData,
+ enablePin: enablePin,
+ disablePin: disablePin,
+ changePin: changePin,
+ enterPIN: enterPIN,
+ enterPUK: enterPUK,
+ getLanInfo: getLanInfo,
+ setLanInfo: setLanInfo,
+ getApnSettings: getApnSettings,
+ deleteApn: deleteApn,
+ setDefaultApn: setDefaultApn,
+ addOrEditApn: addOrEditApn,
+ getQuickSettingInfo: getQuickSettingInfo,
+ setQuickSetting4IPv6: setQuickSetting4IPv6,
+ scanForNetwork: scanForNetwork,
+ setBearerPreference: setBearerPreference,
+ editHostName: editHostName,
+ getSiteWhiteList: getSiteWhiteList,
+ removeSiteWhite: removeSiteWhite,
+ saveSiteWhite: saveSiteWhite,
+ setNetwork: setNetwork,
+ getUpnpSetting: getUpnpSetting,
+ setUpnpSetting: setUpnpSetting,
+ getDmzSetting: getDmzSetting,
+ setDmzSetting: setDmzSetting,
+ getDeviceInfo: getDeviceInfo,
+ getDeviceInfoLow: getDeviceInfoLow,
+ getPortForward: getPortForward,
+ setPortForward: setPortForward,
+ getPortFilter: getPortFilter,
+ setPortFilterBasic: setPortFilterBasic,
+ setPortFilter: setPortFilter,
+ deleteFilterRules: deleteFilterRules,
+ getPortMap: getPortMap,
+ setPortMap: setPortMap,
+ enablePortMap: enablePortMap,
+ deleteMapRules: deleteMapRules,
+ getTrafficAlertInfo: getTrafficAlertInfo,
+ setTrafficAlertInfo: setTrafficAlertInfo,
+ getCurrentUpgradeState: getCurrentUpgradeState,
+ setUpgradeSelectOp: setUpgradeSelectOp,
+ addTimerThings: addTimerSomething,
+ removeTimerThings: removeTimerSomething,
+ getPackSizeInfo: getPackSizeInfo,
+ getMandatory: getMandatory,
+ getOTAUpdateSetting: getOTAUpdateSetting,
+ setOTAUpdateSetting: setOTAUpdateSetting,
+ getSignalStrength: getSignalStrength,
+ getOTAlastCheckTime: getOTAlastCheckTime,
+ clearUpdateResult: clearUpdateResult,
+ refreshAPStationStatus: refreshAPStationStatus,
+ getSntpParams: getSntpParams,
+ setSntpSetting: setSntpSetting,
+ setSNTPDate: setSNTPDate,
+ restoreFactorySettings: restoreFactorySettings,
+ checkRestoreStatus: checkRestoreStatus,
+ getSysSecurity: getSysSecurity,
+ setSysSecurity: setSysSecurity,
+ deleteForwardRules: deleteForwardRules,
+ enableVirtualServer: enableVirtualServer,
+ getSDConfiguration: getSDConfiguration,
+ setSdCardMode: setSdCardMode,
+ checkFileExists: checkFileExists,
+ getFileList: getFileList,
+ fileRename: fileRename,
+ getSdMemorySizes: getSdMemorySizes,
+ deleteFilesAndFolders: deleteFilesAndFolders,
+ createFolder: createFolder,
+ setSdCardSharing: setSdCardSharing,
+ setUpdateInfoWarning: setUpdateInfoWarning,
+ getUpdateInfoWarning: getUpdateInfoWarning,
+ getAPStationBasic: getAPStationBasic,
+ setAPStationBasic: setAPStationBasic,
+ getWdsInfo: getWdsInfo,
+ setWDS: setWDS,
+ addUrlFilterRule: addUrlFilterRule,
+ getUrlFilterList: getUrlFilterList,
+ deleteSelectedRules: deleteSelectedRules,
+ getMacFilterInfo: getMacFilterInfo,
+ setMacFilter: setMacFilter,
+ getFastbootSetting: getFastbootSetting,
+ setFastbootSetting: setFastbootSetting,
+ turnOffDevice: turnOffDevice,
+ restart: restart,
+ getScheduleSetting: getScheduleSetting,
+ setScheduleSetting: setScheduleSetting,
+ updateTimerFlag: updateTimerFlag,
+ childGroupList: childGroupList,
+ addChildGroup: addChildGroup,
+ removeChildGroup: removeChildGroup,
+ checkCurrentUserInChildGroup: checkCurrentUserInChildGroup,
+ getTimeLimited: getTimeLimited,
+ saveTimeLimited: saveTimeLimited,
+ getHostNameList: getHostNameList,
+ getHotspotList: getHotspotList,
+ searchHotspot: searchHotspot,
+ getSearchHotspotList: getSearchHotspotList,
+ saveHotspot: saveHotspot,
+ deleteHotspot: deleteHotspot,
+ connectHotspot: connectHotspot,
+ disconnectHotspot: disconnectHotspot,
+ getOpMode: getOpMode,
+ getRj45PlugState: getRj45PlugState,
+ SetOperationMode: SetOperationMode,
+ getPppoeParams: getPppoeParams,
+ setPppoeDialMode: setPppoeDialMode,
+ getTsw: getTsw,
+ saveTsw: saveTsw,
+ trafficCalibration: trafficCalibration,
+ getParams: getParams,
+ getNewVersionState: getNewVersionState,
+ getUpgradeResult: getUpgradeResult,
+ getV4Switch: getV4Switch,
+ setV4Switch: setV4Switch,
+ getCellId: getCellId,
+ setCellIdSwitch: setCellIdSwitch,
+ getDdnsParams: getDdnsParams,
+ setDDNSForward: setDDNSForward,
+ getUpdateType: getUpdateType,
+ getCurretnMAC: getCurretnMAC,
+ getUSSDResponse: getUSSDResponse,
+ USSDReplyCancel: USSDReplyCancel,
+ getNetworkUnlockTimes: getNetworkUnlockTimes,
+ unlockNetwork: unlockNetwork,
+ getSyslogInfo: getSyslogInfo,
+ setSysLog: setSysLog,
+ };
+});
+
+ // RouterÉèÖÃ
+
+define("adm_lan","jquery knockout set service".split(" "),
+
+ function ($, ko, config, service) {
+
+ var originfrmLan = "";
+
+ // »ñȡ·ÓÉÉèÖÃÏà¹ØÐÅÏ¢
+ function getLanInfo() {
+ return service.getLanInfo();
+ }
+
+ function hex(val) {
+ var h = (val - 0).toString(16);
+ if (h.length == 1)
+ h = '0' + h;
+ return h.toUpperCase();
+ }
+
+ function LanViewModel() {
+ var target = this;
+
+ var info = getLanInfo();
+
+ target.dhcpStart = ko.observable(info.dhcpStart);
+ target.dhcpEnd = ko.observable(info.dhcpEnd);
+ target.dhcpLease = ko.observable(info.dhcpLease);
+
+ target.ipAddress = ko.observable(info.ipAddress);
+ target.subnetMask = ko.observable(info.subnetMask);
+ target.dhcpServer = ko.observable(info.dhcpServer);
+
+ target.macAddress = ko.observable(info.macAddress);
+ target.showMacAddress = ko.observable(config.SHOW_MAC_ADDRESS);
+
+ target.hasWifi = ko.observable(config.HAS_WIFI);
+ target.hasUssd = config.HAS_USSD;
+ target.hasDdns = config.DDNS_SUPPORT;
+
+ target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
+
+ target.clear = function () {
+ clearTimer();
+ init();
+ clearValidateMsg();
+ };
+
+ target.refreshStatus = function () {
+ var connInfo = service.getConnectionInfo();
+ if (connInfo.connectStatus == 'ppp_disconnected') {
+ $('input', '#frmLan').each(function () {
+ $(this).attr("disabled", false);
+ });
+ } else {
+ $('input', '#frmLan').each(function () {
+ $(this).attr("disabled", true);
+ });
+
+ clearValidateMsg();
+ }
+ };
+
+ // ÉèÖÃÏìÓ¦º¯Êý£¬½øÐÐÉèÖñ£´æ
+ target.saveAct = function () {
+ showLoading();
+ var params = {
+ ipAddress: target.ipAddress(),
+ subnetMask: target.subnetMask(),
+ dhcpServer: target.dhcpServer(),
+ dhcpStart: target.dhcpStart(),
+ dhcpEnd: target.dhcpEnd(),
+ dhcpLease: target.dhcpLease()
+ };
+
+ service.setLanInfo(params, function (result) {
+ if (result.result == "success") {
+ successOverlay();
+ target.clear();
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+ // ÉèÖÃÏìÓ¦º¯Êý£¬½øÐÐÉèÖñ£´æ
+ target.save = function () {
+ var frmLanObj = $('#frmLan').serialize();
+ if (frmLanObj == originfrmLan) {
+ showAlert("setting_no_change");
+ return false;
+ }
+ if (config.RJ45_SUPPORT) {
+ var pppObj = service.getPppoeParams();
+ if (sf_isValidate_StaticIP(pppObj.static_wan_ipaddr, target.ipAddress(), target.subnetMask())) {
+ showAlert("lan_tip_staticip_notsame");
+ return false;
+ }
+ }
+ showConfirm("lan_confirm_reopen", function () {
+ target.saveAct();
+ });
+ };
+
+ target.refreshStatus();
+ // dhcpServerÇл»ÏìÓ¦º¯Êý
+ target.dhcpServerHandler = function () {
+ $("#txtIpAddress").parent().find(".error").hide();
+ $("#txtIpAddress").show();
+ return true;
+ };
+ addTimeout(function () {
+ originfrmLan = $('#frmLan').serialize();
+ }, 500);
+ }
+
+
+ function sf_opAnd4Byte(i_v1, i_v2) {
+ var index;
+ var var1 = [];
+ var var2 = [];
+ var result='0x';
+
+ for (index=2,index_tmp=0; index<10; index+=2,index_tmp++) {
+ var1[index_tmp]='0x'+i_v1.substring(index,index+2);
+ var2[index_tmp]='0x'+i_v2.substring(index,index+2);
+ }
+
+ for (index=0; index<4; index++) {
+ result = result + hex(var1[index]&var2[index]);
+ }
+
+ return result - 0;
+ }
+
+ // ½çÃæÏà¹Ø±íµ¥Ð£Ñ鹿Ôò
+ $.validator.addMethod("dhcp_check", function (i_value, i_element, i_parameter) {
+ var dhcpIp = i_parameter == "start" ? $('#txtDhcpIpPoolStart').val() : $('#txtDhcpIpPoolEnd').val();
+ var result = sf_isValidate_Gateway($('#txtIpAddress').val(), $('#txtSubnetMask').val(), dhcpIp);
+ return this.optional(i_element) || result;
+ });
+
+ $.validator.addMethod("dhcpCompare", function (i_value, i_element, i_parameter) {
+ var result;
+ if(i_parameter == "#txtDhcpIpPoolStart") {
+ result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), $(i_parameter).val(), i_value);
+ }
+ else {
+ result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), i_value, $(i_parameter).val());
+ }
+ return result != 1;
+ });
+
+ $.validator.addMethod("ipRange", function (i_value, i_element, i_parameter) {
+ var DHCP_flag = false;
+ if($('#dhcpEnable').is(':checked')){
+ DHCP_flag = true;
+ }
+ var result = sf_isValidate_StartEndIp(i_value, $('#txtSubnetMask').val(), $('#txtDhcpIpPoolStart').val(), $('#txtDhcpIpPoolEnd').val(), DHCP_flag);
+ return result != 2;
+ });
+
+ $.validator.addMethod("subnetmask_check", function (i_value, i_element, i_parameter) {
+ var result = sf_isValidate_Netmask(i_value);
+ return this.optional(i_element) || result;
+ });
+
+
+ // ¾²Ì¬ÓÐЧIPУÑ麯Êý
+ function sf_isValidate_StaticIP(i_ip, i_lanIp, i_lanMask){
+ if(!i_ip || !i_lanIp || !i_lanMask){//¸÷²ÎÊý²»ÄÜΪ¿Õ
+ return false;
+ }
+
+ //ÓëÄÚÍøIPÏàµÈ
+ if (i_ip == i_lanIp) {
+ return true;
+ }
+
+ var res1 = [];
+ var res2 = [];
+
+ var mask_array = [];
+
+ ip_array = i_ip.split(".");
+ lanIp_array = i_lanIp.split(".");
+ mask_array = i_lanMask.split(".");
+ for(var index = 0; index < ip_array.length; index += 1){
+ res1.push(parseInt(mask_array[index]) & parseInt(ip_array[index]));
+ res2.push(parseInt(mask_array[index]) & parseInt(lanIp_array[index]));
+ }
+ if(res2.join(".") != res1.join(".")){//ÔÚ²»Í¬Íø¶Î
+ return false;
+ }else{//ÔÚÍ¬Ò»Íø¶Î
+ return true;
+ }
+ }
+
+
+ function sf_isValidate_NetmaskIP(i_ip) {
+ return (i_ip == 255
+ || i_ip == 254
+ || i_ip == 252
+ || i_ip == 248
+ || i_ip == 240
+ || i_ip == 224
+ || i_ip == 192
+ || i_ip == 128
+ || i_ip == 0);
+ }
+
+ function sf_convertIpToString(i_ip)
+ {
+ var s_i1 = i_ip.indexOf('.');
+ var s_i2 = i_ip.indexOf('.', (s_i1 + 1));
+ var s_i3 = i_ip.indexOf('.', (s_i2 + 1));
+ o_ip = hex(i_ip.substring(0, s_i1)) + hex(i_ip.substring((s_i1 + 1), s_i2)) + hex(i_ip.substring((s_i2 + 1), s_i3)) + hex(i_ip.substring((s_i3 + 1), i_ip.length));
+ o_ip = '0x' + o_ip;
+
+ return o_ip;
+ }
+
+ function sf_getIpString_3(i_ip)
+ {
+ var i1 = i_ip.indexOf('.');
+ var i2 = i_ip.indexOf('.', (i1 + 1));
+ var i3 = i_ip.indexOf('.', (i2 + 1));
+ var i4 = i_ip.substring((i3+1),i_ip.length)-0;
+
+ return i4;
+ }
+
+
+ // Íø¹ØÐ£Ñ麯Êý
+ function sf_isValidate_Gateway(i_wanIp, i_netmaskIp, i_gatewayIp) {
+ var s_wanIp = sf_convertIpToString(i_wanIp);
+ var lan4 = sf_getIpString_3(i_wanIp);
+
+ var s_netmaskIp = sf_convertIpToString(i_netmaskIp);
+ var mask4 = sf_getIpString_3(i_netmaskIp);
+
+ var s_gatewayIp = sf_convertIpToString(i_gatewayIp);
+ var pool4 = sf_getIpString_3(i_gatewayIp);
+
+ var net_no;
+ var lo_broadcast;
+
+ if (sf_opAnd4Byte(s_wanIp, s_netmaskIp) != sf_opAnd4Byte(s_gatewayIp, s_netmaskIp)) {
+ return false;
+ }
+
+ net_no = (lan4 & mask4);
+ lo_broadcast = (lan4 & mask4) + (255-mask4);
+
+ return !(pool4==net_no || pool4==lo_broadcast);
+
+ }
+
+ // ×ÓÍøÑÚÂëУÑ麯Êý
+ function sf_isValidate_Netmask(i_netmask) {
+ var addr = i_netmask.split(".");
+
+ if ("0.0.0.0" == i_netmask || "255.255.255.255" == i_netmask) {
+ return false;
+ }
+
+ if (addr.length != 4) {
+ return false;
+ }
+
+ addr[0] = parseInt(addr[0]);
+ addr[1] = parseInt(addr[1]);
+ addr[2] = parseInt(addr[2]);
+ addr[3] = parseInt(addr[3]);
+
+ if (addr[3] != 0) {
+ if (addr[0] != 255 || addr[1] != 255 || addr[2] != 255) {
+ return false;
+ } else {
+ if (!sf_isValidate_NetmaskIP(addr[3])) {
+ return false;
+ }
+ }
+ }
+
+ if (addr[2] != 0) {
+ if (addr[0] != 255 || addr[1] != 255) {
+ return false;
+ } else {
+ if (!sf_isValidate_NetmaskIP(addr[2])) {
+ return false;
+ }
+ }
+ }
+
+ if (addr[1] != 0) {
+ if (addr[0] != 255) {
+ return false;
+ } else {
+ if (!sf_isValidate_NetmaskIP(addr[1])) {
+ return false;
+ }
+ }
+ }
+
+ if (addr[0] != 255) {
+ return false;
+ }
+
+ return true;
+ }
+
+ // DHCP IP³ØÐ£Ñ麯Êý
+ function sf_isValidate_StartEndIp(i_lanIpaddr, i_netIp, i_startIp, i_endIp, i_DHCPFlag) {
+ s_startIp = sf_convertIpToString(i_startIp);
+ s_endIp = sf_convertIpToString(i_endIp);
+ s_lanIp = sf_convertIpToString(i_lanIpaddr);
+
+ if(s_startIp>s_endIp) {
+ return 1;
+ }
+
+ if(s_lanIp >= s_startIp && s_lanIp <= s_endIp) {
+ return 2;
+ }
+
+ return 0;
+ }
+
+
+ function init() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var fwVm = new LanViewModel();
+ ko.applyBindings(fwVm, container[0]);
+
+ addInterval(fwVm.refreshStatus, 1000);
+
+ $('#frmLan').validate({
+ submitHandler:function () {
+ fwVm.save();
+ },
+
+ rules:{
+ txtIpAddress: {
+ lanip_check: true,
+ ipRange: true
+ },
+ txtSubnetMask: {
+ ipv4: true,
+ subnetmask_check: true
+ },
+ txtDhcpIpPoolStart: {
+ lanip_check: true,
+ dhcp_check: "start",
+ dhcpCompare: "#txtDhcpIpPoolEnd"
+ },
+ txtDhcpIpPoolEnd: {
+ lanip_check: true,
+ dhcp_check: "end",
+ dhcpCompare: "#txtDhcpIpPoolStart"
+ },
+ txtDhcpLease: {
+ range: [1, 65535],
+ digits: true
+ }
+ },
+
+ groups: {
+ lanip_check: "txtDhcpIpPoolStart txtDhcpIpPoolEnd"
+ },
+
+ errorPlacement: function (error, element) {
+ if (element.attr("name") == "txtDhcpLease") {
+ error.insertAfter("#errorHolder");
+ } else if (element.attr("name") == "txtDhcpIpPoolStart") {
+ error.insertAfter("#txtDhcpIpPoolEnd");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+
+ }
+
+
+ return {
+ init:init
+ }
+});
+
+// others Ä£¿é°üº¬:Fast Boot Settings¡¢Restart and Reset¡¢SNTP¡¢Turn Off Device¡¢PIN Management
+define("adm_others","jquery knockout set service underscore".split(" "),
+
+ function ($, ko, config, service, _) {
+
+ var timeSetModes = _.map(config.sntpTimeSetMode, function(item) {
+ return new Option(item.name, item.value);
+ });
+
+ var timeZones = _.map(config.timeZone, function(item){
+ return new Option(item.name, item.value);
+ });
+
+ var daylightSave = _.map(config.daylightSave, function(item){
+ return new Option(item.name, item.value);
+ });
+
+ var sv_sntpYears = [];
+ var sv_sntpMonths = [];
+ var sv_sntpDates = []; //¸ù¾Ý´óСÔÂÉú³ÉÊý×é
+ var sv_sntpHours = [];
+ var sv_sntpMinutes = [];
+ var sc_startpHours = [];
+ var sc_startMinutes = [];
+
+ var sf_bigMonth = [1, 3, 5, 7, 8, 10, 12];
+ var sf_smallMonth = [4, 6, 9, 11];
+
+ function sf_produceArray(start, end, arryName) {
+ var item = {};
+ for(var i = start; i <= end; i++) {
+ item.name = i;
+ item.value = i;
+ arryName.push(new Option(item.name, item.value));
+ }
+ }
+
+ //Éú³ÉÄê¡¢Ô¡¢Ê±¡¢·ÖµÄÊý×é
+ sf_produceArray(2000, 2030, sv_sntpYears);
+ sf_produceArray(1, 12, sv_sntpMonths);
+ sf_produceArray(0, 23, sv_sntpHours);
+ sf_produceArray(0, 59, sv_sntpMinutes);
+ sf_produceArray(0, 23, sc_startpHours);
+ sf_produceArray(0, 59, sc_startMinutes);
+
+ function othersViewModel() {
+ var target = this;
+
+ var inChildGroup = false;
+ var scheduleInfo = service.getScheduleSetting();
+
+ target.fastbootSupport = config.FAST_BOOT_SUPPORT;
+ target.turnOffSupport = config.TURN_OFF_SUPPORT;
+ target.SNTPSupport = config.HAS_SNTP;
+ target.hasUssd = config.HAS_USSD;
+ target.hasDdns = config.DDNS_SUPPORT;
+ target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
+ target.scheduleSetting = ko.observable(scheduleInfo.scheduleSetting);
+ target.scheduleHour = ko.observable(parseInt(scheduleInfo.scheduleHour));
+ target.scheduleMinute = ko.observable(parseInt(scheduleInfo.scheduleMinute));
+ target.scr_hours = ko.observableArray(sc_startpHours);
+ target.scr_minutes = ko.observableArray(sc_startMinutes);
+
+
+ if (config.HAS_PARENTAL_CONTROL) {
+ inChildGroup = service.checkCurrentUserInChildGroup().result;
+ }
+ target.currentUserInChildGroup = ko.observable(inChildGroup);
+
+ var sv_fastbootInfo = service.getFastbootSetting();
+ target.fastbootEnableFlag = ko.observable(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");
+ target.fastbootSetting = ko.observable(sv_fastbootInfo.fastbootEnabled);
+
+
+ // @method addInterval
+ addInterval(function(){
+ target.fastbootEnableFlag(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");
+ }, 1000);
+
+ // »Ö¸´³ö³§ÉèÖÃ
+ // @event restore
+ target.restore = function () {
+ showConfirm("restore_confirm", function () {
+ showLoading("restoring");
+ service.restoreFactorySettings({}, function (info) {
+ if (info && info.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }, function (result) {
+ if (isErrorObject(result) && result.errorType == 'no_auth') {
+ errorOverlay();
+ }
+ });
+ });
+ };
+
+ target.restart = function () {
+ showConfirm("restart_confirm", function () {
+ restartDevice(service);
+ });
+ };
+
+ target.scheduleRestart = function () {
+ showLoading();
+ var params = {};
+ params.scheduleSetting = target.scheduleSetting();
+ params.scheduleHour = target.scheduleHour();
+ params.scheduleMinute = target.scheduleMinute();
+ service.setScheduleSetting(params, function (result) {
+ if (result.result != "success") {
+ errorOverlay();
+ } else {
+ successOverlay();
+ }
+ });
+ };
+
+ // ¿ìËÙ¿ª¹Ø»úÉèÖÃ
+ target.saveFastBoot = function() {
+ showLoading();
+ var params = {
+ fastbootEnabled: target.fastbootSetting(),
+ need_hard_reboot: sv_fastbootInfo.need_hard_reboot
+ };
+ service.setFastbootSetting(params, function(result) {
+ if (result.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+ // ¹Ø»ú
+ target.turnoff = function () {
+ showConfirm("turnoff_confirm", function () {
+ showLoading("turnoff");
+ service.turnOffDevice({}, function (info) {
+ if (info && info.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }, $.noop);
+ });
+ };
+
+ //SNTP´¥·¢serverУ׼ʱ¼ä
+ service.setSNTPDate({
+ goformId: "SNTP_Getdatastatic"
+ });
+
+ var target = this;
+ var sntpInfo = service.getSntpParams();
+
+ globalTime = new Date(parseInt(sntpInfo.sntp_year, 10),parseInt(sntpInfo.sntp_month, 10)-1, parseInt(sntpInfo.sntp_day, 10), parseInt(sntpInfo.sntp_hour, 10), parseInt(sntpInfo.sntp_minute, 10), parseInt(sntpInfo.sntp_second, 10));
+
+ target.day = ko.observable();
+ target.localTime = ko.observable();
+
+ //³õʼ»¯µ±Ç°±¾µØÊ±¼ä
+ //target.updateCurrentTime; cov_2
+ target.timeSetModes = ko.observableArray(timeSetModes);
+ target.isManualSetTime = ko.observable(false);
+ target.isAutoSntpTime = ko.observable(false);
+
+ target.currentMode = ko.observable(sntpInfo.sntp_time_set_mode);
+
+ changeSetTimeMode();
+ target.changeSetTimeMode = function(){
+ changeSetTimeMode();
+ };
+
+ target.currentYear = ko.observable(parseInt(sntpInfo.sntp_year, 10));
+ target.currentMonth = ko.observable(parseInt(sntpInfo.sntp_month, 10));
+ target.currentDate = ko.observable(parseInt(sntpInfo.sntp_day, 10));
+ target.currentHour = ko.observable(parseInt(sntpInfo.sntp_hour, 10));
+ target.currentMinute = ko.observable(parseInt(sntpInfo.sntp_minute, 10));
+
+
+ // ÐèÒª¸ù¾ÝÄêÔÂË¢ÐÂÈÕÆÚÁбíÊý¾Ý£¬×¢Òâ˳Ðò
+
+ target.years = ko.observableArray(sv_sntpYears);
+ target.months = ko.observableArray(sv_sntpMonths);
+ //µ±Óû§Ñ¡ÔñÔ·ݵÄʱºò¸Ä±äÈÕÆÚÑ¡Ôñ¿òµÄÑ¡Ïî
+ target.initDateList = function(){
+ initDateList();
+ target.dates(sv_sntpDates);
+ }
+
+ //³õʼ»¯ÈÕÆÚÁбí
+ initDateList();
+ target.dates = ko.observableArray(sv_sntpDates);
+ target.hours = ko.observableArray(sv_sntpHours);
+ target.minutes = ko.observableArray(sv_sntpMinutes);
+
+ //×Ô¶¯SNTP»ñȡʱ¼äÊý¾Ý°ó¶¨´¦Àí
+ var serverArray = _.map(sntpInfo.sntp_servers, function(item) {
+ return new Option(item.name, item.value)
+ });
+
+ target.serverList = ko.observableArray(serverArray);
+
+ // ÒÔÏÂÃû×Ö²»ÄÜÐ޸ģ¬ÐÞ¸ÄÎÞ·¨Ë¢ÐÂÍøÒ³
+
+ target.currentServer0 = ko.observable(sntpInfo.sntp_server0);
+ target.currentServer1 = ko.observable(sntpInfo.sntp_server1);
+ target.currentServer2 = ko.observable(sntpInfo.sntp_server2);
+ target.customServer0 = ko.observable(sntpInfo.sntp_other_server0);
+ target.customServer1 = ko.observable(sntpInfo.sntp_other_server1);
+ target.customServer2 = ko.observable(sntpInfo.sntp_other_server2);
+ target.isOther0 = ko.observable(false);
+ target.isOther1 = ko.observable(false);
+ target.isOther2 = ko.observable(false);
+
+ initOtherServer();
+
+ target.changeServerSelect = function(){
+ initOtherServer();
+ }
+
+ target.timeZones = ko.observableArray(timeZones);
+ target.currentTimeZone = ko.observable(sntpInfo.sntp_timezone + "_" + sntpInfo.sntp_timezone_index);
+ target.daylightSaves = ko.observableArray(daylightSave);
+ target.currentDaylightSave = ko.observable(sntpInfo.sntp_dst_enable);
+
+ //¸üе±Ç°ÏÔʾʱ¼ä
+ target.updateCurrentTime = function() {
+ var globalDay = globalTime.getDay();
+
+ switch(globalDay){
+ case 6:
+ target.day($.i18n.prop("saturday"));
+ break;
+ case 5:
+ target.day($.i18n.prop("friday"));
+ break;
+ case 4:
+ target.day($.i18n.prop("thursday"));
+ break;
+ case 3:
+ target.day($.i18n.prop("wednesday"));
+ break;
+ case 2:
+ target.day($.i18n.prop("tuesday"));
+ break;
+ case 1:
+ target.day($.i18n.prop("monday"));
+ break;
+ case 0:
+ target.day($.i18n.prop("sunday"));
+ break;
+ default:
+ break;
+ }
+
+ var localCurrentTime = globalTime.getFullYear() + "-" + getTwoDigit(globalTime.getMonth()+1) + "-" + getTwoDigit(globalTime.getDate()) + " " + getTwoDigit(globalTime.getHours()) + ":" + getTwoDigit(globalTime.getMinutes()) + ":" + getTwoDigit(globalTime.getSeconds());
+ target.localTime(localCurrentTime);
+ globalTime.setTime(globalTime.getTime()+1000);
+ };
+
+ // SNTPÉèÖÃ
+ target.apply = function(){
+ var tmpArray = [];
+ for(var i=0; i< sntpInfo.sntp_servers.length; i++){
+ tmpArray.push(sntpInfo.sntp_servers[i].value);
+ }
+ var staInfo = service.getStatusInfo();
+ if(!checkConnectedStatus(staInfo.connectStatus, staInfo.rj45ConnectStatus, staInfo.connectWifiStatus) && target.currentMode() == "auto"){
+ showAlert("sntp_syn_time_wan_connected");
+ return;
+ }
+
+ showLoading("");
+ var requestParams = {
+ goformId: "SNTP",
+ manualsettime : target.currentMode(),
+ sntp_server1_ip : target.currentServer0(),
+ sntp_server2_ip : target.currentServer1(),
+ sntp_server3_ip : target.currentServer2(),
+ sntp_other_server0 : target.customServer0(),
+ sntp_other_server1 : target.customServer1(),
+ sntp_other_server2 : target.customServer2(),
+ timezone : target.currentTimeZone().split("_")[0],
+ sntp_timezone_index : target.currentTimeZone().split("_")[1],
+ DaylightEnabled : target.currentDaylightSave(),
+ time_year : target.currentYear(),
+ time_month : target.currentMonth(),
+ time_day : target.currentDate(),
+ time_hour : target.currentHour(),
+ time_minute : target.currentMinute()
+ };
+
+ service.setSntpSetting(requestParams, function(data2){
+ if(data2) {
+ if(data2.result == "success" && target.currentMode() == "auto"){
+ successOverlay("sntp_req_success");
+ //hideLoading();
+ }else if(data2.result == "processing" && target.currentMode() == "auto"){
+ successOverlay("sntp_processing");
+ }else{
+ //´¥·¢serverУ׼ʱ¼ä
+ service.setSNTPDate({
+ goformId: "SNTP_Getdatastatic"
+ }, function(result){
+ var sntpInfo = service.getSntpParams();
+ globalTime = new Date(parseInt(sntpInfo.sntp_year, 10),parseInt(sntpInfo.sntp_month, 10)-1, parseInt(sntpInfo.sntp_day, 10), parseInt(sntpInfo.sntp_hour, 10), parseInt(sntpInfo.sntp_minute, 10), parseInt(sntpInfo.sntp_second, 10));
+ successOverlay();
+ });
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+
+ // ÊÖ¶¯/×Ô¶¯Çл»ÏìÓ¦º¯Êý
+ function changeSetTimeMode() {
+ if(target.currentMode() == "manual") {
+ target.isManualSetTime(true);
+ target.isAutoSntpTime(false);
+ } else {
+ target.isManualSetTime(false);
+ target.isAutoSntpTime(true);
+ }
+ return true;
+ }
+
+ // ³õʼ»¯Ê±¼ä
+ function initDateList(){
+ sv_sntpDates = [];
+ if($.inArray(parseInt(target.currentMonth(), 10), sf_smallMonth) != -1) {
+ sf_produceArray(1, 30, sv_sntpDates);
+ } else if($.inArray(parseInt(target.currentMonth(), 10), sf_bigMonth) != -1) {
+ sf_produceArray(1, 31, sv_sntpDates);
+ } else if(parseInt(target.currentYear(), 10)%4 == 0) {
+ sf_produceArray(1, 29, sv_sntpDates);
+ } else {
+ sf_produceArray(1, 28, sv_sntpDates);
+ }
+ }
+
+ // ³õʼ»¯ÆäËû·þÎñÆ÷
+ function initOtherServer(){
+ target.isOther0(target.currentServer0() == "Other");
+ target.isOther1(target.currentServer1() == "Other");
+ target.isOther2(target.currentServer2() == "Other");
+ !target.isOther0() && $("#sntp_server0").find(".error").hide();
+ !target.isOther1() && $("#sntp_server1").find(".error").hide();
+ !target.isOther2() && $("#sntp_server2").find(".error").hide();
+ }
+
+
+ }
+
+ // ³õʼ»¯ ViewModel£¬²¢½øÐÐÊÓͼ°ó¶¨
+ function init() {
+ var fwVm = new othersViewModel();
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ ko.applyBindings(fwVm, container);
+ fwVm.updateCurrentTime();
+
+ addInterval(function(){
+ fwVm.updateCurrentTime();
+ }, 1000);
+
+ $("#sntpForm").validate({
+ submitHandler: function(){
+ fwVm.apply();
+ },
+ rules: {
+ sntp_other_server0 : "sntp_invalid_server_name",
+ sntp_other_server1 : "sntp_invalid_server_name",
+ sntp_other_server2 : "sntp_invalid_server_name"
+ }
+ });
+ }
+
+ return {
+ init:init
+ }
+ });
+// ÃÜÂë¹ÜÀí Ä£¿é
+
+define("adm_management","jquery knockout set service underscore CryptoJS".split(" "),
+
+ function ($, ko, config, service, _, CryptoJS) {
+
+ function manageViewModel() {
+ var target = this;
+
+ target.currentValue = ko.observable();
+ target.newValue = ko.observable();
+ target.confirmValue = ko.observable();
+
+ function sf_changeValue() {
+ var sv_manageInfo = {};
+ if (config.PASSWORD_ENCODE) {
+ sv_manageInfo.oldValue = target.currentValue();
+ sv_manageInfo.newValue = target.newValue();
+ } else {
+ var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
+
+ if (!pwdRegex.test(target.newValue())) {
+ showConfirm("password_note_too_low", function () {
+
+ var kparam = service.getDeviceInfoLow();
+ var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
+ var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
+ var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+ var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+
+ sv_manageInfo.oldValue = cipherold;
+ sv_manageInfo.newValue = ciphernew;
+
+ showLoading();
+
+ service.changeManageInfo(sv_manageInfo, function (resultInfo) {
+ target.cancel();
+ if (resultInfo && resultInfo.result == true) {
+ successOverlay();
+ } else {
+ if (resultInfo && resultInfo.errorType == "badPassword") {
+ hideLoading();
+ showAlert("current_password_error",function(){
+ $("#txtCurrent").focus();
+ });
+ } else {
+ errorOverlay();
+ }
+ }
+ });
+ });
+ return;
+ }
+ var kparam = service.getDeviceInfoLow();
+ var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
+ var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
+ var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+ var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+
+ sv_manageInfo.oldValue = cipherold;
+ sv_manageInfo.newValue = ciphernew;
+ }
+
+ showLoading();
+
+ service.changeManageInfo(sv_manageInfo, function (resultInfo) {
+ target.cancel();
+ if (resultInfo && resultInfo.result == true) {
+ successOverlay();
+ } else {
+ if (resultInfo && resultInfo.errorType == "badPassword") {
+ hideLoading();
+ showAlert("current_password_error",function(){
+ $("#txtCurrent").focus();
+ });
+ } else {
+ errorOverlay();
+ }
+ }
+ });
+ }
+
+ // Çå³ýÊäÈëµÄÃÜÂë
+ function sf_cancel() {
+ target.currentValue("");
+ target.newValue("");
+ target.confirmValue("");
+ }
+
+ target.cancel = sf_cancel;
+
+ // ÐÞ¸ÄÃÜÂë
+ target.changeValue = sf_changeValue;
+ }
+
+ function init() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var fwVm = new manageViewModel();
+ ko.applyBindings(fwVm, container[0]);
+
+ $('#frmPassword').validate({
+ submitHandler:function () {
+ fwVm.changeValue();
+ },
+ rules:{
+ txtCurrent:"manage_info_check",
+ txtNew:"manage_info_check",
+ txtConfirm:{ equalTo:"#txtNew"}
+ }
+ });
+ }
+
+ return {
+ init:init
+ }
+ }
+);
+// PIN¹ÜÀíÄ£¿é
+
+define("adm_pin","jquery knockout set service".split(" "),
+
+ function ($, ko, config, service) {
+ var pageState = {common:0, requirePin:1, modifyPin:2, requirePuk:3, destroyed:4};
+ var pinStatus = {enable:"1", disable:"0"};
+
+
+ function pinViewModel() {
+ var target = this;
+ var sv_currentPinData = service.getPinData();
+
+ target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';
+ target.originPinStatus = ko.observable(sv_currentPinData.pin_status);
+
+ target.pinStatus = ko.observable(sv_currentPinData.pin_status);
+ target.pinNumber = ko.observable(sv_currentPinData.pinnumber);
+ target.pukNumber = ko.observable(sv_currentPinData.puknumber);
+
+ target.currentPin = ko.observable();
+ target.newPin = ko.observable();
+ target.confirmPin = ko.observable();
+
+ target.puk = ko.observable();
+
+ target.pageState = ko.observable();
+ // ÇëÇó²Ù×÷ºó³É¹¦±ê־λ
+ target.operateSuccessFlag = true;
+
+ target.callback = sf_callback;
+
+ function sf_callback(info) {
+ if (info && info.result == true) {
+ target.operateSuccessFlag = true;
+ successOverlay();
+ } else {
+ target.operateSuccessFlag = false;
+
+ // ×îºóÒ»´ÎǰҪµ¯¿òÌáʾ
+ if(target.pinNumber() == 2){
+ showAlert("last_enter_pin");
+ } else if(target.pukNumber() == 2){
+ showAlert("last_enter_puk");
+ }
+ else{
+ errorOverlay();
+ }
+ }
+ init(target);
+ }
+
+
+ // È·¶¨°´Å¥Ê¼þ´¦Àí£¬°üÀ¨ÐÞ¸ÄPIN£¬¸ù¾ÝPUKÉèÖÃPIN£¬ÉèÖÃPINµÄʹÄÜ״̬
+
+ function sf_changePin() {
+ if (target.isConnectedNetWork()) {
+ showAlert("cannot_operate_when_connected");
+ return;
+ }
+
+ if (target.pageState() == pageState.common) {
+ return;
+ }
+
+ var sv_pinPara = {
+ oldPin:target.currentPin(),
+ newPin:target.newPin()
+ };
+ showLoading();
+
+ if (target.pageState() == pageState.modifyPin) {
+ service.changePin(sv_pinPara, target.callback);
+ } else if (target.pageState() == pageState.requirePuk) {
+ sv_pinPara = {
+ PinNumber:target.newPin(),
+ PUKNumber:target.puk()
+ };
+ service.enterPUK(sv_pinPara, target.callback);
+ } else {
+ if (target.pinStatus() == pinStatus.enable) {
+ service.enablePin(sv_pinPara, target.callback);
+ } else {
+ service.disablePin(sv_pinPara, target.callback);
+ }
+ }
+ }
+
+
+ // È¡Ïûʼþ´¦Àí
+ function sf_cancel() {
+ target.pageState(pageState.common);
+ target.pinStatus(target.originPinStatus());
+ target.clear();
+ }
+
+ // Çå³ýÒ³ÃæÊäÈëºÍ¼ì²âÏûÏ¢
+ function sf_clear() {
+ target.confirmPin("");
+ target.currentPin("");
+ target.newPin("");
+ target.puk("");
+ clearValidateMsg();
+ }
+
+ // ¸ù¾ÝÊý¾Ý£¬ÉèÖõ±Ç°µÄÒ³Ãæ×´Ì¬
+ function sf_computePageState(i_pinData) {
+ if (i_pinData.pinnumber > 0) {
+ //²Ù×÷³É¹¦Ò³Ãæ»Øµ½³õʼ״̬£¬²Ù×÷ʧ°Ü²¢ÇÒpinnumber>0,Ò³Ãæ²»Ìø×ª
+ if (target.operateSuccessFlag) {
+ target.cancel();
+ } else {
+ target.clear();
+ }
+ } else {
+ target.clear();
+ if (i_pinData.puknumber > 0) {
+ target.pageState(pageState.requirePuk);
+ } else {
+ target.pageState(pageState.destroyed);
+ }
+ }
+ }
+
+ // ½øÈëPINÐÞ¸Ä״̬ʼþ´¦Àí
+ function sf_displayModifyPinPage() {
+ if (target.isConnectedNetWork()) {
+ showAlert("cannot_operate_when_connected");
+ return;
+ }
+ target.pinStatus(target.originPinStatus());
+ target.pageState(pageState.modifyPin);
+ target.clear();
+ }
+
+ // ´¦ÀíÒ³ÃæÔªËØµÄʹÄÜ״̬
+ function sf_fixPageEnable() {
+ if (target.isConnectedNetWork()) {
+ $('#frmPin :input').each(function () {
+ disableBtn($(this));
+ });
+ clearValidateMsg();
+ } else {
+ $('#frmPin :input').each(function () {
+ if (this.id == "txtPin" || this.id == "btnPinApply") {
+ if (target.pageState() == pageState.common) {
+ disableBtn($(this));
+ return;
+ }
+ }
+ if (this.id == "btnModifyPin") {
+ if (target.originPinStatus() != pinStatus.enable) {
+ disableBtn($(this));
+ return;
+ }
+ }
+ if (this.id == "pinEnable" || this.id == "pinDisable") {
+ if (target.pageState() == pageState.modifyPin) {
+ disableBtn($(this));
+ return;
+ }
+ }
+ enableBtn($(this));
+ });
+
+ }
+ }
+
+ // ÊÇ·ñÒÑÁªÍø
+ function sf_isConnectedNetWork() {
+ var info = service.getConnectionInfo();
+ return info.connectStatus == "ppp_connected";
+ }
+
+ // PINʹÄܸıäʱʼþ´¦Àí
+ function sf_pinStatusChangeEvent() {
+ if (target.pinStatus() == target.originPinStatus()) {
+ target.pageState(pageState.common);
+ } else {
+ target.pageState(pageState.requirePin);
+ }
+ target.clear();
+ }
+
+ target.changePin = sf_changePin;
+ target.cancel = sf_cancel;
+ target.clear = sf_clear;
+ target.computePageState = sf_computePageState;
+
+ target.computePageState(sv_currentPinData);
+
+ target.displayModifyPinPage = sf_displayModifyPinPage;
+ target.fixPageEnable = sf_fixPageEnable;
+ target.isConnectedNetWork = sf_isConnectedNetWork;
+
+ target.pinStatusChangeEvent = ko.dependentObservable(sf_pinStatusChangeEvent, this);
+ }
+
+ function init(oldViewModel) {
+
+ var fwVm = oldViewModel;
+
+ if (fwVm) {
+ var sv_currentPinData = service.getPinData();
+ fwVm.originPinStatus(sv_currentPinData.pin_status);
+ fwVm.pinNumber(sv_currentPinData.pinnumber);
+ fwVm.pukNumber(sv_currentPinData.puknumber);
+ fwVm.computePageState(sv_currentPinData);
+ } else {
+ fwVm = new pinViewModel();
+ addInterval(function () {
+ fwVm.fixPageEnable();
+ }, 1000);
+ }
+
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ ko.applyBindings(fwVm, container);
+ fwVm.fixPageEnable();
+
+ $('#frmPin').validate({
+ submitHandler:function () {
+ fwVm.changePin();
+ },
+ rules:{
+ txtPuk:"puk_check",
+ txtPin:"pin_check",
+ txtNewPin:"pin_check",
+ txtConfirmPin:{equalToPin:"#txtNewPin"}
+ }
+ });
+ }
+
+ return {
+ init:init
+ }
+ }
+);
+
+// ¿ìËÙÉèÖÃ
+define("adm_quick_set","jquery knockout set service underscore CryptoJS".split(" "),
+
+ function ($, ko, config, service, _, CryptoJS) {
+
+ var sv_wifiState = {ok:0, wps_on:1, wifi_off:2};
+ var sv_apnMode = {auto:"auto", manual:"manual"};
+ var sv_minStep = 1;
+ var sv_maxStep = 5;
+
+ // »ñÈ¡¼øÈ¨·½Ê½
+ function sf_fetchAuthenticationModes() {
+ return _.map(config.APN_AUTH_MODES, function (item) {
+ return new Option(item.name, item.value);
+ });
+ }
+
+ // WIFI°²È«Ä£Ê½Ñ¡Ïî
+ var sv_securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
+ return new Option(item.name, item.value);
+ });
+
+
+ function quickSettingViewModel() {
+ var target = this;
+
+ var sv_quickSettingInfo = service.getQuickSettingInfo();
+
+ target.currentStep = ko.observable(sv_minStep);
+ target.ipType = ko.observable(sv_quickSettingInfo.pdp_type == "IP" ? "IP" : sv_quickSettingInfo.ipv6_pdp_type);
+ target.supportIPv6 = config.IPV6_SUPPORT;
+ target.supportIpv4AndIpv6 = config.IPV4_AND_V6_SUPPORT;
+
+ target.wpsFlag = ko.observable(sv_quickSettingInfo.WscModeOption);
+
+ function sf_apnDisabled() {
+ return (sv_quickSettingInfo.apn_index < config.defaultApnSize || sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting");
+ }
+
+ function sf_apnModeDisabled() {
+ return (sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting" || (!target.profileName() && target.apnMode() == sv_apnMode.auto));//Ñ¡ÏîΪ¿Õ»òÕýÔÚÁ¬½Ó»òÒÑÁ¬½Ó
+ }
+
+ function sf_currAPN() {
+ var sv_APNText = sv_quickSettingInfo["APN_configtmp" + sv_quickSettingInfo.apn_index];
+ var strIPv6APN = sv_quickSettingInfo["ipv6_APN_configtmp" + sv_quickSettingInfo.apn_index];
+
+ var sv_apn = [];
+ var sv_ipv6APNItems = [];
+
+ if (sv_APNText) {
+ sv_apn = sv_APNText.split("($)");
+ }
+
+ if (strIPv6APN) {
+ sv_ipv6APNItems = strIPv6APN.split("($)");
+ }
+
+ return {
+ m_profile_name:sv_apn[0],
+ wan_apn:sv_apn[1],
+ ppp_auth_mode: sv_apn[4] == "" || typeof(sv_apn[4]) == "undefined" ? "" : sv_apn[4].toLowerCase(),
+ ppp_username:sv_apn[5],
+ ppp_passtmp:sv_apn[6],
+ pdp_type: sv_apn[7],
+ ipv6_wan_apn:sv_ipv6APNItems[1],
+ ipv6_ppp_auth_mode:typeof(sv_ipv6APNItems[4]) == "undefined" || sv_ipv6APNItems[4] == ""? "" : sv_ipv6APNItems[4].toLowerCase(),
+ ipv6_ppp_username:sv_ipv6APNItems[5],
+ ipv6_ppp_passtmp:sv_ipv6APNItems[6],
+ ipv6_pdp_type:sv_ipv6APNItems[7]
+ }
+ }
+
+ // µ±Ç°APNÅäÖÃ
+ target.currAPN = ko.computed(sf_currAPN);
+
+ target.apn = ko.observable(target.currAPN().wan_apn);
+ target.ipv6_apn = ko.observable(target.currAPN().ipv6_wan_apn);
+ target.ipv6_selectedAuthMode = ko.observable(target.currAPN().ipv6_ppp_auth_mode);
+ target.ipv6_username = ko.observable(target.currAPN().ipv6_ppp_username);
+ target.ipv6_password = ko.observable(target.currAPN().ipv6_ppp_passtmp);
+ target.profileName = ko.observable(target.currAPN().m_profile_name);
+ target.selectedAuthMode = ko.observable(target.currAPN().ppp_auth_mode);
+ target.username = ko.observable(target.currAPN().ppp_username);
+ target.password = ko.observable(target.currAPN().ppp_passtmp);
+
+ target.transAPN = ko.observable("apn_ipv4_apn");
+ target.transAPNIPv6 = ko.observable("apn_ipv6_apn");
+ target.transAuthMode = ko.observable("apn_authentication_ipv4");
+ target.transAuthModeIPv6 = ko.observable("apn_authentication_ipv6");
+ target.transUserName = ko.observable("apn_user_name_ipv4");
+ target.transPassword = ko.observable("apn_password_ipv4");
+ target.transUserNameIPv6 = ko.observable("apn_user_name_ipv6");
+ target.transPasswordIPv6 = ko.observable("apn_password_ipv6");
+
+
+
+ target.apnDisabled = ko.computed(sf_apnDisabled);
+ target.apnMode = ko.observable(sv_quickSettingInfo.apn_mode);
+ target.apnModeDisabled = ko.computed(sf_apnModeDisabled);
+ target.authModes = ko.observableArray(sf_fetchAuthenticationModes());
+
+ if (target.ipType() == "IPv6") {
+ target.showIPv4 = false;
+ target.showIPv6 = true;
+ target.transAPNIPv6("apn");
+ target.transAuthModeIPv6("apn_authentication");
+ target.transUserNameIPv6("apn_user_name");
+ target.transPasswordIPv6("apn_password");
+ } else if (config.IPV4_AND_V6_SUPPORT && target.ipType() == "IPv4v6") {
+ target.showIPv4 = true;
+ target.showIPv6 = true;
+ //ʹÓÃĬÈÏ
+ } else if (target.ipType() == "IP" || target.ipType() == "IPv4") {
+ target.showIPv4 = true;
+ target.showIPv6 = false;
+ target.transAPN("apn");
+ target.transAuthMode("apn_authentication");
+ target.transUserName("apn_user_name");
+ target.transPassword("apn_password");
+ } else { //pdp_type == "IPv4v6" && config.IPV4V6_SUPPORT
+ target.showIPv4 = true;
+ target.showIPv6 = false;
+ target.transAPN("apn");
+ target.transAuthMode("apn_authentication");
+ target.transUserName("apn_user_name");
+ target.transPassword("apn_password");
+ }
+
+ target.wifiDisabled = (sv_quickSettingInfo.wifi_cur_state != "1");
+ target.ssid = ko.observable(sv_quickSettingInfo.SSID1);
+ target.broadcast = ko.observable(sv_quickSettingInfo.HideSSID);
+ target.hasWifiWep = config.WIFI_WEP_SUPPORT;
+ target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
+ target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
+
+ target.securityModes = ko.observableArray(sv_securityModes);
+ target.selectedSecurityMode = ko.observable(sv_quickSettingInfo.AuthMode);
+ target.WPAKey = ko.observable(sv_quickSettingInfo.WPAPSK1);
+
+ target.apnMode_display = ko.observable("");
+
+ target.apnMode_trans = ko.computed(sf_apnMode_trans);
+ target.selectedAuthMode_display = ko.computed(sf_selectedAuthMode_display);
+ target.ipv6_selectedAuthMode_display = ko.computed(sf_ipv6_selectedAuthMode_display);
+
+ target.showWifiPassword = ko.observable(false);
+ target.showWifiPasswordHandler = sf_showWifiPasswordHandler;
+
+ //ÅжÏÊÇ·ñÔÚ802 n onlyÏÂ
+ var sv_adInfo = service.getWifiAdvance();
+ target.adBand = ko.observable(sv_adInfo.wifiBand);
+ target.adMode = ko.observable(sv_adInfo.mode);
+
+ target.encryptType = ko.observable(sv_quickSettingInfo.EncrypType);
+ target.keyID = ko.observable(sv_quickSettingInfo.DefaultKeyID);
+ target.wepPassword = ko.observable("");
+
+ target.getWepPassword = sf_getWepPassword;
+ target.wepPassword(target.getWepPassword());
+ target.profileChangeHandler = sf_profileChangeHandler;
+
+ target.broadcast_display = ko.observable("");
+ target.broadcast_trans = ko.computed(sf_broadcast_trans);
+
+ target.selectedSecurityMode_display = ko.observable();
+ target.selectedSecurityMode_trans = ko.computed(sf_selectedSecurityMode_trans);
+
+
+ target.callback = sf_callback;
+ target.next = sf_button_next;
+ target.previous = sf_button_previous;
+ target.save = sf_button_save;
+
+ function sf_apnMode_trans() {
+ if (sv_apnMode.auto == target.apnMode()) {
+ target.apnMode_display($.i18n.prop("apn_auto_apn"));
+ return "apn_auto_apn";
+ } else {
+ target.apnMode_display($.i18n.prop("apn_manual_apn"));
+ return "apn_manual_apn";
+ }
+ }
+
+ function sf_broadcast_trans() {
+ if ("0" == target.broadcast()) {
+ target.broadcast_display($.i18n.prop("enable"));
+ return "enable";
+ } else {
+ target.broadcast_display($.i18n.prop("disable"));
+ return "disable";
+ }
+ }
+
+ function sf_button_next() {
+ var currentStep = target.currentStep();
+ var toStep = target.currentStep() + 1;
+ sf_changeStep(toStep);
+
+ if (currentStep == 1 && target.apnMode() == sv_apnMode.auto) {
+ toStep = target.currentStep() + 1;
+ sf_changeStep(toStep);
+ }
+ }
+
+ function sf_button_previous() {
+
+ var currentStep = target.currentStep();
+ var toStep = target.currentStep() - 1;
+
+ sf_changeStep(toStep);
+
+ if (currentStep == 3 && target.apnMode() == sv_apnMode.auto) {
+ toStep = target.currentStep() - 1;
+ sf_changeStep(toStep);
+ }
+ }
+ function sf_button_save() {
+ var submit = function () {
+ sf_quickSetting4IPv6();
+ };
+ var result = sf_isDisabled_Wifi();
+ if(result == sv_wifiState.wifi_off){
+ showConfirm("quick_setting_wifi_disable_confirm", submit);
+ } else if (result == sv_wifiState.wps_on) {
+ showAlert("wps_on_info");
+ } else{
+ showConfirm("quick_setting_param_changed_confirm", submit);//submit();
+ }
+ }
+ // ¿ìËÙÉèÖÃÌá½»ºóµÄ»Øµ÷´¦Àí
+ function sf_callback(data) {
+ if (data.result == "success") {
+ successOverlay();
+ location.hash = "#network_choose";
+ }
+ else {
+ errorOverlay();
+ }
+ }
+
+ // ±ä»»²½Öèʱ´¦Àí
+ function sf_changeStep(i_step) {
+ if (i_step > sv_maxStep) {
+ i_step = sv_maxStep;
+ } else if (i_step < sv_minStep) {
+ i_step = sv_minStep;
+ }
+
+ target.currentStep(i_step);
+ return true;
+ }
+
+ function sf_ipv6_selectedAuthMode_display() {
+ var mode = target.ipv6_selectedAuthMode();
+ return sf_getAuthModeNameByValue(mode);
+ }
+ // ¸ù¾Ý¼øÈ¨Ä£Ê½µÄÖµ»ñÆäÃû³Æ
+ function sf_getAuthModeNameByValue(authMode) {
+ for (var i = 0; i < config.APN_AUTH_MODES.length; i++) {
+ if (authMode == config.APN_AUTH_MODES[i].value) {
+ return config.APN_AUTH_MODES[i].name;
+ }
+ }
+ }
+
+ function sf_getWepPassword(){
+ return target.keyID() == '3' ? sv_quickSettingInfo.Key4Str1 : (target.keyID() == '2' ? sv_quickSettingInfo.Key3Str1 : target.keyID() == '1' ? sv_quickSettingInfo.Key2Str1 : sv_quickSettingInfo.Key1Str1);
+ }
+
+ function sf_isDisabled_Wifi() {
+ var s_wpsInfo = service.getWpsInfo();
+ if(s_wpsInfo.radioFlag == "0"){
+ return sv_wifiState.wifi_off;
+ }else if (s_wpsInfo.wpsFlag == '1') {
+ return sv_wifiState.wps_on;
+ }
+ return sv_wifiState.ok;
+ }
+ function sf_profileChangeHandler(i_data, i_event) {
+ $("#pwdWepKey").parent().find("label[class='error']").hide();
+ target.wepPassword(target.getWepPassword());
+ return true;
+ }
+
+ // ¿ìËÙÉèÖÃÌá½»(Ö§³ÖIPv6£©
+ function sf_quickSetting4IPv6() {
+ showLoading();
+ var useIPv4ForV6 = config.IPV4V6_SUPPORT && target.currAPN().pdp_type == "IPv4v6";
+
+ var ciphertext = "";
+ if (config.PASSWORD_ENCODE) {
+ ciphertext = target.WPAKey();
+ } else {
+ var kparam = service.getDeviceInfoLow();
+ var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
+ var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
+ ciphertext = CryptoJS.AES.encrypt(target.WPAKey(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+ }
+
+ var s_quickSettingParameters = {
+ apn_index: sv_quickSettingInfo.apn_index,
+ apnMode: target.apnMode(),
+ Encryption_Mode_hid: target.selectedSecurityMode(),
+ ipv6_ppp_auth_mode: useIPv4ForV6 ? target.selectedAuthMode() : target.ipv6_selectedAuthMode(),
+ ipv6_ppp_username: useIPv4ForV6 ? target.username() : target.ipv6_username(),
+ ipv6_ppp_passtmp: useIPv4ForV6 ? target.password() : target.ipv6_password(),
+ ipv6_wan_apn: useIPv4ForV6 ? target.apn() : target.ipv6_apn(),
+ pdp_type: target.ipType(),
+ ppp_auth_mode: target.selectedAuthMode(),
+ ppp_username: target.username(),
+ ppp_passtmp: target.password(),
+ profile_name: target.profileName(),
+ //Ŀǰ¼ÓÃÜģʽֻÓÐ2ÖÖ£¬ÏÂÃæ3¸ö²ÎÊýΪ¹Ì¶¨Öµ
+ //Èç¹ûÐèÒª¶¨ÖÆÎª5ÖÖ£¬²ÎÊýÖµÐèÒªÉèÖÃ
+ security_shared_mode: "NONE",
+ SSID_Broadcast: target.broadcast(),
+ SSID_name: target.ssid(),
+ wan_apn: target.apn(),
+ wep_default_key: 0,
+ WPA_ENCRYPTION_hid: target.selectedSecurityMode() == "OPEN" ? "NONE" : target.selectedSecurityMode() == "WPA2PSK" ? 1 : 2,
+ WPA_PreShared_Key: ciphertext
+ }
+
+ s_quickSettingParameters.wep_default_key = target.keyID();
+
+ if(target.encryptType() == "SHARED" || target.selectedSecurityMode() == "WEP") {
+
+ s_quickSettingParameters.security_shared_mode = "WEP";
+
+ s_quickSettingParameters.wep_key_1 = sv_quickSettingInfo.Key1Str1;
+ s_quickSettingParameters.wep_key_2 = sv_quickSettingInfo.Key2Str1;
+ s_quickSettingParameters.wep_key_3 = sv_quickSettingInfo.Key3Str1;
+ s_quickSettingParameters.wep_key_4 = sv_quickSettingInfo.Key4Str1;
+
+ var WEPSelectTmp = '0';
+
+ if(target.wepPassword().length =='5' ||target.wepPassword().length =='13'){
+ WEPSelectTmp = '1';
+ }else{
+ WEPSelectTmp = '0';
+ }
+
+ if(target.keyID() =='3'){
+ s_quickSettingParameters.wep_key_4 = target.wepPassword();
+ s_quickSettingParameters.WEP4Select = WEPSelectTmp;
+ }else if(target.keyID() =='2'){
+ s_quickSettingParameters.wep_key_3 = target.wepPassword();
+ s_quickSettingParameters.WEP3Select = WEPSelectTmp;
+ }else if(target.keyID() =='1'){
+ s_quickSettingParameters.wep_key_2 = target.wepPassword();
+ s_quickSettingParameters.WEP2Select = WEPSelectTmp;
+ }else{
+ s_quickSettingParameters.wep_key_1 = target.wepPassword();
+ s_quickSettingParameters.WEP1Select = WEPSelectTmp;
+ }
+ }else if(target.encryptType() == "WPAPSKWPA2PSK") {
+ s_quickSettingParameters.security_shared_mode = "NONE";
+ }else {
+ s_quickSettingParameters.security_shared_mode = "NONE";
+ }
+
+ service.setQuickSetting4IPv6(s_quickSettingParameters, target.callback);
+ }
+
+ function sf_selectedAuthMode_display() {
+ var mode = target.selectedAuthMode();
+ return sf_getAuthModeNameByValue(mode);
+ }
+
+ function sf_selectedSecurityMode_trans() {
+ var mode = target.selectedSecurityMode();
+ var modesOption = config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES;
+ for (var i = 0; i < modesOption.length; i++) {
+ if (mode == modesOption[i].value) {
+ target.selectedSecurityMode_display($.i18n.prop("security_mode_" + modesOption[i].value));
+ return "security_mode_" + modesOption[i].value;
+ }
+ }
+ }
+
+ function sf_showWifiPasswordHandler(){
+ $("#pwdWepKey").parent().find(".error").hide();
+ $("#codeWPAKey").parent().find(".error").hide();
+ var checkbox = $("#showWifiPassword:checked");
+ if(checkbox && checkbox.length == 0){
+ target.showWifiPassword(true);
+ }else{
+ target.showWifiPassword(false);
+ }
+ }
+
+ }
+
+ function init() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var fwVm = new quickSettingViewModel();
+ ko.applyBindings(fwVm, container[0]);
+
+ $('#quickSettingForm').validate({
+ submitHandler:function () {
+ if (fwVm.currentStep() < 5) {
+ fwVm.next();
+ } else {
+ fwVm.save();
+ }
+ },
+ rules:{
+ txtAPN:"apn_check",
+ txtIPv6APN:"apn_check",
+ txtSSID:'ssid',
+ pwdWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
+ txtWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
+ txtWPAKey:'wifi_password_check',
+ codeWPAKey:'wifi_password_check',
+ txtUserName:'ppp_username_check',
+ txtIPv6UserName:'ppp_username_check',
+ txtSecretCode:"ppp_secretcode_check",
+ txtIPv6SecretCode:"ppp_secretcode_check"
+ },
+ errorPlacement:function (error, element) {
+ var id = element.attr("id");
+ if (id == "pwdWepKey" || id == "txtWepKey"){
+ error.insertAfter("#lblShowWepPassword");
+ } else if (id == "txtWPAKey" || id == "codeWPAKey") {
+ error.insertAfter("#lblShowWifiPassword");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+ }
+
+ return {
+ init:init
+ };
+ }
+);
+
+define("main","set service knockout underscore jquery statusBar echarts".split(" "), function (set, fnc, libko, libus, libjq, barStat, echarts) {
+
+ var chartOptions = {
+ color: ['red', 'red', 'red', 'red', 'red'],
+ series: [{
+ name: 'Á÷Á¿¿ØÖÆ',
+ type: 'pie',
+ radius: ['0', '72'],
+ itemStyle: {
+ normal: {
+ label: {
+ show: false
+ },
+ labelLine: {
+ show: false
+ }
+ }
+ },
+ data: [],
+ selectedOffset: 3
+ }
+ ],
+ animation: false,
+ title: {
+ text: '',
+ x: 'center',
+ y: 'center',
+ itemGap: 0,
+ textStyle: {
+ color: '#FFF',
+ fontFamily: '΢ÈíÑźÚ',
+ fontSize: 20,
+ fontWeight: 'bolder'
+ },
+ subtextStyle: {
+ color: '#FFF',
+ fontFamily: '΢ÈíÑźÚ',
+ fontSize: 16,
+ fontWeight: 'bolder'
+ }
+ },
+ tooltip: {
+ formatter: "{b}"
+ },
+ };
+ var languageOld = window.language;
+ var num_refresh = 0;
+ var traffic_graphic_chart = null;
+ var connStat = {
+ CONNECTED: 1,
+ DISCONNECTED: 2,
+ CONNECTING: 3,
+ DISCONNECTING: 4
+ };
+ function init() {
+ num_refresh = 0;
+ homeUtil.oldUsedData = null;
+ homeUtil.oldAlarmData = null;
+ traffic_graphic_chart = echarts.init(libjq("#traffic_graphic")[0]);
+ var container = libjq('#container')[0];
+ libko.cleanNode(container);
+ var tmp = new VmHome();
+ libko.applyBindings(tmp, container);
+ var data = fnc.getLoginData();
+ var psw_flg = data.psw_changed;
+ if (psw_flg != "1") {
+ showConfirm("password_note_first_change", function () {
+ window.location.hash = '#pwd_mode';
+ });
+ return;
+ }
+ }
+
+ var homeUtil = {
+ initStatus: null,
+ initShownStatus: function (data) {
+ this.initStatus = {};
+ var ipv6Mode = data.ipv6PdpType.toLowerCase().indexOf("v6") > 0;
+ if (set.RJ45_SUPPORT) {
+ var mode = checkCableMode(data.blc_wan_mode);
+ if (mode) {
+ this.initStatus.showIpv6WanIpAddr = false;
+ this.initStatus.showIpv4WanIpAddr = true;
+ } else if (set.IPV6_SUPPORT) {
+ if (data.pdpType == "IP") {
+ this.initStatus.showIpv6WanIpAddr = false;
+ this.initStatus.showIpv4WanIpAddr = true;
+ } else if (ipv6Mode) {
+ if (data.ipv6PdpType == "IPv6") {
+ this.initStatus.showIpv6WanIpAddr = true;
+ this.initStatus.showIpv4WanIpAddr = false;
+ } else {
+ this.initStatus.showIpv6WanIpAddr = true;
+ this.initStatus.showIpv4WanIpAddr = true;
+ }
+ }
+ } else {
+ this.initStatus.showIpv6WanIpAddr = false;
+ this.initStatus.showIpv4WanIpAddr = true;
+ }
+ } else {
+ if (set.IPV6_SUPPORT) {
+ if (data.pdpType == "IP") {
+ this.initStatus.showIpv6WanIpAddr = false;
+ this.initStatus.showIpv4WanIpAddr = true;
+ } else if (ipv6Mode) {
+ if (data.ipv6PdpType == "IPv6") {
+ this.initStatus.showIpv6WanIpAddr = true;
+ this.initStatus.showIpv4WanIpAddr = false;
+ } else {
+ this.initStatus.showIpv6WanIpAddr = true;
+ this.initStatus.showIpv4WanIpAddr = true;
+ }
+ }
+ } else {
+ this.initStatus.showIpv6WanIpAddr = false;
+ this.initStatus.showIpv4WanIpAddr = true;
+ }
+ }
+ },
+ wanIpGet: function (data) {
+ var addrInfo = {
+ wanIpAddress: '',
+ ipv6WanIpAddress: ''
+ };
+ addrInfo.wanIpAddress = verifyDeviceInfo(data.wanIpAddress);
+ addrInfo.ipv6WanIpAddress = verifyDeviceInfo(data.ipv6WanIpAddress);
+ return addrInfo;
+ },
+ cachedAPStationBasic: null,
+ cachedConnectionMode: null,
+ getCanConnectNetWork: function (param) {
+ var status = fnc.getStatusInfo();
+ if (status.simStatus != "modem_init_complete") {
+ return false;
+ }
+ var typeNetworkTmp = status.networkType.toLowerCase();
+ if (typeNetworkTmp == 'searching') {
+ return false;
+ }
+ if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
+ typeNetworkTmp = 'limited_service';
+ }
+ if (typeNetworkTmp == 'no service') {
+ typeNetworkTmp = 'no_service';
+ }
+ if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
+ if (param.cStatus() != connStat.CONNECTED) {
+ return false;
+ }
+ }
+ if (set.AP_STATION_SUPPORT) {
+ if (status.connectWifiStatus == "connect") {
+ if (status.ap_station_mode == "wifi_pref") {
+ return false;
+ }
+ }
+ }
+ return true;
+ },
+ doConnect: function () {
+ showLoading('connecting');
+ fnc.connect({}, function (data) {
+ if (data.result) {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ },
+ refreshHomeData: function (param) {
+ var info = fnc.getConnectionInfo();
+ param.connectStatus(info.connectStatus);
+ param.canConnect(this.getCanConnectNetWork(param));
+ param.networkType(homeUtil.getNetworkType(info.networkType));
+ if (info.connectStatus == "ppp_connected") {
+ param.current_Flux(transUnit(parseInt(info.data_counter.currentReceived, 10) + parseInt(info.data_counter.currentSent, 10), false));
+ param.connected_Time(transSecond2Time(info.data_counter.currentConnectedTime));
+ param.up_Speed(transUnit(info.data_counter.uploadRate, true));
+ param.down_Speed(transUnit(info.data_counter.downloadRate, true));
+ } else {
+ param.current_Flux(transUnit(0, false));
+ param.connected_Time(transSecond2Time(0));
+ param.up_Speed(transUnit(0, true));
+ param.down_Speed(transUnit(0, true));
+ }
+ param.trafficAlertEnable(info.limitVolumeEnable);
+ if (info.limitVolumeEnable) {
+ if (info.limitVolumeType == '1') {
+ param.trafficUsed(transUnit(parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10), false));
+ param.trafficLimited(transUnit(info.limitDataMonth, false));
+ } else {
+ param.trafficUsed(transSecond2Time(info.data_counter.monthlyConnectedTime));
+ param.trafficLimited(transSecond2Time(info.limitTimeMonth));
+ }
+ }
+ if (languageOld != window.language) {
+ languageOld = window.language;
+ num_refresh = 1;
+ }
+ if (param.showTraffic()) {
+ homeUtil.updateEcharts(info);
+ } else {
+ homeUtil.allFreeEcharts();
+ }
+ homeUtil.refreshStationInfo(param);
+ },
+ allFreeEcharts: function () {
+ var usedData = homeUtil.data.free;
+ usedData.value = 1;
+ usedData.selected = false;
+ usedData.name = libjq.i18n.prop("echarts_no");
+ chartOptions.series[0].data = [usedData];
+ chartOptions.title.text = '';
+ homeUtil.setEcharts(chartOptions, libjq.i18n.prop("echarts_no"));
+ },
+ getNetworkType: function (networkType) {
+ var typeNetworkTmp = networkType.toLowerCase();
+ if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
+ typeNetworkTmp = 'limited_service';
+ }
+ if (typeNetworkTmp == 'no service') {
+ typeNetworkTmp = 'no_service';
+ }
+ if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
+ return libjq.i18n.prop("network_type_" + typeNetworkTmp);
+ } else {
+ return networkType;
+ }
+ },
+ data: {
+ full: {
+ value: 30,
+ name: 'Á÷Á¿³¬³ö',
+ itemStyle: {
+ normal: {
+ color: '#DF4313'
+ }
+ }
+ },
+ used: {
+ value: 30,
+ name: 'ÒÑʹÓÃ',
+ itemStyle: {
+ normal: {
+ color: '#8CC916'
+ }
+ }
+ },
+ left1: {
+ value: 50,
+ name: 'ÌáÐÑÖµÄÚδʹÓÃ',
+ itemStyle: {
+ normal: {
+ color: '#D8D8D8'
+ }
+ }
+ },
+ free: {
+ value: 50,
+ name: 'δʹÓÃ',
+ itemStyle: {
+ normal: {
+ color: '#D8D8D8'
+ }
+ }
+ },
+ alert: {
+ value: 1,
+ name: 'ÌáÐÑÖµ',
+ itemStyle: {
+ normal: {
+ color: '#FF5500'
+ }
+ }
+ },
+ alarm: {
+ value: 19.7,
+ name: '¾¯½äÇø',
+ itemStyle: {
+ normal: {
+ color: '#8CC916'
+ }
+ }
+ },
+ start: {
+ value: 50,
+ name: 'ÌáÐÑÖµÄÚδʹÓÃ',
+ itemStyle: {
+ normal: {
+ color: '#D8D8D8'
+ }
+ }
+ },
+ },
+ getDataInfo: function (value) {
+ return {
+ data: /\d+(.\d+)?/.exec(value)[0],
+ unit: /[A-Z]{1,2}/.exec(value)[0]
+ }
+ },
+ oldAlarmData: null,
+ oldUsedData: null,
+ updateEcharts: function (info) {
+ var startName = libjq.i18n.prop("echarts_no");
+ num_refresh++;
+ if (num_refresh % 10 != 2) {
+ return false;
+ }
+ var total = 0,
+ used = 0,
+ reach = 0,
+ left = 0,
+ alarm = 0,
+ left1 = 0;
+ if (info.limitVolumeEnable) {
+ startName = libjq.i18n.prop("echarts_used");
+ chartOptions.series[0].data = [];
+ if (info.limitVolumeType == '1') {
+ var limitedDataFormatted = transUnit(info.limitDataMonth, false);
+ chartOptions.series[0].data = [];
+ if (info.limitDataMonth == 0) {
+ var usedData = homeUtil.data.used;
+ usedData.value = 1;
+ usedData.selected = false;
+ usedData.name = libjq.i18n.prop("echarts_used");
+ chartOptions.series[0].data.push(usedData);
+ } else {
+ var dataInfo = homeUtil.getDataInfo(limitedDataFormatted);
+ total = dataInfo.data * homeUtil.getUnitValue(dataInfo.unit) * 1048576;
+ used = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
+ reach = total * info.limitVolumePercent / 100;
+ if (used >= total) {
+ var fullData = homeUtil.data.full;
+ fullData.value = 100;
+ fullData.name = libjq.i18n.prop("echarts_full");
+ chartOptions.series[0].data.push(fullData);
+ startName = libjq.i18n.prop("echarts_full");
+ } else {
+ if (reach - used > 0) {
+ left1 = reach - used;
+ left = total - reach;
+ } else {
+ alarm = used - reach;
+ left = total - used;
+ }
+ var usedData = homeUtil.data.used;
+ if (reach - used > 0) {
+ usedData.value = used;
+ } else {
+ usedData.value = reach;
+ }
+ usedData.name = libjq.i18n.prop("echarts_used");
+ chartOptions.series[0].data.push(usedData);
+ if (left1 > 0) {
+ var left1Data = homeUtil.data.left1;
+ left1Data.value = left1;
+ left1Data.name = libjq.i18n.prop("echarts_left1");
+ chartOptions.series[0].data.push(left1Data);
+ }
+ var alertData = homeUtil.data.alert;
+ alertData.value = total / 200;
+ alertData.name = libjq.i18n.prop("echarts_alert");
+ chartOptions.series[0].data.push(alertData);
+ if (alarm > 0) {
+ var alarmData = homeUtil.data.alarm;
+ alarmData.value = alarm;
+ alarmData.name = libjq.i18n.prop("echarts_alarm");
+ chartOptions.series[0].data.push(alarmData);
+ }
+ var freeData = homeUtil.data.free;
+ freeData.value = left;
+ freeData.name = libjq.i18n.prop("echarts_free");
+ chartOptions.series[0].data.push(freeData);
+ }
+ }
+ } else {
+ chartOptions.series[0].data = [];
+ if (info.limitTimeMonth == 0) {
+ var usedData = homeUtil.data.used;
+ usedData.value = 1;
+ usedData.selected = false;
+ usedData.name = libjq.i18n.prop("echarts_used");
+ chartOptions.series[0].data.push(usedData);
+ } else {
+ total = info.limitTimeMonth;
+ used = info.data_counter.monthlyConnectedTime;
+ reach = total * info.limitVolumePercent / 100;
+ if (used >= total) {
+ var fullTime = homeUtil.data.full;
+ fullTime.value = 100;
+ fullTime.name = libjq.i18n.prop("echarts_full");
+ chartOptions.series[0].data.push(fullTime);
+ startName = libjq.i18n.prop("echarts_full");
+ } else {
+ if (reach - used > 0) {
+ left1 = reach - used;
+ left = total - reach;
+ } else {
+ alarm = used - reach;
+ left = total - used;
+ }
+ var usedTime = homeUtil.data.used;
+ if (reach - used > 0) {
+ usedTime.value = used;
+ } else {
+ usedTime.value = reach;
+ }
+ usedTime.name = libjq.i18n.prop("echarts_used");
+ chartOptions.series[0].data.push(usedTime);
+ if (left1 > 0) {
+ var left1Time = homeUtil.data.left1;
+ left1Time.value = left1;
+ left1Time.name = libjq.i18n.prop("echarts_left1");
+ chartOptions.series[0].data.push(left1Time);
+ }
+ var alertTime = homeUtil.data.alert;
+ alertTime.value = total / 200;
+ alertTime.name = libjq.i18n.prop("echarts_alert");
+ chartOptions.series[0].data.push(alertTime);
+ if (alarm > 0) {
+ var alarmTime = homeUtil.data.alarm;
+ alarmTime.value = alarm;
+ alarmTime.name = libjq.i18n.prop("echarts_alarm");
+ chartOptions.series[0].data.push(alarmTime);
+ }
+ var freeTime = homeUtil.data.free;
+ freeTime.value = left;
+ freeTime.name = libjq.i18n.prop("echarts_free");
+ chartOptions.series[0].data.push(freeTime);
+ }
+ }
+ }
+ } else {
+ var usedData = homeUtil.data.used;
+ usedData.value = 1;
+ usedData.selected = false;
+ usedData.name = libjq.i18n.prop("echarts_no");
+ chartOptions.series[0].data = [usedData];
+ chartOptions.title.text = '';
+ }
+ var firstEle = libus.find(chartOptions.series[0].data, function (n) {
+ return n.name == libjq.i18n.prop("echarts_used");
+ });
+ var alarmEle = libus.find(chartOptions.series[0].data, function (n) {
+ return n.name == libjq.i18n.prop("echarts_alarm");
+ });
+ if (!alarmEle) {
+ alarmEle = {
+ value: 0
+ };
+ }
+ if (typeof firstEle == "undefined") {
+ homeUtil.setEcharts(chartOptions, startName);
+ } else if (homeUtil.oldUsedData != firstEle.value || homeUtil.oldAlarmData != alarmEle.value) {
+ homeUtil.oldUsedData = firstEle.value;
+ homeUtil.oldAlarmData = alarmEle.value;
+ homeUtil.setEcharts(chartOptions, startName);
+ }
+ },
+ getUnitValue: function (unit) {
+ unit = unit.toUpperCase();
+ if (unit == 'GB') {
+ return '1024';
+ } else if (unit == 'TB') {
+ return '1048576';
+ } else {
+ return '1';
+ }
+ },
+ setEcharts: function (options, startName) {
+ var startPart = homeUtil.data.start;
+ startPart.value = 0;
+ startPart.name = startName;
+ startPart.selected = false;
+ var arr = [startPart].concat(options.series[0].data);
+ options.series[0].data = arr;
+ traffic_graphic_chart.setOption(options, true);
+ addTimeout(function () {
+ traffic_graphic_chart.resize();
+ }, 1000);
+ },
+ refreshStationInfo: function (param) {
+ param.wirelessDeviceNum(fnc.getStatusInfo().wirelessDeviceNum);
+ if (num_refresh % 10 == 2) {
+ fnc.getAttachedCableDevices({}, function (data) {
+ param.wireDeviceNum(data.attachedDevices.length);
+ });
+ }
+ },
+ getUnit: function (val) {
+ if (val == '1024') {
+ return 'GB';
+ } else if (val == '1048576') {
+ return 'TB';
+ } else {
+ return 'MB';
+ }
+ },
+ refreshOpmodeInfo: function (param) {
+ var obj = fnc.getOpMode();
+ param.isLoggedIn(obj.loginfo == "ok");
+ var currentMode = checkCableMode(obj.blc_wan_mode);
+ if (param.opCurMode() && !currentMode) {
+ var data = fnc.getLoginData();
+ var state = data.modem_main_state;
+ if (state == "modem_sim_undetected" || state == "modem_undetected" || state == "modem_sim_destroy" || state == "modem_waitpin" || state == "modem_waitpuk" || state == "modem_imsi_waitnck") {
+ window.location.reload();
+ return;
+ }
+ }
+ param.opCurMode(currentMode);
+ if (currentMode && obj.ethwan_mode == "DHCP") {
+ param.enableFlag(false);
+ } else if ((!currentMode && obj.ppp_status != "ppp_disconnected") || (currentMode && obj.rj45_state != "idle" && obj.rj45_state != "dead")) {
+ param.enableFlag(true);
+ } else {
+ param.enableFlag(false);
+ }
+ var mode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;
+ var currentOpMode = "";
+ switch (mode) {
+ case "AUTO":
+ currentOpMode = "opmode_auto";
+ break;
+ case "PPPOE":
+ currentOpMode = "opmode_cable";
+ break;
+ case "PPP":
+ currentOpMode = "opmode_gateway";
+ break;
+ default:
+ break;
+ }
+ libjq("#opmode").attr("data-trans", currentOpMode).text(libjq.i18n.prop(currentOpMode));
+ param.isShowHomeConnect(!currentMode);
+ param.showTraffic(set.TRAFFIC_SUPPORT && !currentMode);
+ param.isSupportQuicksetting(set.HAS_QUICK_SETTING && !currentMode);
+ }
+ };
+ function VmHome() {
+ var target = this;
+ target.hasSms = set.HAS_SMS;
+ target.hasPhonebook = set.HAS_PHONEBOOK;
+ target.isSupportSD = set.SD_CARD_SUPPORT;
+ target.isCPE = set.PRODUCT_TYPE == 'CPE';
+ target.hasRj45 = set.RJ45_SUPPORT;
+ target.notDataCard = set.PRODUCT_TYPE != 'DATACARD';
+ target.hasParentalControl = set.HAS_PARENTAL_CONTROL;
+ var wifiInfo = fnc.getWifiBasic();
+ if (set.WIFI_SUPPORT_QR_SWITCH) {
+ target.showQRCode = set.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
+ } else {
+ target.showQRCode = set.WIFI_SUPPORT_QR_CODE;
+ }
+ if(set.WIFI_SUPPORT_QR_CODE){
+ target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + libjq.now();
+ } else {
+ target.qrcodeSrc = './pic/res_blacktrans.png';
+ }
+ if (target.hasRj45) {
+ var opModeObj = checkCableMode(fnc.getOpMode().blc_wan_mode);
+ target.opCurMode = libko.observable(opModeObj);
+ target.isShowHomeConnect = libko.observable(!opModeObj);
+ target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT && !opModeObj);
+ target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING && !opModeObj);
+ } else {
+ target.isShowHomeConnect = libko.observable(true);
+ target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT);
+ target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING);
+ }
+ if (set.PRODUCT_TYPE == 'DATACARD') {
+ libjq('#home_image').addClass('data-card');
+ }
+ var info = fnc.getConnectionInfo();
+ target.networkType = libko.observable(homeUtil.getNetworkType(info.networkType));
+ target.connectStatus = libko.observable(info.connectStatus);
+ target.canConnect = libko.observable(false);
+ target.cStatus = libko.computed(function () {
+ if (target.connectStatus().indexOf('_connected') != -1) {
+ return connStat.CONNECTED;
+ } else if (target.connectStatus().indexOf('_disconnecting') != -1) {
+ return connStat.DISCONNECTING;
+ } else if (target.connectStatus().indexOf('_connecting') != -1) {
+ return connStat.CONNECTING;
+ } else {
+ return connStat.DISCONNECTED;
+ }
+ });
+ target.current_Flux = libko.observable(transUnit(0, false));
+ target.connected_Time = libko.observable(transSecond2Time(0));
+ target.up_Speed = libko.observable(transUnit(0, true));
+ target.down_Speed = libko.observable(transUnit(0, true));
+ target.isLoggedIn = libko.observable(false);
+ target.enableFlag = libko.observable(true);
+ target.simSerialNumber = libko.observable('');
+ target.imei = libko.observable('');
+ target.imsi = libko.observable('');
+ target.ssid = libko.observable('');
+ target.hasWifi = set.HAS_WIFI;
+ target.showMultiSsid = libko.observable(set.HAS_MULTI_SSID && wifiInfo.multi_ssid_enable == "1");
+ target.trafficAlertEnable = libko.observable(false);
+ target.trafficUsed = libko.observable('');
+ target.trafficLimited = libko.observable('');
+ target.wireDeviceNum = libko.observable(fnc.getAttachedCableDevices().attachedDevices.length);
+ target.wirelessDeviceNum = libko.observable(fnc.getStatusInfo().wirelessDeviceNum);
+ target.showOpModeWindow = function () {
+ if (target.enableFlag()) {
+ return;
+ }
+ showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
+ };
+ target.currentOpMode = libko.observable("0");
+ var popoverShown = false;
+ libjq('#showDetailInfo').popover({
+ html: true,
+ placement: 'top',
+ trigger: 'focus',
+ title: function () {
+ return libjq.i18n.prop('device_info')
+ },
+ content: function () {
+ return getDetailInfoContent();
+ }
+ }).on('shown.bs.popover', function () {
+ popoverShown = true;
+ }).on('hidden.bs.popover', function () {
+ popoverShown = false;
+ });
+ function fetchDeviceInfo() {
+ var data = fnc.getDeviceInfo();
+ target.simSerialNumber(verifyDeviceInfo(data.simSerialNumber));
+ target.imei(verifyDeviceInfo(data.imei));
+ target.imsi(verifyDeviceInfo(data.imsi));
+ target.ssid(verifyDeviceInfo(data.ssid));
+ target.showMultiSsid(set.HAS_MULTI_SSID && data.multi_ssid_enable == "1");
+ return data;
+ }
+ fetchDeviceInfo();
+ function getDetailInfoContent() {
+ var data = fetchDeviceInfo();
+ homeUtil.initShownStatus(data);
+ var addrInfo = homeUtil.wanIpGet(data);
+ var compiled = libus.template(libjq("#detailInfoTmpl").html());
+ var tmpl = compiled({
+ simSerialNumber: verifyDeviceInfo(data.simSerialNumber),
+ imei: verifyDeviceInfo(data.imei),
+ imsi: verifyDeviceInfo(data.imsi),
+ signal: signalFormat(data.signal),
+ hasWifi: set.HAS_WIFI,
+ isCPE: set.PRODUCT_TYPE == 'CPE',
+ hasRj45: set.RJ45_SUPPORT,
+ showMultiSsid: set.HAS_MULTI_SSID && data.multi_ssid_enable == "1",
+ ssid: verifyDeviceInfo(data.ssid),
+ max_access_num: verifyDeviceInfo(data.max_access_num),
+ m_ssid: verifyDeviceInfo(data.m_ssid),
+ m_max_access_num: verifyDeviceInfo(data.m_max_access_num),
+ wifi_long_mode: "wifi_des_" + data.wifiRange,
+ lanDomain: verifyDeviceInfo(data.lanDomain),
+ ipAddress: verifyDeviceInfo(data.ipAddress),
+ showMacAddress: set.SHOW_MAC_ADDRESS,
+ macAddress: verifyDeviceInfo(data.macAddress),
+ showIpv4WanIpAddr: homeUtil.initStatus.showIpv4WanIpAddr,
+ wanIpAddress: addrInfo.wanIpAddress,
+ showIpv6WanIpAddr: homeUtil.initStatus.showIpv6WanIpAddr,
+ ipv6WanIpAddress: addrInfo.ipv6WanIpAddress,
+ sw_version: verifyDeviceInfo(data.sw_version),
+ hw_version: verifyDeviceInfo(data.hw_version)
+ });
+ return libjq(tmpl).translate();
+ }
+ target.connectHandler = function () {
+ if (target.connectStatus() == "ppp_connected") {
+ showLoading('disconnecting');
+ fnc.disconnect({}, function (data) {
+ if (data.result) {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ } else {
+ if (fnc.getStatusInfo().roamingStatus) {
+ showConfirm('dial_roaming_connect', function () {
+ target.connect();
+ });
+ } else {
+ target.connect();
+ }
+ }
+ };
+ target.connect = function () {
+ var statusInfo = fnc.getStatusInfo();
+ var trafficResult = barStat.getTrafficResult(statusInfo);
+ if (statusInfo.limitVolumeEnable && trafficResult.showConfirm) {
+ var confirmMsg = null;
+ if (trafficResult.usedPercent > 100) {
+ confirmMsg = {
+ msg: 'traffic_beyond_connect_msg'
+ };
+ barStat.setTrafficAlertPopuped(true);
+ } else {
+ confirmMsg = {
+ msg: 'traffic_limit_connect_msg',
+ params: [trafficResult.limitPercent]
+ };
+ barStat.setTrafficAlert100Popuped(false);
+ }
+ showConfirm(confirmMsg, function () {
+ homeUtil.doConnect();
+ });
+ } else {
+ homeUtil.doConnect();
+ }
+ };
+ fnc.getSignalStrength({}, function (data) {
+ var signalTxt = signalFormat(convertSignal(data));
+ libjq("#fresh_signal_strength").text(signalTxt);
+ if (popoverShown) {
+ libjq("#popoverSignalTxt").text(signalTxt);
+ }
+ });
+ homeUtil.refreshHomeData(target);
+ addInterval(function () {
+ fnc.getSignalStrength({}, function (data) {
+ var signalTxt = signalFormat(convertSignal(data));
+ libjq("#fresh_signal_strength").text(signalTxt);
+ if (popoverShown) {
+ libjq("#popoverSignalTxt").text(signalTxt);
+ }
+ });
+ homeUtil.refreshHomeData(target);
+ }, 1000);
+ if (target.hasRj45) {
+ homeUtil.refreshOpmodeInfo(target);
+ addInterval(function () {
+ homeUtil.refreshOpmodeInfo(target);
+ }, 1000);
+ }
+ target.showNetworkSettingsWindow = function () {
+ if (target.hasRj45) {
+ fnc.getOpMode({}, function (data) {
+ var mode = checkCableMode(data.blc_wan_mode);
+ if (mode) {
+ window.location.hash = '#network_set';
+ } else {
+ window.location.hash = '#conn_set';
+ }
+ });
+ } else {
+ window.location.hash = '#conn_set';
+ }
+ }
+ };
+ return {
+ init: init
+ };
+});
+
+
+define("language","knockout service jquery set underscore".split(" "),
+ function(ko, service, $, config, _) {
+
+ // »ñÈ¡µ±Ç°ÓïÑÔÏî
+ function getCurrentLanguage() {
+ return service.getLanguage();
+ }
+
+ // ¸ù¾ÝÓïÑÔÏî¼ÓÔØÓïÑÔ×ÊÔ´²¢·ÒëÒ³ÃæÉϵÄbody²¿·Ö
+ // @param {String} current ÓïÑÔÏî:zh-cn
+ function loadLanguageAndRefresh(current){
+ window.CURRENT_LANGUAGE = current;
+ $("body").attr('lang', current);
+ $.i18n.properties({
+ name:'Messages',
+ path:'i18n/',
+ mode:'map',
+ cache: true,
+ language:current,
+ callback: function() {
+ jQuery.validator.messages = $.i18n.map;
+ $('body').translate();
+ }
+ });
+ }
+
+ window.language = null;
+
+
+ function LanguageViewModel() {
+ var target = this;
+ var currentLan = getCurrentLanguage();
+ var languages = _.map(config.LANGUAGES, function(item) {
+ return new Option(item.name, item.value);
+ });
+
+ document.title = config.WEBUI_TITLE;
+ if($('#webui_title')[0]) {
+ $('#webui_title').html(config.WEBUI_TITLE);
+ }
+
+ target.languages = ko.observableArray(languages);
+ target.currentLan = ko.observable(currentLan.Language);
+ window.language = target.currentLan();
+
+ // Çл»ÓïÑÔʼþ´¦Àí
+ // @event langChangeHandler
+ target.langChangeHandler = function(info, event) {
+ clearValidateMsg();
+
+ service.setLanguage({Language: target.currentLan()}, function() {
+ loadLanguageAndRefresh(target.currentLan());
+ window.language = target.currentLan();
+ });
+ };
+
+ // ¼ÓÔØÓïÑÔÁÐ±í²¢Ë¢Ð½çÃæ
+ loadLanguageAndRefresh(target.currentLan());
+ }
+
+ // ³õʼ»¯ÓïÑÔVM²¢°ó¶¨
+ function init() {
+ ko.applyBindings(new LanguageViewModel(), $('#language')[0]);
+ }
+
+ return {
+ init: init
+ };
+});
+
+
+// µÇ½ Ä£¿é
+define("entry","jquery knockout set service underscore menu logout CryptoJS".split(" "),
+ function($, ko,config, service, _, menu, logout, CryptoJS) {
+
+
+ var pageState = {LOGIN:0, WAIT_PIN:1, WAIT_PUK:2, PUK_LOCKED:3, LOGGEDIN:4, LOADING:5};
+ var timer = loginStatusCheckingTimer();
+ var loginLockTimer = 0;
+ var lastLoginStatus = "0";
+
+ function loginViewModel() {
+ var target = this;
+ var data = service.getLoginData();
+ var loginStatus = service.getLoginStatus();
+
+ target.confirmPIN = ko.observable();
+ target.leftSeconds = ko.observable(0);
+ target.loginCount = ko.observable(0);
+ target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);
+ target.newPIN = ko.observable();
+ target.password = ko.observable();
+ target.PIN = ko.observable();
+ target.pinNumber = ko.observable(data.pinnumber);
+ target.PUK = ko.observable();
+ target.pukNumber = ko.observable(data.puknumber);
+ target.showEntrance = ko.observable(false);
+ target.sharePathInvalid = ko.observable(false);
+ target.uiLoginTimer = ko.observable(300);
+
+ // ×¢Òâ˳Ðò£¬µ÷ÕûÇ°Ãæ»áÎÞ·¨Ë¢Ð³ö½çÃæ
+ target.accountLocked = ko.computed(function () {
+ return target.loginCount() == config.MAX_LOGIN_COUNT && target.leftSeconds() != '-1';
+ });
+
+ target.leftUnlockTime = ko.computed(function () {
+ target.leftSeconds();
+ var formatted = transSecond2Time(target.uiLoginTimer());
+ return formatted.substring(formatted.indexOf(':') + 1, formatted.length);
+ });
+
+
+ if(config.SD_CARD_SUPPORT){
+ service.getSDConfiguration({}, function (data) {
+ target.showEntrance(data.sd_status == "1" && data.share_status == "1" && data.sd_mode == "0");
+ if(target.showEntrance()){
+ service.checkFileExists({
+ path: data.share_file
+ }, function (data1) {
+ if (data1.status == 'exist' || data1.status == 'processing') {
+ target.sharePathInvalid(false);
+ } else {
+ target.sharePathInvalid(true);
+ }
+ });
+ }
+ });
+ }
+
+ var state = computePageState(loginStatus, data);
+ target.pageState = ko.observable(state);
+ if (state == pageState.LOADING) {
+ addTimeout(refreshPage, 500);
+ }
+ setFocus();
+
+
+ // login ʼþ´¦Àí
+
+ target.login = function () {
+ if(config.LOGIN_SECURITY_SUPPORT && target.accountLocked()){
+ showAlert("password_error_account_lock_time", function () {
+ setFocus();
+ });
+ return false;
+ }
+ target.pageState(pageState.LOADING);
+ window.clearInterval(timer);
+ var ciphertext = "";
+ if (config.PASSWORD_ENCODE) {
+ ciphertext = target.password();
+ } else {
+ var kparam = service.getDeviceInfoLow();
+ var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
+ var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
+ ciphertext = CryptoJS.AES.encrypt(target.password(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+ }
+ service.login({
+ password:ciphertext
+ }, function (info) {
+ setTimeout(function () {
+ timer = loginStatusCheckingTimer();
+ }, 1300);
+ if (info.result) {
+ target.pageState(pageState.LOGGEDIN);
+ if(config.LOGIN_SECURITY_SUPPORT){
+ target.loginCount(0);
+ target.uiLoginTimer(300);
+ clearInterval(loginLockTimer);
+ }
+ $("#container").empty();
+ window.location.hash = "#main";
+ logout.init();
+ } else {
+ target.password("");
+ if(config.LOGIN_SECURITY_SUPPORT){
+ target.checkLoginData(function(){
+ if (target.loginCount() == config.MAX_LOGIN_COUNT) {
+ showAlert("password_error_five_times", function () {
+ setFocus();
+ });
+ target.startLoginLockInterval();
+ } else {
+ showAlert({msg: 'password_error_left', params: [config.MAX_LOGIN_COUNT - target.loginCount()]}, function () {
+ setFocus();
+ });
+ }
+ });
+ }else {
+ showAlert("password_error", function () {
+ setFocus();
+ });
+ }
+ target.pageState(pageState.LOGIN);
+ }
+ });
+ };
+
+
+
+
+ // »ñÈ¡µÇ¼Ïà¹ØÐÅÏ¢
+ target.checkLoginData = function(cb){
+ service.getLoginData({}, function(r){
+ var failTimes = parseInt(r.psw_fail_num_str, 10);
+ target.loginCount(config.MAX_LOGIN_COUNT - failTimes);
+ target.leftSeconds(r.login_lock_time);
+ target.uiLoginTimer(r.login_lock_time);
+ if($.isFunction(cb)){
+ cb();
+ } else if (target.loginCount() == config.MAX_LOGIN_COUNT) {
+ target.startLoginLockInterval();
+ }
+ });
+ };
+
+ // Æô¶¯µ¹¼ÆÊ±¶¨Ê±Æ÷¡£
+ target.startLoginLockInterval = function () {
+ loginLockTimer = setInterval(function () {
+ service.getLoginData({}, function (data) {
+ if (data.login_lock_time <= 0 || data.psw_fail_num_str == 5) {
+ target.loginCount(0);
+ clearInterval(loginLockTimer);
+ }
+ if(target.leftSeconds() != data.login_lock_time){
+ target.leftSeconds(data.login_lock_time);
+ target.uiLoginTimer(data.login_lock_time);
+ } else {
+ target.uiLoginTimer(target.uiLoginTimer() > 0 ? target.uiLoginTimer() - 1 : 0);
+ }
+ });
+ }, 1000);
+ };
+
+ target.checkLoginData();
+
+
+
+ // ÑéÖ¤ÊäÈëPINʼþ´¦Àí
+ target.enterPIN = function () {
+ target.pageState(pageState.LOADING);
+ var pin = target.PIN();
+ service.enterPIN({
+ PinNumber:pin
+ }, function (data) {
+ if (!data.result) {
+ showAlert("pin_error", function () {
+ refreshPage();
+ });
+ target.PIN('');
+ } else {
+ refreshPage();
+ }
+ });
+ };
+
+ function setFocus(){
+ setTimeout(function () {
+ var txtAdmin = $('#txtAdmin:visible');
+ var txtPIN = $('#txtPIN:visible');
+ var txtPUK = $('#txtPUK:visible');
+ if (txtAdmin.length > 0) {
+ txtAdmin.focus();
+ } else if (txtPIN.length > 0) {
+ txtPIN.focus();
+ } else if (txtPUK.length > 0) {
+ txtPUK.focus();
+ }
+ }, 100);
+ }
+
+
+ // Ë¢ÐÂÒ³Ãæ×´Ì¬
+ function refreshPage() {
+ var data = service.getLoginData();
+ var loginStatus = service.getLoginStatus();
+ var state = computePageState(loginStatus, data);
+ if (state == pageState.LOADING) {
+ addTimeout(refreshPage, 500);
+ } else {
+ target.pageState(state);
+ target.pinNumber(data.pinnumber);
+ target.pukNumber(data.puknumber);
+ }
+ setFocus();
+ }
+
+ // ÊäÈëPUKÉèÖÃÐÂPINʼþ´¦Àí
+ target.enterPUK = function () {
+ target.pageState(pageState.LOADING);
+ var newPIN = target.newPIN();
+ var confirmPIN = target.confirmPIN();
+ var params = {};
+ params.PinNumber = newPIN;
+ params.PUKNumber = target.PUK();
+ service.enterPUK(params, function (data) {
+ if (!data.result) {
+ showAlert("puk_error", function () {
+ refreshPage();
+ });
+ target.PUK('');
+ target.newPIN('');
+ target.confirmPIN('');
+ } else {
+ refreshPage();
+ }
+ });
+ };
+
+
+
+ // ¸ù¾ÝµÇ¼״̬ºÍSIM¿¨×´Ì¬·µ»ØÒ³Ãæ×´Ì¬
+ function checkPinAfterLogin(loginStatus, data) {
+ if (loginStatus.status == "loggedIn") {
+ var currentState = data.modem_main_state; // cov_2
+ if (currentState == "modem_waitpin") {
+ return pageState.WAIT_PIN;
+ } else if ((currentState == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {
+ return pageState.WAIT_PUK;
+ } else if ((data.puknumber == 0 || currentState == "modem_sim_destroy")
+ && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
+ return pageState.PUK_LOCKED;
+ } else {
+ return pageState.LOGGEDIN;
+ }
+ } else {
+ var currentState = data.modem_main_state;
+ if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
+ return pageState.LOADING;
+ } else {
+ return pageState.LOGIN;
+ }
+ }
+ }
+
+ // ¸ù¾ÝµÇ¼״̬ºÍSIM¿¨×´Ì¬ÉèÖÃÒ³Ãæ×´Ì¬
+ function computePageState(loginStatus, data) {
+ //PX-880 ÏȵǼÔÙ½øÐÐPINÑéÖ¤£¬ÓÉÓÚrouterÉè¼ÆÔÒò£¬µÇ¼ºó£¬PINÑéÖ¤²»ÔÚµÇÂ¼Ò³Ãæ½øÐУ¬ºÍÊý¾Ý¿¨µÄÑéÖ¤±£³ÖÒ»Ö¡£
+ if (config.LOGIN_THEN_CHECK_PIN) {
+ return checkPinAfterLogin(loginStatus, data);
+ } else {
+ return loginAfterCheckPin(loginStatus, data);
+ }
+ }
+
+ // ¸ù¾ÝµÇ¼״̬ºÍSIM¿¨×´Ì¬·µ»ØÒ³Ãæ×´Ì¬
+ function loginAfterCheckPin(loginStatus, data) {
+ if (loginStatus.status == "loggedIn") {
+ return pageState.LOGGEDIN;
+ } else {
+ var currentState = data.modem_main_state;
+ if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
+ return pageState.LOADING;
+ } else if (currentState == "modem_waitpin") {
+ return pageState.WAIT_PIN;
+ } else if ((currentState == "modem_waitpuk" || parseInt(data.pinnumber) === 0) && (parseInt(data.puknumber) != 0)) {
+ return pageState.WAIT_PUK;
+ } else if ((parseInt(data.puknumber) === 0 || currentState == "modem_sim_destroy") && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
+ return pageState.PUK_LOCKED;
+ } else {
+ return pageState.LOGIN;
+ }
+ }
+ }
+ }
+
+
+ // ¼ì²éµ±Ç°window.location.hash£¬Òì³£ÔòÌø×ªµ½index.html
+ function gotoLogin() {
+ if (window.location.hash != config.defaultRoute && _.indexOf(config.GUEST_HASH, window.location.hash) == -1) {
+ if (!manualLogout && lastLoginStatus == "1") {
+ manualLogout = false;
+ lastLoginStatus = 'UNREAL';
+ showAlert('need_login_again', function () {
+ window.location = "index.html";
+ });
+ } else if (lastLoginStatus == 'UNREAL') {
+ //do nothing, only popup need_login_again alert one time
+ return;
+ } else {
+ window.location = "index.html";
+ }
+ }
+ }
+
+ // ¶¨Ê±¼ì²éµÇ¼״̬
+ function loginStatusCheckingTimer() {
+ return setInterval(function () {
+ var info = service.getStatusInfo();
+ if (!info.isLoggedIn) {
+ gotoLogin();
+ return;
+ }
+ lastLoginStatus = service.getStatusInfo().isLoggedIn ? "1" : "0";
+ }, 1000);
+ }
+
+ function init() {
+ var info = service.getStatusInfo();
+ if (info.isLoggedIn) {
+ window.location.hash = '#main';
+ return;
+ }
+
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ var fwVm = new loginViewModel();
+ ko.applyBindings(fwVm, container);
+
+ $('#frmLogin').validate({
+ submitHandler:function () {
+ fwVm.login();
+ },
+ rules: {
+ txtAdmin: 'login_password_length_check'
+ }
+ });
+ $('#frmPIN').validate({
+ submitHandler:function () {
+ fwVm.enterPIN();
+ },
+ rules:{
+ txtPIN:"pin_check"
+ }
+ });
+ $('#frmPUK').validate({
+ submitHandler:function () {
+ fwVm.enterPUK();
+ },
+ rules:{
+ txtNewPIN:"pin_check",
+ txtConfirmPIN:{equalToPin:"#txtNewPIN"},
+ txtPUK:"puk_check"
+ }
+ });
+ }
+
+
+ return {
+ init:init,
+ gotoLogin:gotoLogin
+ };
+ });
+
+
+// Logout Ä£¿é
+define("logout","set service knockout underscore jquery".split(" "),
+ function (config, service, ko, _, $) {
+
+ function logoutViewModel() {
+ var target = this;
+ // »ñÈ¡ÊÇ·ñµÇ¼
+ var loginFlag = function () {
+ var loginInfo = service.getLoginStatus();
+ return (loginInfo.status == "loggedIn");
+ }
+ ();
+ target.loggedIn = ko.observable(loginFlag);
+
+ // Í˳öϵͳ
+ target.logout = function () {
+ showConfirm("confirm_logout", function () {
+ manualLogout = true;
+ service.logout({}, setLocation());
+ });
+ };
+
+ // ÊÇ·ñÏÔʾÍ˳ö°´Å¥
+ target.showLogout = function () {
+ if (config.HAS_LOGIN) {
+ return target.loggedIn();
+ } else {
+ return false;
+ }
+ };
+ }
+ function setLocation() {
+ window.location = 'index.html';
+ }
+ function initialize() {
+ var fwVm = new logoutViewModel();
+ bindContainer(fwVm);
+ }
+ function bindContainer(fwVm) {
+ var con = $('#logout')[0];
+ ko.cleanNode(con);
+ ko.applyBindings(fwVm, con);
+ }
+ return {
+ init: initialize
+ };
+});
+
+// operation mode Ä£¿é
+define("opmode","knockout service jquery set underscore".split(" "),
+
+ function (ko, service, $, config, _) {
+
+ function currentOperationModeViewMode(){
+ var target = this;
+ target.isLoggedIn = ko.observable(false);
+ target.enableFlag = ko.observable(false);
+
+ target.showOpModeWindow = function () {
+ showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {
+ });
+ };
+ target.currentOpMode = ko.observable("0");
+
+ service.getOpMode({}, function(info){
+ target.isLoggedIn(info.loginfo == "ok");
+ if (info.opms_wan_mode != "PPP" && info.rj45_state != "idle" && info.rj45_state != "dead") {
+ target.enableFlag(false);
+ } else if (info.opms_wan_mode == "PPP" && info.ppp_status != "ppp_disconnected") {
+ target.enableFlag(false);
+ } else if(info.opms_wan_mode == "DHCP"){
+ target.enableFlag(true);
+ } else {
+ target.enableFlag(true);
+ }
+
+ var opmsWanMode = (info.opms_wan_mode == "DHCP" || info.opms_wan_mode == "STATIC") ? "PPPOE" : info.opms_wan_mode;
+
+ var currentOperationMode = "";
+ switch(opmsWanMode){
+ case "BRIDGE":
+ currentOperationMode = "opmode_bridge";
+ break;
+ case "PPP":
+ currentOperationMode = "opmode_gateway";
+ break;
+ case "PPPOE":
+ currentOperationMode = "opmode_cable";
+ break;
+ default:
+ break;
+ }
+ $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
+ });
+ // ¶¨Ê±²éѯ¹¤×÷ģʽÏà¹Ø×´Ì¬£¬ÉèÖýçÃæ×´Ì¬
+ setInterval(function(){
+ var object = service.getConnectionInfo();
+ if(object.opms_wan_mode == "DHCP") {
+ target.enableFlag(true);
+ } else if((object.opms_wan_mode == "PPP" && object.ppp_status != "ppp_disconnected") || (object.opms_wan_mode != "PPP" && object.rj45_state != "idle" && object.rj45_state != "dead")) {
+ target.enableFlag(false);
+ } else {
+ target.enableFlag(true);
+ }
+ }, 1000);
+ }
+
+ function init() {
+ var container = $('#currentOpMode')[0];
+ ko.cleanNode(container);
+ var fwVm = new currentOperationModeViewMode();
+ ko.applyBindings(fwVm, container);
+ }
+
+ return {
+ init:init
+ };
+});
+
+// operation mode popupÄ£¿é
+
+define("opmode_popup","knockout service jquery set underscore".split(" "),
+
+ function (ko, service, $, config, _) {
+
+ function operationModeViewMode() {
+ var target = this;
+ var currentSelectedOperationMode = "";
+ target.selectedMode = ko.observable("0");
+
+ // ³õʼ»¯½çÃæÄ£Ê½ÏÔʾ
+ service.getOpMode({}, function(info){
+ if(info.blc_wan_mode == "AUTO_PPP"){
+ currentSelectedOperationMode = "AUTO";
+ }else if(info.blc_wan_mode == "AUTO_PPPOE"){
+ currentSelectedOperationMode = "AUTO";
+ }else if(info.blc_wan_mode == "PPPOE"){
+ currentSelectedOperationMode = "PPPOE";
+ }else{
+ currentSelectedOperationMode = info.blc_wan_mode;
+ }
+ target.selectedMode(currentSelectedOperationMode);
+ });
+
+ // ģʽÉèÖÃ/Çл»
+ target.changeOpMode = function(){
+ var userSelectedOperationMode = $('input:radio[name="opMode"]:checked').val();
+ var messageText = "";
+ if(userSelectedOperationMode == currentSelectedOperationMode) {
+ hidePopupSettingWindow();
+ return;
+ }
+ if(userSelectedOperationMode == "LTE_BRIDGE"){
+ messageText = "opmode_msg3";
+ }else{
+ messageText = "opmode_msg2";
+ }
+ showConfirm(messageText, function(){
+ showLoading();
+ service.SetOperationMode({
+ opMode: userSelectedOperationMode
+ },function(info){
+ if (info && info.result == "success") {
+ var currentOperationMode = "";
+ switch(userSelectedOperationMode){
+ case "AUTO":
+ currentOperationMode = "opmode_auto"
+ break;
+ case "PPP":
+ currentOperationMode = "opmode_gateway";
+ break;
+ case "PPPOE":
+ currentOperationMode = "opmode_cable";
+ break;
+ default:
+ break;
+ }
+ $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ });
+
+ }
+
+ }
+
+ function init() {
+ var fwVm = new operationModeViewMode();
+ ko.applyBindings(fwVm, $('#popupSettingWindow')[0]);
+
+ $("#opmode_form").validate({
+ submitHandler: function(){
+ fwVm.changeOpMode();
+ }
+ });
+ }
+
+ return {
+ init:init
+ };
+});
+
+define("router","underscore jquery menu set service".split(" "),
+ function (_, $, menu, config, service) {
+ var currentHash = '';
+ var container = $('#container');
+
+ //À뿪½çÃæÊ±¼ì²éÊÇ·ñÓÐÄÚÈÝÐ޸ģ¬Èç¹ûÓÐÔòÌáʾ
+ checkFormContentModify = function (href) {
+ if (config.CONTENT_MODIFIED.modified && window.location.hash != href) {
+ if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
+ config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
+ config.resetContentModifyValue();
+ window.location.hash = href;
+ } else {
+ showConfirm(config.CONTENT_MODIFIED.message, {
+ ok: function () {
+ config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
+ config.resetContentModifyValue();
+ window.location.hash = href;
+ },
+ no: function () {
+ var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);
+ if (!result) {
+ window.location.hash = href;
+ config.resetContentModifyValue();
+ }
+ }
+ });
+ }
+ return false;
+ } else {
+ return true;
+ }
+ };
+
+ //¶¨Ê±²é¿´SIM¿¨µÄ״̬£¬Èôµ±Ç°SIM¿¨×´Ì¬²»Îª¾ÍÐ÷״̬ÇÒδÏÔʾnosimcardÒ³Ãæ£¬ÔòÏÔʾnosimcardÒ³Ãæ,ÒÔ±ÜÃâ²»¹Ø±Õwebui£¬ÖØÐ²å°ÎÉ豸ºó£¬²»ÔÙÅжÏSIM¿¨×´Ì¬µÄÎÊÌâ
+ function checkSimCardStatus() {
+ setInterval(function () {
+ var data = service.getStatusInfo();
+ var match = menu.findMenu();
+ if (match.length == 0) {
+ return false;
+ }
+ var requirePinHash = ["phonebook", "sms_list"];
+ var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
+ if (match[0].checkSIMStatus === true) {
+ var simstatus = data.simStatus == "modem_sim_undetected"
+ || data.simStatus == "modem_sim_destroy" || data.simStatus == "modem_waitpin"
+ || data.simStatus == "modem_waitpuk";
+ var netlockstatus = data.simStatus == "modem_imsi_waitnck";
+ if (data.isLoggedIn && (
+ ($('#div-nosimcard')[0] == undefined && simstatus)
+ || ($('#div-network-lock')[0] == undefined && netlockstatus)
+ || (($('#div-nosimcard')[0] != undefined || $('#div-network-lock')[0] != undefined) && data.simStatus == "modem_init_complete"))) {
+ fixedLoadResources(match[0], data.simStatus, isRequirePin);
+ }
+ }
+ }, 1000);
+ }
+
+ //¼ì²éµÇÂ¼Ò³Ãæ±³¾°
+ function checkLoginPageBg() {
+ var h = window.location.hash;
+ if (h == '#entry' || _.indexOf(config.GUEST_HASH, h) != -1) {
+ $("#manageContainer").attr("style", "margin-top:-36px;");
+ } else {
+ $("#manageContainer").attr("style", "margin-top:0px;");
+ }
+
+ if (window.location.hash == '#entry') {
+ $("#mainContainer").addClass('loginBackgroundBlue');
+ } else {
+ var mainContainer = $("#mainContainer");
+ if (mainContainer.hasClass('loginBackgroundBlue')) {
+ $("#container").css({
+ margin: 0
+ });
+ mainContainer.removeClass('loginBackgroundBlue').height('auto');
+ }
+ }
+ }
+
+ function fixedLoadResources(menuItem, simStatus, isRequirePin) {
+ var item = {};
+ $.extend(item, menuItem);
+ //ûÓÐSIM¿¨Ê±£¬Õë¶ÔhomeÒ³Ãæ²»×ö´¦Àí¡£
+ //ÍøÂç±»ËøÊ±£¬homeÒ³ÃæÏÔʾ½âËøÒ³Ãæ
+ if (simStatus == "modem_sim_undetected" || simStatus == "modem_sim_destroy") {
+ if (!isRequirePin) {
+ item.path = "sim_abnormal";
+ }
+ } else if (simStatus == "modem_waitpin" || simStatus == "modem_waitpuk") {
+ item.path = "sim_abnormal";
+ } else if (simStatus == "modem_imsi_waitnck") {
+ item.path = "locknet";
+ }
+ //load tmpl and controller js
+ loadResources(item);
+ }
+
+ //¸ù¾Ý²Ëµ¥ÅäÖÃitem¼ÓÔØ¶ÔÓ¦µÄ×ÊÔ´
+ function loadResources(item) {
+ var pId = item.path.replace(/\//g, '_');
+ var $body = $('body').removeClass();
+ if (pId != 'entry' && pId != 'main') {
+ $body.addClass('beautiful_bg page_' + pId);
+ } else {
+ $body.addClass('page_' + pId);
+ }
+ clearTimer();
+ hideLoading();
+ var tmplPath = 'text!tmpl/' + item.path + '.html';
+ //TODO: prevent first menu click cover the second menu content, need test with device
+ require([tmplPath, item.path], function (tmpl, viewModel) {
+ container.stop(true, true);
+ container.hide();
+ container.html(tmpl);
+ viewModel.init();
+ //support backward/forward
+ menu.refreshMenu();
+ $('#container').translate();
+ menu.activeSubMenu();
+
+ $("form").attr("autocomplete", "off");
+ container.fadeIn();
+ });
+ }
+ //±È¶Ôhash״̬, Èç¹û±ä»¯Ôò¸ù¾ÝеÄhashÆ¥Åä²Ëµ¥ÅäÖÃ,Æ¥Åä²»ÉÏÊ±Ìø×ªµ½homeÒ³Ãæ, Æ¥ÅäÉÏʱ¼Ç¼hashÖµ²¢¶¯Ì¬¼ÓÔØ¶ÔÓ¦µÄ×ÊÔ´Îļþ
+ function hashCheck() {
+ if (window.location.hash != currentHash) {
+ //½â¾öµÇ½ºóºóÍËÎÊÌâ, µÇ½Óû§·ÃÎʷǵǼÓû§Ê±Ò³Ãæ²»Ìø×ª
+ var info = service.getStatusInfo();
+ if (window.location.hash == config.defaultRoute || _.indexOf(config.GUEST_HASH, window.location.hash) != -1) {
+ if (info.isLoggedIn) {
+ window.location.hash = currentHash == "" ? "#main" : currentHash;
+ return;
+ }
+ }
+
+ var match = menu.findMenu();
+
+ if (match.length == 0) {
+ window.location.hash = config.defaultRoute;
+ } else {
+ //µÇ¼ʱ¼ì²é¹¤×÷ģʽ£¬ÓÐÏßģʽÏÂÇÒÖ÷½çÃæÐèÒª¼ì²éSIM¿¨×´Ì¬ÔòÖØÐ¼ÓÔØ,ÎÞÏßģʽÇÒÖ÷½çÃæ²»ÐèÒª¼ì²éSIM¿¨×´Ì¬ÔòÖØÐ¼ÓÔØ
+ if (config.RJ45_SUPPORT && window.location.hash == "#main") {
+ if ((match[0].checkSIMStatus && checkCableMode(info.blc_wan_mode)) || (!match[0].checkSIMStatus && !checkCableMode(info.blc_wan_mode))) {
+ window.location.reload();
+ return;
+ }
+ }
+ //TODO: ¶þ¼¶²Ëµ¥Óë¶ÔÓ¦Èý¼¶²Ëµ¥µÚÒ»ÏÏàÇл»Ê±²»ÖØÐ¼ÓÔØÊý¾Ý, ÓëTODO: click the same menu ʵÏÖ·½Ê½»¥³â
+ var oldMenu = menu.findMenu(currentHash);
+ currentHash = match[0].hash;
+ if (currentHash == "#entry") {
+ $('#indexContainer').addClass('login-page-bg');
+ menu.rebuild();
+ } else {
+ $('#indexContainer').removeClass('login-page-bg');
+ }
+
+ if (oldMenu.length != 0 && match[0].path == oldMenu[0].path && match[0].level != oldMenu[0].level && match[0].level != '1' && oldMenu[0].level != '1') {
+ return;
+ }
+
+ checkLoginPageBg();
+ var requirePinHash = ["phonebook", "sms_list"];
+ var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
+ if (match[0].checkSIMStatus === true || isRequirePin) {
+ //simStatus is undefined when refreshing page
+ if (info.simStatus == undefined) {
+ showLoading('waiting');
+ function checkSIM() {
+ var data = service.getStatusInfo();
+ if (data.simStatus == undefined || $.inArray(data.simStatus, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
+ addTimeout(checkSIM, 500);
+ } else {
+ fixedLoadResources(match[0], data.simStatus, isRequirePin);
+ hideLoading();
+ }
+ }
+ checkSIM();
+ } else {
+ fixedLoadResources(match[0], info.simStatus, isRequirePin);
+ }
+ } else {
+ loadResources(match[0]);
+ }
+ }
+ }
+ }
+
+ //ĬÈÏÈë¿ÚÒ³ÃæÎª#main, ¶¨Ê±¼ì²éhash״̬
+ function init() {
+ checkSimCardStatus();
+ window.location.hash = window.location.hash || "#main";
+ //if support onhashchange then use. If ie8 in ie7 mode, it doesn't trigger onhashchange.
+ if (('onhashchange' in window) && ((typeof document.documentMode === 'undefined') || document.documentMode == 8)) {
+ window.onhashchange = hashCheck;
+ hashCheck();
+ } else {
+ setInterval(hashCheck, 200);
+ }
+
+ //Èç¹ûÐÞ¸ÄÁËÒ³ÃæÄÚÈÝ, À뿪ʱ¸ø³öÌáʾ
+ $("a[href^='#']").die('click').live('click', function () {
+ var $this = $(this);
+ config.CONTENT_MODIFIED.checkChangMethod();
+ return checkFormContentModify($this.attr('href'));
+ });
+ }
+
+ return {
+ init: init
+ };
+});
+
+// statusBar Ä£¿é
+
+define("statusBar", "knockout jquery underscore service set menu tooltip".split(" "),
+
+ function (ko, $, _, service, config, menu, tooltip) {
+
+ var sv__hasCheckedSMSCapacity = false;
+ var sv__initSMSCompleted = false;
+ var sv_newSMSMessageInDealing = false;
+ var sv_fotaUpdateCancel = null;
+ var sv_batteryCheckTimer = 0;
+ var sv_dbMessageIds = [];
+ var sv_fotaResultAlertPopuped = false;
+ var sv_isFirstLoadNewMessage = true;
+ var isLoggedIn = true;
+ var sv_messagePopStack = {};
+ var sv_newMessagePopTemplate = null;
+ var sv_resetTrafficAlertPopuped = false;
+ var sv_simMessageListTemplate = null;
+ var sv_smsListTemplate = null;
+ var sv_trafficAlertPopuped_100 = false;
+ var sv_trafficAlertPopuped = false;
+ var sv_timer = 0;
+
+ // »ñȡ״̬ÐÅÏ¢£¬ÈçÍøÂç¡¢SIM¡¢WIFIµÈ
+ var getCurrentStatusInfo = function () {
+ return service.getStatusInfo();
+ };
+
+ function statusViewModel() {
+ var target = this;
+ var info = getCurrentStatusInfo();
+ var roamStatus = info.roamingStatus ? true : false;
+ var $langLogoBar = $("#langLogoBar");
+
+
+ // ´ò¿ªÍøÂçÁ¬½Óʼþ´¦Àí
+ function sf_connect() {
+ showLoading("connecting");
+ service.connect({}, function (data) {
+ if (data.result) {
+ refreshWifiConnectStatus(target, data.status);
+ }
+ successOverlay();
+ }, function (data) {
+ errorOverlay();
+ });
+ }
+ // ¶Ï¿ªÁ¬½Óʼþ´¦Àí
+ function sf_disconnect() {
+ showLoading("disconnecting");
+ service.disconnect({}, function (data) {
+ if (data.result) {
+ refreshWifiConnectStatus(target, data.status);
+ }
+ successOverlay();
+ }, function (data) {
+ errorOverlay();
+ });
+ }
+
+ if(info.isLoggedIn){
+ if(!$langLogoBar.hasClass("langborderBg")){
+ $langLogoBar.addClass("langborderBg");
+ }
+ $("#statusBar:hidden").show();
+ } else {
+ if($langLogoBar.hasClass("langborderBg")){
+ $langLogoBar.removeClass("langborderBg");
+ }
+ $("#statusBar:visible").hide();
+ }
+
+
+ //target.attachedDevices = ko.observable(info.attachedDevices);
+ target.batteryLevel = ko.observable(info.batteryLevel + '%');
+ target.batteryPers = ko.observable(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
+ target.batteryStatus = ko.observable(info.batteryStatus);
+ target.connectionCssClass = ko.observable("");
+ target.connectStatus = ko.observable(info.connectStatus);
+ target.connectStatusText = ko.observable();
+ target.connectStatusTrans = ko.observable();
+ target.hasWifi = ko.observable(config.HAS_WIFI);
+ target.hasBattery = ko.observable(config.HAS_BATTERY);
+ target.isLoggedIn = ko.observable(info.isLoggedIn);
+ target.isShowConnectionIcon = ko.observable(false);
+ target.isShowFotaNewversionIcon = ko.observable(info.new_version_state && info.fota_package_already_download != "yes" && !config.isShowFotaIcon);
+ target.isShowRj45ConnectionIcon = ko.observable(false);
+ target.networkOperator = ko.observable(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,roamStatus));
+ target.networkType = ko.observable(getNetworkType(info.networkType));
+ target.pinStatus = ko.observable(info.pinStatus);
+ target.pinStatusText = ko.observable();
+ target.rj45ConnectionCssClass = ko.observable("");
+ target.roamingStatus = ko.observable(info.roamingStatus ? "R" : "");
+ target.showAttachedDevices = ko.observable(info.wifiStatus);
+ target.showSmsDeleteConfirm = ko.observable(false);
+ target.smsUnreadCount = ko.observable(0);
+ target.simStatus = ko.observable(sf_convertSimStatusToImage(info.simStatus));
+ target.signalCssClass = ko.observable(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
+ target.updateType = ko.observable(service.getUpdateType().update_type);
+ target.wifiStatusCssClass = ko.observable(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
+ target.wifiStatusImg = ko.observable(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
+
+ sf_getConnectionCssClass(target, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
+
+ target.connect = sf_connect;
+ target.disconnect = sf_disconnect;
+ }
+
+ function sf_gotoSmsList(){
+ var s_href = '#msg_main';
+ if(window.location.hash == '#msg_main'){
+ s_href = '#msg_list';
+ }
+ config.CONTENT_MODIFIED.checkChangMethod();
+ if(checkFormContentModify(s_href)){
+ window.location.hash = s_href;
+ }
+ }
+
+ gotoSmsList = sf_gotoSmsList;
+
+ function sf_getNetWorkProvider(i_spnB1Flag, i_spnNameData, i_spnB2Flag, i_networkProvider, i_roamStatus) {
+ if (i_spnNameData == "") {
+ return i_networkProvider;
+ } else {
+ i_spnNameData = decodeMessage(i_spnNameData);
+ if (i_spnB1Flag == "0" && i_spnB2Flag == "0") {
+ if (i_roamStatus) {//ÂþÓÎ
+ return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
+ } else {//²»ÂþÓÎ
+ return i_spnNameData;
+ }
+ }else if (i_spnB1Flag == "1" && i_spnB2Flag == "1") {
+ if (i_roamStatus) {//ÂþÓÎ
+ return i_networkProvider;
+ } else {//²»ÂþÓÎ
+ return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
+ }
+ } else if (i_spnB1Flag == "1") {
+ return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
+ } else if (i_spnB2Flag == "1") {
+ if (i_roamStatus) {//ÂþÓÎ
+ return i_networkProvider;
+ } else {//²»ÂþÓÎ
+ return i_spnNameData;
+ }
+ }
+ return "";
+ }
+ }
+
+ // Ìí¼ÓжÌÏûÏ¢Ìáʾ£¬²¢¸üÐÂÏà¹ØÄÚÈÝ
+ function sf_addNewMessage(i_message, i_isUpdate, i_type){
+ config.smsMaxId = i_message.id;
+ var now = $.now();
+ sv_messagePopStack["m" + now] = now;
+ var name = i_message.number;
+ if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
+ sv_isFirstLoadNewMessage = false;
+ if(config.HAS_PHONEBOOK){
+ sf_getPhoneBooks();
+ }else{
+ config.phonebook = [];
+ }
+ }
+ for(i in config.phonebook){
+ if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
+ name = config.phonebook[i].pbm_name;
+ break;
+ }
+ }
+ var s_newMsg = {
+ mark : "m" + now,
+ name: name,
+ title: $.i18n.prop("sms"),
+ titleTrans: "sms",
+ tag: i_message.tag,
+ content : i_message.content,
+ datetime : i_message.time
+ };
+ if(sv_newMessagePopTemplate == null){
+ sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
+ }
+ $(".bubbleItem:not(.report)", "#buttom-bubble").remove();
+ $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
+ if((window.location.hash == "#msg_main" || window.location.hash == "#msg_list") && i_type == "1"){
+ //sf_dealChosenNumber(s_newMsg.name, i_message.number);
+ var s_inChating = config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
+ var s_itemId = getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
+ var item = $("#smslist-item-" + s_itemId);
+ if(item && item.length > 0){
+ // ÒÑ´æÔÚÄÚÈÝ£¬¸üÐÂÄÚÈݵ÷Õû˳Ðò
+ for(var i = 0; config.listMsgs && i < config.listMsgs.length; i++){
+ if(getLastNumber(config.listMsgs[i].number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
+ config.listMsgs[i].id = i_message.id;
+ config.listMsgs[i].latestId = i_message.id;
+ config.listMsgs[i].latestSms = i_message.content;
+ config.listMsgs[i].latestTime = i_message.time;
+ if(!i_isUpdate){
+ config.listMsgs[i].newCount++;
+ config.listMsgs[i].totalCount++;
+ }
+ break;
+ }
+ }
+ item.find(".smslist-item-checkbox p.checkbox").attr("id", i_message.id);
+ item.find(".smslist-item-checkbox input:checkbox").val(i_message.id).attr("id", "checkbox" + i_message.id);
+ if(!i_isUpdate){
+ var s_itemCount = item.find(".smslist-item-total-count").text();
+ s_itemCount = Number(s_itemCount.substring(1, s_itemCount.length - 1));
+ item.find(".smslist-item-total-count").text("(" + (s_itemCount + 1) + ")");
+ if(!config.currentChatObject || config.currentChatObject != getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
+ var s_newNum = item.find(".smslist-item-new-count").removeClass("hide");
+ if(s_newNum && s_newNum.text().length > 0){
+ s_newNum.text(Number(s_newNum.text()) + 1);
+ }else{
+ s_newNum.text(1);
+ }
+ }
+ }
+ if(item.find(".smslist-item-draft-flag").length > 0){
+ if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
+ item.find(" td:nth-child(2)").removeClass("font-weight-bold");
+ } else {
+ item.find(" td:nth-child(2)").addClass("font-weight-bold");
+ }
+ }else{
+ var msgContent = item.find(".smslist-item-msg").text(i_message.content);
+ msgContent.closest('td').prop('title', i_message.content);
+ item.find("span.clock-time").text(i_message.time);
+ if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
+ msgContent.closest('tr').removeClass("font-weight-bold");
+ } else {
+ msgContent.closest('tr').addClass("font-weight-bold");
+ }
+ }
+ item.find(".smslist-item-repeat span").die().click(function() {
+ forwardClickHandler(i_message.id);
+ });
+
+ var s_tmpItem = item;
+ item.hide().remove();
+ $("#smslist-table").prepend(s_tmpItem.show());
+ } else {
+ // Èç¹û¶ÌÐÅÁбíÖв»´æÔÚÏàÓ¦µÄÁªÏµÈ˶ÌÏ¢£¬Ó¦ÔÚ¶ÌÐÅÁбíÖÐÐÂÔöÊý¾Ý
+ var s_theName = "";
+ if(config.phonebook && config.phonebook.length > 0) {
+ for(i in config.phonebook){
+ if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
+ s_theName = config.phonebook[i].pbm_name;
+ break;
+ }
+ }
+ }
+ var s_theNewMessage = {
+ id : i_message.id,
+ name : s_theName,
+ number : i_message.number,
+ latestId :i_message.id,
+ totalCount : 1,
+ newCount : s_inChating ? 0 : 1,
+ latestSms : i_message.content,
+ latestTime : i_message.time,
+ checked : false,
+ hasDraft : false,
+ itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
+ };
+ if(sv_smsListTemplate == null){
+ sv_smsListTemplate = $.template("smsTableTmpl", $("#smsTableTmpl"));
+ }
+ $.tmpl("smsTableTmpl", {data: [s_theNewMessage]}).prependTo("#smslist-table");
+ }
+ if(config.HAS_PHONEBOOK){
+ $(".sms-add-contact-icon").removeClass("hide");
+ }else{
+ $(".sms-add-contact-icon").addClass("hide");
+ }
+ if(s_inChating){
+ var talkItem = $("#talk-item-" + i_message.id, "#chatlist");
+ if (talkItem && talkItem.length > 0) {// ¸üм¶Áª¶ÌÐÅÄÚÈÝ
+ $(".J_content pre", talkItem).html(dealContent(i_message.content));
+ $(".time .smslist-item-time", talkItem).text(i_message.time);
+ $(".smslist-item-repeat", talkItem).die().click(
+ function() {
+ forwardClickHandler(i_message.id);
+ });
+ $(".smslist-item-delete", talkItem).die().click(
+ function() {
+ deleteSingleItemClickHandler(i_message.id);
+ });
+ } else {// Ôö¼ÓеĻظ´ÄÚÈÝ
+ $("#smsOtherTmpl").tmpl(i_message).appendTo("#chatlist");
+ $(".clear-container", "#chatpanel").animate({
+ scrollTop : $("#chatlist").height()
+ });
+ }
+ if (!config.SMS_SET_READ_WHEN_COMPLETE) {
+ service.setSmsRead({ids: [i_message.id]}, $.noop);
+ } else if (config.SMS_SET_READ_WHEN_COMPLETE && i_message.receivedAll) {
+ service.setSmsRead({ids: [i_message.id]}, $.noop);
+ }
+ }
+ enableCheckbox($("#smslist-checkAll"));
+ }
+ if(window.location.hash == "#msg_sim" && i_type == "0"){
+ // Èç¹û¶ÌÐÅÁбíÖв»´æÔÚÏàÓ¦µÄÁªÏµÈ˶ÌÏ¢£¬Ó¦ÔÚ¶ÌÐÅÁбíÖÐÐÂÔöÊý¾Ý
+ var s_theName = "";
+ if(config.phonebook && config.phonebook.length > 0) {
+ for(i in config.phonebook){
+ if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
+ s_theName = config.phonebook[i].pbm_name;
+ break;
+ }
+ }
+ }
+ var s_theNewMessage = {
+ id : i_message.id,
+ name : s_theName,
+ number : i_message.number,
+ content : i_message.content,
+ time : i_message.time,
+ tag: i_message.tag,
+ checked : false,
+ itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
+ };
+ if(i_isUpdate){
+ var s_item = $(".simMsgList-item-class-" + s_theNewMessage.id);
+ s_item.hide().remove();
+ }
+ if(sv_simMessageListTemplate == null){
+ sv_simMessageListTemplate = $.template("ssimMessageListTemplate", $("#simMessageListTemplate"));
+ }
+ $.tmpl("simMessageListTemplate", {data: [s_theNewMessage]}).prependTo("#simMsgList_container");
+ }
+ }
+
+ function sf_checkBatteryStatusForFota(){
+ var s_state = service.getCurrentUpgradeState();
+ if(s_state.current_upgrade_state == 'low_battery'){
+ showInfo('ota_low_battery');
+ clearInterval(sv_batteryCheckTimer);
+ }
+ }
+
+ // ½«SIM¿¨×´Ì¬×ª»¯ÎªÏìÓ¦µÄÎÄ×ÖÃèÊö
+ function sf_convertSimStatusToImage(i_status) {
+ var s_image;
+ switch (i_status) {
+ case "modem_destroy":
+ s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
+ break;
+ case "modem_imsi_waitnck":
+ s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitnck");
+ break;
+ case "modem_init_complete":
+ s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
+ break;
+ case "modem_sim_destroy":
+ s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
+ break;
+ case "modem_sim_undetected":
+ s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_undetected");
+ break;
+ case "modem_undetected":
+ s_image = "./pic/simcard_undetected.png";
+ break;
+ case "modem_waitpin":
+ s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpin");
+ break;
+ case "modem_waitpuk":
+ s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpuk");
+ break;
+
+ default:
+ s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
+ break;
+ }
+ return s_image;
+ }
+
+ function sf_dealChosenNumber(i_choosenName, i_choosenNum) {
+ setTimeout(function () {
+ var s_choosen = $("#chosenUserSelect");
+ var s_options = $("option", s_choosen);
+ for (var index = 0; index < s_options.length; index++) {
+ if (getLastNumber(i_choosenNum, config.SMS_MATCH_LENGTH) == s_options[index].value) {
+
+ s_options[index].text = i_choosenName + '/' + i_choosenNum;
+ s_options[index].value = i_choosenNum;
+
+ break;
+ }
+ }
+ s_choosen.trigger("liszt:updated");
+ }, 0);
+ }
+
+ // Ë«Òì²½»ñÈ¡É豸²àºÍsim¿¨²âµÃ¶ÌÐÅÏ¢£¬²¢½«ÆäºÏ²¢
+ function sf_dealPhoneBooksResult(i_books){
+ if($.isArray(i_books.pbm_data) && i_books.pbm_data.length > 0){
+ config.phonebook = i_books.pbm_data;
+ }
+ }
+
+ // ¹ýÂË×îеÄ5Ìõ¶ÌÏûÏ¢£¬½«Î´Ìí¼Óµ½¶ÌÐÅÁбíÖеĵ¯³öÌáʾ
+ function sf_filterNewMessage(i_messages, i_type){
+ if(!config.dbMsgs){
+ config.dbMsgs = [];
+ }
+ if(sv_dbMessageIds.length == 0){
+ $.each(config.dbMsgs, function(index_1, i_element){
+ sv_dbMessageIds.push(i_element.id);
+ });
+ }
+ $.each(i_messages, function(index_2, i_element){
+ if($.inArray(i_element.id, sv_dbMessageIds) == -1){//Ôö¼ÓжÌÐÅ
+ sv_dbMessageIds.push(i_element.id);
+ config.dbMsgs.push(i_element);
+ if(i_element.tag == '1'){
+ sf_addNewMessage(i_element, false, i_type);
+ }
+ }else{
+ for(var index = 0; index < config.dbMsgs.length; index++){//¸üм¶Áª¶ÌÐÅ
+ if(config.dbMsgs[index].id == i_element.id && config.dbMsgs[index].content != i_element.content && i_element.tag == '1'){
+ config.dbMsgs[index].content = i_element.content;
+ sf_addNewMessage(i_element, true, i_type);
+ break;
+ }
+ }
+ }
+ });
+ }
+
+ // ½«µçÁ¿×ª»¯Îª¶ÔӦͼƬ
+ function sf_getBatteryLevelImage(pers, i_status) {
+ var s_Image = null;
+ if ("0" == i_status) {
+ if ("1" == pers) {
+ s_Image = "pic/power_one.png";
+ } else if ("2" == pers) {
+ s_Image = "pic/power_two.png";
+ } else if ("3" == pers) {
+ s_Image = "pic/power_three.png";
+ } else if ("4" == pers) {
+ s_Image = "pic/power_full.png";
+ } else { //"5" == pers || "0" == pers
+ s_Image = "pic/power_out.png";
+ }
+ } else {
+ s_Image = "pic/power_charging.gif";
+ }
+ return s_Image;
+ }
+
+ // »ñÈ¡ÁªÍø×´Ì¬µÄCSSÑùʽ
+ function sf_getConnectionCssClass(i_fwVm, i_status, i_data_counter, i_wifiSSID, i_wifiStatus, i_rj45Status) {
+
+ var s_rj45ConnectionStatus = "icon_connection ";
+ var s_connectionStatus = "icon_connection ";
+
+ if(i_rj45Status == "connect"){
+ s_rj45ConnectionStatus += "connecting";
+ }else if(i_rj45Status == "working"){
+ s_rj45ConnectionStatus += "rj45_connected";
+ }else{
+ s_rj45ConnectionStatus += "disconnect";
+ }
+
+ if (i_status == "ppp_connecting" || i_status == "wifi_connecting") {
+ s_connectionStatus += "connecting";
+ } else if(i_status == "ppp_connected") {//CPE ppp_statusΪnone readyµÈÖµ
+ if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate != '0') {
+ s_connectionStatus += "connectionBoth";
+ } else if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate == '0') {
+ s_connectionStatus += "connectionUp";
+ } else if (i_data_counter.uploadRate == '0' && i_data_counter.downloadRate != '0') {
+ s_connectionStatus += "connectionDown";
+ } else {
+ s_connectionStatus += "connectionNone";
+ }
+ } else if (i_status == "ppp_disconnected") {
+ if (i_wifiSSID && i_wifiStatus == "connect") {
+ service.getHotspotList({}, function (data) {
+ var s_cssName = "icon_connection ";
+ var s_css = "connecting ";
+ for (var i = 0, len = data.hotspotList.length; i < len; i++) {
+ if (data.hotspotList[i].connectStatus == "1") {
+ s_css = "wifi_connected";
+ break;
+ }
+ }
+ s_cssName += s_css;
+ i_fwVm.connectionCssClass(s_cssName);
+ });
+ i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
+ return;
+ } else if (i_wifiSSID && (i_wifiStatus == "connecting" || i_wifiStatus =="dhcping")) {
+ s_connectionStatus += "connecting";
+ } else {
+ s_connectionStatus += "disconnect";
+ }
+ } else {
+ s_connectionStatus += "disconnect";
+ }
+
+ i_fwVm.connectionCssClass(s_connectionStatus);
+ i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
+ }
+
+ // »ñÈ¡µç»°±¾ÐÅÏ¢
+ function sf_getPhoneBooks() {
+ var s_books = service.getPhoneBooks({
+ page : 0,
+ data_per_page : 2000,
+ orderBy : "id",
+ isAsc : false
+ });
+ sf_dealPhoneBooksResult(s_books);
+ }
+
+ // »ñÈ¡ÐźÅÁ¿µÄCSSÑùʽ
+ function sf_getSignalCssClass(siganl, networkType, simStatus) {
+ networkType = networkType.toLowerCase();
+ simStatus = simStatus ? simStatus.toLowerCase() : '';
+ if(networkType == '' || networkType == 'limited_service' || networkType == 'no_service' || networkType == 'limited service' || networkType == 'no service'
+ || simStatus != 'modem_init_complete'){
+ siganl = '_none';
+ }
+ return "signal signal" + siganl;
+ }
+
+ function sf_getWifiStatusCssClass(i_status, i_deviceSize) {
+ if (i_status) {
+ if (i_deviceSize == 0) {
+ return "wifi_status0";
+ } else {
+ return "wifi_status" + i_deviceSize;
+ }
+ } else {
+ return "wifi_status_off";
+ }
+ }
+
+ // ¸ù¾Ýwifi״̬»ñÈ¡wifiµÄͼƬ×ÊÔ´
+ function sf_getWifiStatusImage(i_status, i_deviceSize) {
+ if (i_status) {
+ if (i_deviceSize == 0) {
+ return "./pic/wlan0.png";
+ } else {
+ return "./pic/wlan" + i_deviceSize + ".png";
+ }
+ } else {
+ return "./pic/wlan_off.png";
+ }
+ }
+
+ // »ñÈ¡ÒÑÏÂÔØÉý¼¶°ü´óС£¬¸üÐÂÏÂÔØ½ø¶È
+ function sf_refreshFotaDownloadProgress(){
+ service.getPackSizeInfo({}, function (data) {
+ var percents;
+ if (parseInt(data.fota_pkg_total_size) == 0) {
+ percents = 0;
+ } else {
+ percents = parseInt(parseInt(data.fota_dl_pkg_size) * 100 / parseInt(data.fota_pkg_total_size));
+ }
+ if (percents > 100) {
+ percents = 100;
+ }
+ if (percents >= 0) {
+ if (percents > 95) {
+ showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
+ }
+ setProgressBar(percents);
+ }
+ });
+ }
+
+ // ´¦Àí¶ÌÐÅ·¢Ëͱ¨¸æ
+ function sf_responseSmsReport(){
+ if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
+
+ sv_isFirstLoadNewMessage = false;
+
+ if(config.HAS_PHONEBOOK){
+ sf_getPhoneBooks();
+ }else{
+ config.phonebook = [];
+ }
+ }
+ service.getSMSDeliveryReport({
+ page: 0,
+ smsCount: 10
+ }, function(data){
+ var s_messages = data.messages;
+ var s_nums = [];
+ $.each(s_messages, function(i, i_message){
+ if($.inArray(i_message.number, s_nums) == -1){
+ s_nums.push(i_message.number);
+ window.setTimeout(function(){
+ var s_now = $.now();
+ sv_messagePopStack["m" + s_now] = s_now;
+ i_message.name = i_message.number;
+ for(i in config.phonebook){
+ if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
+ i_message.name = config.phonebook[i].pbm_name;
+ break;
+ }
+ }
+ var s_msgContent = $.i18n.prop("sms_delivery_report_" + i_message.content);
+
+ var s_newMsg = {
+ mark : "m" + s_now,
+ name: i_message.name,
+ title: $.i18n.prop("sms_report"),
+ titleTrans: "sms_report",
+ content : s_msgContent,
+ datetime : i_message.time,
+ report : 'report'
+ };
+
+ if(sv_newMessagePopTemplate == null){
+ sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
+ }
+
+ $(".report", "#buttom-bubble").remove();
+ $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
+ }, 100);
+ }
+ });
+ }, function(){
+ //No Deal
+ });
+ }
+
+ function sf_simStatusInvalid(simStatus){
+ return simStatus == 'modem_sim_undetected' || simStatus == 'modem_undetected' || simStatus == 'modem_sim_destroy'
+ || simStatus == 'modem_waitpin' || simStatus == 'modem_waitpuk' || simStatus == 'modem_imsi_waitnck';
+ }
+
+ // ÏÔʾFOTAÉý¼¶µ±Ç°×´Ì¬
+ function sf_showFotaCurrentStatus() {
+ sv_fotaUpdateCancel = true;
+ var r = service.getNewVersionState();
+
+ function showProgress() {
+ var upgradingState = ["downloading"];
+ var info = service.getCurrentUpgradeState();
+ if(info.current_upgrade_state.toLowerCase() == "idle") {
+ addTimeout(showProgress, 1000);
+ } else if(($.inArray(info.current_upgrade_state, upgradingState) != -1)&&(r.fota_new_version_state != "already_has_pkg")) {
+ hideLoading();
+ sf_showFotaUpgradeStatus();
+ }
+ }
+ if (!($("#progress").is(":visible"))) {
+ showProgress();
+ }
+ var times = 0;
+ var getOTAUpgradeState = function () {
+ var data = null;
+ if (times <= 3) {
+ times = times + 1;
+ data = service.getCurrentUpgradeState();
+ } else {
+ data = getCurrentStatusInfo();
+ }
+ var state = data.current_upgrade_state;
+ if(sv_fotaUpdateCancel && isLoggedIn == true){
+
+ if(r.fota_new_version_state == "already_has_pkg"){
+ if(state == 'low_battery'){
+ hideProgressBar();
+ sv_fotaUpdateCancel = false;
+ service.removeTimerThings('fota_current_upgrade_state',function(){});
+ showInfo('ota_pkg_low_battery');
+ window.clearTimeout(sv_timer);
+ return;
+ }else if(state == 'prepare_install'){
+ hideProgressBar();
+ sv_fotaUpdateCancel = false;
+ service.removeTimerThings('fota_current_upgrade_state',function(){});
+ showInfo('ota_pkg_download_success');
+ window.clearTimeout(sv_timer);
+ sv_batteryCheckTimer = setInterval(function () {
+ sf_checkBatteryStatusForFota();
+ }, 1000);
+ return;
+ }
+ }else if(state == 'downloading') {
+ sf_refreshFotaDownloadProgress();
+ }else if(state == 'download_failed') {
+ hideProgressBar();
+ sv_fotaUpdateCancel = false;
+ showAlert('ota_download_failed');
+ window.clearTimeout(sv_timer);
+ return;
+ }else if(state == 'low_battery'){
+ hideProgressBar();
+ sv_fotaUpdateCancel = false;
+ service.removeTimerThings('fota_current_upgrade_state',function(){});
+ showInfo('ota_low_battery');
+ window.clearTimeout(sv_timer);
+ return;
+ }else if(state == 'prepare_install'){
+ hideProgressBar();
+ sv_fotaUpdateCancel = false;
+ service.removeTimerThings('fota_current_upgrade_state',function(){});
+ showInfo('ota_download_success');
+ window.clearTimeout(sv_timer);
+ sv_batteryCheckTimer = setInterval(function () {
+ sf_checkBatteryStatusForFota();
+ }, 1000);
+ return;
+ }else{
+ sv_fotaUpdateCancel = false;
+ hideProgressBar();
+ window.clearTimeout(sv_timer);
+ return;
+ }
+ sv_timer = window.setTimeout(getOTAUpgradeState , 1000);
+ }
+ };
+
+ if(sv_fotaUpdateCancel && isLoggedIn == true){
+ sv_timer = window.setTimeout(getOTAUpgradeState , 100);
+ }else{
+ window.clearTimeout(sv_timer);
+ }
+ }
+
+ // ÏÔʾFotaÉý¼¶½á¹û
+ function sf_showFotaUpdateResult(i_otaResult) {
+ if ((!($("#loading").is(":visible"))) && (!($("#confirm").is(":visible")))) {
+ var s_message = i_otaResult ? "ota_update_success" : "ota_update_failed";
+ sv_fotaResultAlertPopuped = true;
+ showAlert(s_message, function () {
+ sv_fotaResultAlertPopuped = false;
+ if (config.UPGRADE_TYPE == "OTA") {
+ service.clearUpdateResult({}, $.noop());
+ }
+ });
+ } else {
+ window.setTimeout(function () {
+ sf_showFotaUpdateResult(i_otaResult)
+ }, 1000);
+ }
+ }
+
+ // ÏÔʾµ±Ç°Éý¼¶×´Ì¬
+ function sf_showFotaUpgradeStatus() {
+ var s_data = service.getMandatory();
+ var s_isMandatory = s_data.is_mandatory;
+ var s_sizeInfo =service.getPackSizeInfo();
+ var s_percents;
+
+ if (parseInt(s_sizeInfo.fota_pkg_total_size) == 0) {
+ s_percents = 0;
+ } else {
+ s_percents = parseInt(parseInt(s_sizeInfo.fota_dl_pkg_size) * 100 / parseInt(s_sizeInfo.fota_pkg_total_size));
+ }
+ if (s_percents > 100) {
+ s_percents = 100;
+ }
+
+ if (s_isMandatory) {
+ showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
+ } else {
+ var cancelHtml = "";
+ if (config.UPGRADE_TYPE == "OTA") {
+ cancelHtml = "<br/><br/><button id='btnStopUpgrade' onclick='stopOTAUpgrade();' class='btn-1 btn-primary'>" + $.i18n.prop("cancel") + "</button>";
+ }
+ showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning") + cancelHtml);
+ }
+
+ //setProgressBar(0);
+ if (s_percents >= 0) {
+ setProgressBar(s_percents);
+ }
+ }
+
+
+
+
+
+ function sf_startFotaUpgrade(){
+ service.setUpgradeSelectOp({selectOp:'1'},function(result){
+ if (result.result == "success"){
+ sf_showFotaCurrentStatus();
+ }});
+ }
+
+ function cancelFotaUpgrade(){
+ service.setUpgradeSelectOp({selectOp:'0'},function(result){ });
+ }
+
+
+ function refreshFotaStatusForUserSelector(choice){
+ var info = getCurrentStatusInfo();
+ if(choice){
+ var modeData = service.getOpMode();
+ if (!checkConnectedStatus(info.connectStatus, modeData.rj45_state, info.connectWifiStatus)) {
+ showAlert("ota_network_disconnected");
+ return;
+ }
+
+ if(info.fota_user_selector == 'none'){
+ sf_startFotaUpgrade();
+ }else if(info.fota_user_selector == 'accept'){
+ sf_showFotaCurrentStatus();
+ }else if(info.fota_user_selector == 'cancel'){
+ showAlert("ota_have_cancel");
+ }else if(info.fota_user_selector == 'downloading_cancel'){
+ showAlert("ota_have_cancel");
+ }
+ }else{
+ if(info.fota_user_selector == 'none'){
+ cancelFotaUpgrade();
+ }else if(info.fota_user_selector == 'accept'){
+ sf_showFotaCurrentStatus();
+ }else if(info.fota_user_selector == 'cancel'){
+ // todo:
+ }else if(info.fota_user_selector == 'downloading_cancel'){
+ // todo:
+ }
+ }
+ }
+
+
+ // ÏÔʾÓÐа汾»òÏÂÔØÖжÏÊÇ·ñ¼ÌÐøÌáʾ
+ function showFotaStatusForUserToConfirm(upgradeState) {
+ var upgState = upgradeState.current_upgrade_state;
+ if (upgState == 'upgrade_pack_redownload') {
+ showConfirm("ota_interrupted", {ok: function () {
+ refreshFotaStatusForUserSelector(1);
+ }, no: function () {
+ refreshFotaStatusForUserSelector(0);
+ }});
+ } else {
+ var upgradingState = ["prepare_install", "low_battery",
+ "connecting_server", "connect_server_success", "downloading", "accept"];
+ if ($.inArray(upgState, upgradingState) != -1) {
+ sf_showFotaCurrentStatus();
+ } else {
+
+ showConfirm($.i18n.prop('ota_new_version'), {ok: function () {
+ refreshFotaStatusForUserSelector(1);
+ config.ISNOW_NOTICE = false;
+ }, no: function () {
+ refreshFotaStatusForUserSelector(0);
+ config.ISNOW_NOTICE = false;
+ }});
+ }
+ }
+ }
+
+ showOTAAlert = function () {
+ config.ISNOW_NOTICE = true;
+ var is_mandatory = service.getMandatory().is_mandatory;
+ if (is_mandatory) {
+ sf_showFotaCurrentStatus();
+ } else {
+ var upgradeState = {};
+ upgradeState = service.getCurrentUpgradeState();
+ showFotaStatusForUserToConfirm(upgradeState);
+ }
+ };
+
+ // ÖÕÖ¹FotaÉý¼¶
+ stopOTAUpgrade = function () {
+ service.setUpgradeSelectOp({selectOp:'2'},function(result){ });
+ sv_fotaUpdateCancel = false;
+ window.clearTimeout(sv_timer);
+ hideLoading();
+ showAlert('ota_cancel');
+ };
+
+ // ÉèÖÃÁ÷Á¿ÌáÐÑÊÇ·ñÌáÐѹý
+ function setTrafficAlertPopuped(val){
+ sv_trafficAlertPopuped = !!val;
+ sv_trafficAlertPopuped_100 = !!val;
+ if(!val){
+ sv_resetTrafficAlertPopuped = true;
+ }
+ }
+
+ function setTrafficAlert100Popuped(val){
+ sv_trafficAlertPopuped_100 = !!val;
+ if(!val){
+ sv_resetTrafficAlertPopuped = true;
+ }
+ }
+
+ // ¼ÆËãÁ÷Á¿½á¹¹
+ function getTrafficResult(info){
+ var s_trafficResult = {
+ showConfirm : false,
+ limitPercent : info.limitVolumePercent
+ };
+ if(info.limitVolumeType == '1'){
+ var monthlyTraffic = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
+ s_trafficResult.usedPercent = monthlyTraffic / info.limitVolumeSize * 100;
+ if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
+ s_trafficResult.showConfirm = true;
+ s_trafficResult.type = 'data';
+ }
+ }else{
+ s_trafficResult.usedPercent = info.data_counter.monthlyConnectedTime / info.limitVolumeSize * 100;
+ if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
+ s_trafficResult.showConfirm = true;
+ s_trafficResult.type = 'time';
+ }
+ }
+ return s_trafficResult;
+ }
+
+ // ³õʼ»¯ ViewModel£¬²¢½øÐÐÊÓͼ°ó¶¨
+ function init() {
+ if(config.PRODUCT_TYPE == 'DATACARD') {
+ $('#statusBar').addClass('padding-right-90');
+ $('#language').addClass('data-card-language');
+ }
+ //preload img
+ var imgAlert = $('<img />').attr('src', 'pic/res_alert.png');
+ var imgConfirm = $('<img />').attr('src', 'pic/res_confirm.png');
+ var imgInfo = $('<img />').attr('src', 'pic/res_info.png');
+
+ window.setTimeout(function () {
+
+ var fwVm = new statusViewModel();
+
+ ko.applyBindings(fwVm, $('#statusBar')[0]);
+
+ window.setInterval(function () {
+ var info = getCurrentStatusInfo();
+ var s_roamStatus = info.roamingStatus ? true : false;
+ var $langLogoBar = $("#langLogoBar");
+ isLoggedIn = info.isLoggedIn;
+
+
+ //fwVm.attachedDevices(info.attachedDevices);
+ fwVm.batteryLevel(info.batteryLevel + '%');
+ fwVm.batteryPers(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
+ fwVm.batteryStatus(info.batteryStatus);
+ fwVm.isShowFotaNewversionIcon(info.new_version_state && info.fota_user_selector && info.fota_package_already_download != "yes" && config.ISNOW_NOTICE && fwVm.updateType() == 'mifi_fota');
+ fwVm.isShowRj45ConnectionIcon(config.RJ45_SUPPORT);
+ fwVm.networkOperator(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,s_roamStatus));
+ fwVm.networkType(getNetworkType(info.networkType));
+ fwVm.pinStatus(info.pinStatus);
+ fwVm.roamingStatus(info.roamingStatus ? "R" : "");
+ fwVm.showAttachedDevices(info.wifiStatus);
+ fwVm.simStatus(sf_convertSimStatusToImage(info.simStatus));
+ fwVm.signalCssClass(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
+ fwVm.isLoggedIn(info.isLoggedIn);
+ fwVm.wifiStatusCssClass(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
+ fwVm.wifiStatusImg(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
+
+ if(config.HAS_SMS ){
+ if(!sv__hasCheckedSMSCapacity && info.isLoggedIn){
+ checkSMSCapacity(info.smsUnreadCount);
+ } else {
+ fwVm.smsUnreadCount(info.smsUnreadCount);
+ }
+ }
+
+ sf_getConnectionCssClass(fwVm, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
+ refreshWifiConnectStatus(fwVm, info.connectStatus,info.connectWifiSSID,info.connectWifiStatus);
+ checkTrafficLimitAlert(fwVm, info);
+ updateStatusBarTrans({simStatus: info.simStatus, wifiStatus: info.wifiStatus, deviceSize: info.wirelessDeviceNum, networkType: info.networkType});
+
+ if(info.isLoggedIn){
+ $("#statusBar:hidden").show();
+ } else {
+ $("#statusBar:visible").hide();
+ }
+ }, 500);
+
+ if(config.HAS_SMS){
+ window.setInterval(function(){
+ if(fwVm.isLoggedIn()){
+ checkSMSCapacity();
+ }
+ }, 10000);
+ checkSmsModelReady();
+ }
+
+ window.setInterval(function() {
+ var data = getCurrentStatusInfo();
+ var upgradingState = ["prepare_install", "low_battery", "download_success","downloading"];
+
+ if (fwVm.isLoggedIn() == true && !($("#progress").is(":visible")) && data.defaultWanName != ""){
+ if ($.inArray(data.current_upgrade_state, upgradingState) != -1){
+ if(null == sv_fotaUpdateCancel){
+ if(!data.is_mandatory){
+ $.modal.close();
+ }
+ sf_showFotaCurrentStatus();
+ }else if(false == sv_fotaUpdateCancel){
+ sv_fotaUpdateCancel = null;
+ }
+ }
+ }
+ }, 1000);
+
+ var checkFotaUpgradeResult = function () {
+ var info = service.getStatusInfo();
+ if (info.isLoggedIn) {
+ service.getUpgradeResult({}, function (data) {
+ if (data.upgrade_result == "success") {
+ sf_showFotaUpdateResult(true);
+ } else if (data.upgrade_result == "fail") {
+ sf_showFotaUpdateResult(false);
+ } else {
+ window.setTimeout(checkFotaUpgradeResult, 1000);
+ }
+ }, function () {
+ window.setTimeout(checkFotaUpgradeResult, 1000);
+ });
+ } else {
+ window.setTimeout(checkFotaUpgradeResult, 1000);
+ }
+ };
+ if(fwVm.updateType() == "mifi_fota"){
+ checkFotaUpgradeResult();
+ window.setInterval(function () {
+ var info = getCurrentStatusInfo();
+ if (info.isLoggedIn && info.defaultWanName != "") {
+ if(info.new_version_state && info.fota_package_already_download != "yes" && !config.ALREADY_NOTICE){
+ service.getUpgradeResult({}, function (data) {
+ if (data.upgrade_result == "success") {
+ sf_showFotaUpdateResult(true);
+ } else if (data.upgrade_result == "fail") {
+ sf_showFotaUpdateResult(false);
+ } else {
+ if(sv_fotaResultAlertPopuped == false){
+ config.ALREADY_NOTICE = true;
+ showOTAAlert();
+ }
+ }
+ });
+ }
+ }
+ }, 1000);
+ }
+ function checkSMSCapacity(unreadCount){
+ service.getSmsCapability({}, function(info){
+ var showSmsConfirm = false;
+ if(info.nvTotal != 0 && info.nvUsed >= info.nvTotal){
+ $("#sms_unread_count").attr("tipTitle", "sms_capacity_is_full");
+ showSmsConfirm = true;
+ } else if(info.nvTotal != 0 && info.nvUsed + 5 >= info.nvTotal) {
+ $("#sms_unread_count").attr("tipTitle", "sms_capacity_will_full");
+ showSmsConfirm = true;
+ } else {
+ $("#sms_unread_count").attr("tipTitle", "sms_unread_count");
+ }
+ fwVm.showSmsDeleteConfirm(showSmsConfirm);
+ if(typeof unreadCount != "undefined"){
+ fwVm.smsUnreadCount(unreadCount);
+ }
+ sv__hasCheckedSMSCapacity = true;
+ });
+ }
+ }, 1200);
+
+ tooltip.init();
+
+ // ¼ì²é¶ÌϢģ¿é³õʼ»¯×´Ì¬
+ function checkSmsModelReady(){
+ var info = getCurrentStatusInfo();
+ if(info.isLoggedIn){
+ service.getSMSReady({}, function (data) {
+ if (data.sms_cmd_status_result == "1") {
+ window.setTimeout(function(){checkSmsModelReady();}, 1000);
+ } else {
+ sv__initSMSCompleted = true;
+ }
+ });
+ } else {
+ window.setTimeout(function(){checkSmsModelReady();}, 1000);
+ }
+ }
+
+ // ¼ì²éä¯ÀÀÌáÐÑ״̬
+ checkTrafficLimitAlert = function(fwVm, info){
+ if(window.location.hash == '#entry'){
+ return false;
+ }
+ var APStationEnabled = config.AP_STATION_SUPPORT ? service.getStatusInfo().ap_station_enable : 'undefined';
+ var trafficResult = getTrafficResult(info);
+ var inShow = $("#confirm-container:visible").length > 0;
+ var notPPP = (config.PRODUCT_TYPE == 'CPE' && checkCableMode(info.blc_wan_mode)) ? true : false;
+
+ // »ñÈ¡Ap StationʹÄÜ״̬£¬ÉèÖÃÌáÐÑ·½Ê½
+ if (config.AP_STATION_SUPPORT && (typeof APStationEnabled == "undefined" || APStationEnabled === '')) {
+ service.refreshAPStationStatus({}, $.noop());
+ return false;
+ }
+ APStationEnabled = APStationEnabled == 1;
+
+ if (!info.isLoggedIn || inShow || (sv_trafficAlertPopuped && sv_trafficAlertPopuped_100) || !info.limitVolumeEnable || (!APStationEnabled && !(info.connectStatus == "ppp_connected")) || notPPP) {
+ return false;
+ }
+
+ if(sv_resetTrafficAlertPopuped){
+ window.setTimeout(function () {
+ sv_resetTrafficAlertPopuped = false;
+ }, 2000);
+ return false;
+ }
+
+ if(trafficResult.showConfirm){
+
+ var confirmMessage = null;
+
+ if(trafficResult.usedPercent > 100 && !sv_trafficAlertPopuped_100){
+
+ sv_trafficAlertPopuped = true;
+ sv_trafficAlertPopuped_100 = true;
+
+ confirmMessage = {msg: APStationEnabled ? 'traffic_beyond_msg' : 'traffic_beyond_disconnect_msg'};
+
+ } else if (!sv_trafficAlertPopuped) {
+
+ sv_trafficAlertPopuped = true;
+ sv_trafficAlertPopuped_100 = false;
+ confirmMessage = {msg: APStationEnabled ? 'traffic_limit_msg' : 'traffic_limit_disconnect_msg',
+ params: [trafficResult.limitPercent]};
+ }
+
+ if (confirmMessage != null) {
+ if (APStationEnabled) {
+ showAlert(confirmMessage);
+ } else {
+ showConfirm(confirmMessage, function () {
+ showLoading("disconnecting");
+ service.disconnect({}, function (data) {
+ if (data.result) {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ });
+ }
+ }
+ }
+ return true;
+ };
+
+ // ¸üÐÂ״̬ÖеÄtooltip
+ function updateStatusBarTrans(status){
+ $("#statusItemSimStatus").attr("tipTitle", "sim_status_" + status.simStatus);
+ if (status.wifiStatus) {
+ if (status.deviceSize == 0) {
+ $("#wifi_status").attr("tipTitle","wifi_status_on");
+ } else {
+ $("#wifi_status").attr("tipTitle","wifi_status" + status.deviceSize);
+ }
+ } else {
+ $("#wifi_status").attr("tipTitle","wifi_status_off");
+ }
+ }
+
+
+ // Ë¢ÐÂwifiÍøÂçÁ¬½Ó״̬
+ function refreshWifiConnectStatus(fwVm, status, wifiSSID, wifiStatus) {
+ fwVm.connectStatus(status);
+ if (status == "ppp_disconnecting") {
+ fwVm.connectStatusTrans("disconnecting");
+ fwVm.connectStatusText($.i18n.prop("disconnecting"));
+ } else if (status == "ppp_connecting") {
+ fwVm.connectStatusTrans("connecting");
+ fwVm.connectStatusText($.i18n.prop("connecting"));
+ } else if (status == "ppp_connected") {
+ fwVm.connectStatusTrans("connected");
+ fwVm.connectStatusText($.i18n.prop("connected"));
+ } else if(wifiSSID){
+ if(wifiStatus =="dhcping" || wifiStatus =="connecting"){
+ fwVm.connectStatus("wifi_connecting");
+ fwVm.connectStatusTrans("connecting");
+ fwVm.connectStatusText($.i18n.prop("connecting"));
+ }else if(wifiStatus =="connect"){
+ fwVm.connectStatus("wifi_connect");
+ fwVm.connectStatusTrans("connected");
+ fwVm.connectStatusText($.i18n.prop("connected"));
+ }else{
+ fwVm.connectStatus("ppp_disconnected");
+ fwVm.connectStatusTrans("disconnected");
+ fwVm.connectStatusText($.i18n.prop("disconnected"));
+ }
+ }else{
+ fwVm.connectStatusTrans("disconnected");
+ fwVm.connectStatusText($.i18n.prop("disconnected"));
+ }
+ }
+
+ // »ñÈ¡µ±Ç°ÍøÂç״̬
+ getNetworkType = function(networkType) {
+ var networkTypeTmp = networkType.toLowerCase();
+ if (networkTypeTmp == '' || networkTypeTmp == 'limited service') {
+ networkTypeTmp = 'limited_service';
+ }
+ if(networkTypeTmp == 'no service') {
+ networkTypeTmp = 'no_service';
+ }
+ if (networkTypeTmp == 'limited_service' || networkTypeTmp == 'no_service') {
+ $("#networkType", "#statusBar").attr("data-trans", "network_type_" + networkTypeTmp);
+ return $.i18n.prop("network_type_" + networkTypeTmp);
+ } else {
+ $("#networkType", "#statusBar").removeAttr("data-trans");
+ return networkType;
+ }
+ };
+
+ if(config.HAS_SMS && menu.checkIsMenuExist("sms_list")){
+ window.setInterval(function () {
+ var info = getCurrentStatusInfo();
+ if(window.location.hash == "#entry" || sf_simStatusInvalid(info.simStatus)){
+ return;
+ }
+ for(key in sv_messagePopStack){
+ var val = sv_messagePopStack[key];
+ if($.now() - val > 5000){
+ delete(sv_messagePopStack["m" + val]);
+ var node = $(".bubbleItem#m" + val, "#buttom-bubble");
+ node.fadeOut(1000, function(){
+ $(this).remove();
+ });
+ }
+ }
+ if(info.isLoggedIn){
+ if(info.newSmsReceived && !sv_newSMSMessageInDealing){
+ sv_newSMSMessageInDealing = true;
+ service.resetNewSmsReceivedVar();
+ sf_checkNewMessages();
+ }
+ if(info.smsReportReceived){
+ service.resetSmsReportReceivedVar();
+ sf_responseSmsReport();
+ }
+ }
+ }, 1000);
+
+ if(config.SMS_DATABASE_SORT_SUPPORT){
+ window.setInterval(function(){
+ if(menu.checkIsMenuExist("sms_list")){
+ var info = getCurrentStatusInfo();
+ if(info.isLoggedIn && sv__initSMSCompleted && !sv_newSMSMessageInDealing && !sf_simStatusInvalid(info.simStatus)){
+ sv_newSMSMessageInDealing = true;
+ sf_checkNewMessages();
+ }
+ }
+ }, 20001);
+ }
+ }
+
+ function sf_checkNewMessages(){
+
+ var s_tags = 1;
+ var s_smsCount = 5;
+
+ if(!config.dbMsgs || config.dbMsgs.length == 0){
+ s_smsCount = 500;
+ s_tags = 10;
+ }
+ service.getSMSMessages({
+ page : 0,
+ smsCount : s_smsCount,
+ nMessageStoreType : 0,
+ tags : s_tags,
+ orderBy : "order by id desc"
+ }, function(data){
+ if(data && data.messages){
+ sf_filterNewMessage(data.messages, 0);
+ }
+ sv_newSMSMessageInDealing = false;
+ });
+ service.getSMSMessages({
+ page : 0,
+ smsCount : s_smsCount,
+ nMessageStoreType : 1,
+ tags : s_tags,
+ orderBy : "order by id desc"
+ }, function(data){
+ if(data && data.messages){
+ sf_filterNewMessage(data.messages, 1);
+ }
+ sv_newSMSMessageInDealing = false;
+ });
+ }
+
+ if(config.HAS_SMS){
+ $(".bubbleItem", "#buttom-bubble").live("mouseover", function(){
+ var $this = $(this);
+ delete(sv_messagePopStack[$this.attr("id")]);
+ }).live("mouseout", function(){
+ var $this = $(this);
+ var now = $.now();
+ sv_messagePopStack["m" + now] = now;
+ $this.attr("id", "m" + now);
+ $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").data("targetid", "m" + now);
+ });
+
+ $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").die().live("click", function(){
+ var id = $(this).data("targetid");
+ delete(sv_messagePopStack[id]);
+ var node = $(".bubbleItem#" + id, "#buttom-bubble");
+ node.fadeOut(1000, function(){
+ $(this).remove();
+ });
+ });
+ }
+ }
+
+
+ return {
+ init:init,
+ setTrafficAlertPopuped: setTrafficAlertPopuped,
+ setTrafficAlert100Popuped: setTrafficAlert100Popuped,
+ getTrafficResult: getTrafficResult,
+ showOTAAlert:showOTAAlert
+ };
+});
+
+// Á÷Á¿Í³¼ÆÌáÐÑÄ£¿é
+define("status_traffic_alert","jquery knockout service statusBar echarts".split(" "),
+
+ function ($, ko, service, status, echarts) {
+
+ var sv_trafficGraph = null;
+ var sv_sourceData = null;
+ var sv_usedDataModified = false;
+ var sv_usedTimeModified = false;
+
+ var sv_trafficStaticalInfo = {
+ // Á÷Á¿Í¼³õʼֵ
+ data: {
+ alarm: {
+
+ itemStyle: {
+ normal: {
+ color: '#8CC916'
+ }
+ },
+ name: '¾¯½äÇø',
+ value: 19.7
+ },
+ alert: {
+
+ itemStyle: {
+ normal: {
+ color: '#FF5500'
+ }
+ },
+ name: 'ÌáÐÑÖµ',
+ value: 1
+ },
+ free: {
+
+ itemStyle: {
+ normal: {
+ color: '#D8D8D8'
+ }
+ },
+ name: 'δʹÓÃ',
+ value: 50
+ },
+ full: {
+
+
+ itemStyle: {
+ normal: {
+ color: '#DF4313'
+ }
+ },
+ name: 'Á÷Á¿³¬³ö',
+ value: 30
+ },
+ left1: {
+
+ itemStyle: {
+ normal: {
+ color: '#D8D8D8'
+ }
+ },
+ name: 'ÌáÐÑÖµÄÚδʹÓÃ',
+ value: 50,
+ },
+ start: {
+
+ itemStyle: {
+ normal: {
+ color: '#D8D8D8'
+ }
+ },
+ name: 'ÌáÐÑÖµÄÚδʹÓÃ',
+ value: 50
+ },
+ used: {
+
+ itemStyle: {
+ normal: {
+ color: '#8CC916'
+ }
+ },
+ name: 'ÒÑʹÓÃ',
+ value: 30
+ }
+ },
+ cacheEle: {},
+ // ÔªËØ»ñÈ¡
+ getEle: function (i_elementId) {
+ if (this.cacheEle.hasOwnProperty('id')) {
+ return this.cacheEle[i_elementId];
+ } else {
+ this.cacheEle[i_elementId] = $("#" + i_elementId);
+ return this.cacheEle[i_elementId];
+ }
+ },
+ // »ñÈ¡Á÷Á¿¸æ¾¯×´Ì¬Öµ
+ fetchTrafficAlertInfo: function(){
+ sv_sourceData = getTrafficAlertInfo();
+ return sv_sourceData;
+ },
+ // »ñÈ¡Á÷Á¿ÖµºÍ¶ÔÓ¦µ¥Î»Öµ
+ getTrafficStatisticalDatalnfo: function (i_valueInfo) {
+ return {
+ data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
+ unit: /[A-Z]{1,2}/.exec(i_valueInfo)[0]
+ }
+ },
+
+ // »ñȡʱ¼äʱ¡¢·Ö¡¢Ãë
+ getTrafficTimeHours: function (i_time) {
+ var s_timeArray = i_time.split(':');
+ return {
+ h: parseInt(s_timeArray[0], 10),
+ m: parseInt(s_timeArray[1], 10),
+ s: parseInt(s_timeArray[2], 10)
+ }
+ },
+ // »ñȡͳ¼ÆÊ±¼äºÍ¶ÔÓ¦µ¥Î»Öµ
+ getTrafficTimeInfo: function (i_valueInfo) {
+ return {
+ data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
+ unit: /[a-z]{4,6}/.exec(i_valueInfo)[0]
+ }
+ },
+ // ʱ¼ä»»Ëã³ÉS
+ getTrafficTimeToSeconds: function (i_time) {
+ var s_FormattedTime = this.getTrafficTimeHours(i_time);
+ return s_FormattedTime.h * 3600 + s_FormattedTime.m * 60 + s_FormattedTime.s;
+ },
+ // ͨ¹ý½øÖÆ»ñÈ¡Á÷Á¿µ¥Î»
+ getTrafficUnitByScale: function (i_scale) {
+ if (i_scale == '1024') {
+ return 'GB';
+ } else if (i_scale == '1048576') {
+ return 'TB';
+ } else {
+ return 'MB';
+ }
+ },
+ // µ¥Î»¶ÔÓ¦Öµ»ñÈ¡
+ getTrafficValueByStatisticalUnit: function (i_unit) {
+ i_unit = i_unit.toLowerCase();
+ if(i_unit == 'minute'){
+ return '60';
+ } else if (i_unit == 'gb') {
+ return '1024';
+ } else if(i_unit == 'hour'){
+ return '3600';
+ } else if (i_unit == 'tb') {
+ return '1048576';
+ } else {
+ return '1';
+ }
+ },
+
+ // ¼ì²é±íµ¥ÊÇ·ñ¿É±à¼
+ isFormEditable: function (fwVm) {
+ var s_dataPageEditState = fwVm.dataLimitTypeChecked() == '1' && (fwVm.viewEditUsedData() || fwVm.viewEditAlertData() || fwVm.viewEditTotalData());
+ var s_timePageEditState = fwVm.dataLimitTypeChecked() == '0' && (fwVm.viewEditUsedTime() || fwVm.viewEditAlertTime() || fwVm.viewEditTotalTime());
+ if (s_dataPageEditState || s_timePageEditState) {
+ $('.border-color-transition:visible').addClass('attention-focus');
+ addTimeout(function () {
+ $('.border-color-transition:visible').removeClass('attention-focus');
+ }, 1500);
+ return true;
+ } else {
+ var s_result = false;
+ if (fwVm.dataLimitTypeChecked() == 1) {
+ if (fwVm.alertDataReach() == '0') {
+ fwVm.editAlertDataHandler();
+ s_result = true;
+ }
+ if (fwVm.limitDataMonth() == '0') {
+ fwVm.editTotalDataHandler();
+ s_result = true;
+ }
+ } else {
+ if (fwVm.alertTimeReach() == '0') {
+ fwVm.editAlertTimeHandler();
+ s_result = true;
+ }
+ if (fwVm.limitTimeMonth() == '0') {
+ fwVm.editTotalTimeHandler();
+ s_result = true;
+ }
+ }
+
+ if (s_result) {
+ $('.border-color-transition:visible').addClass('attention-focus');
+ addTimeout(function () {
+ $('.border-color-transition:visible').removeClass('attention-focus');
+ }, 1500);
+ }
+ return s_result;
+ }
+ },
+
+ // Ë¢ÐÂÁ÷Á¿Í¼ÐÅÏ¢£¬Èç¸÷ÇøÓòÊýÖµ¡¢ÌáʾÓïµÈ
+
+ refreshFlowDiagramInfo: function (fwVm) {
+ var s_alarm = 0;
+ var s_left = 0;
+ var s_left1 = 0;
+ var s_reach = 0;
+ var s_total = 0;
+ var s_used = 0;
+
+
+ var s_startName = $.i18n.prop("echarts_no");
+
+ if (sv_sourceData.dataLimitChecked == '1') { //if (fwVm.dataLimitChecked() == '1') { //¿ªÆô
+ s_startName = $.i18n.prop("echarts_used");
+ sv_trafficGraphOptions.series[0].data = [];
+
+ if (fwVm.dataLimitTypeChecked() == '1') { // Êý¾Ý
+ sv_trafficGraphOptions.title.text = "";
+ sv_trafficGraphOptions.series[0].data = [];
+
+ if (fwVm.limitDataMonth() == 0) {
+ var s_usedData = sv_trafficStaticalInfo.data.used;
+ s_usedData.value = 1;
+ s_usedData.name = $.i18n.prop("echarts_used");
+ s_usedData.selected = false;
+ sv_trafficGraphOptions.series[0].data.push(s_usedData);
+ } else {
+ s_total = fwVm.limitDataMonth() * fwVm.selectedDataUnit() * 1048576;
+ s_used = parseInt(sv_sourceData.monthlySent, 10) + parseInt(sv_sourceData.monthlyReceived, 10);
+ s_reach = s_total * fwVm.alertDataReach() / 100;
+
+ if (s_used >= s_total) {
+ var s_fullData = sv_trafficStaticalInfo.data.full;
+ s_fullData.value = 100;
+ s_fullData.name = $.i18n.prop("echarts_full");
+ sv_trafficGraphOptions.series[0].data.push(s_fullData);
+ s_startName = $.i18n.prop("echarts_full");
+ } else {
+ if (s_reach > s_used) {
+ s_left1 = s_reach - s_used;
+ s_left = s_total - s_reach;
+ } else {
+ s_alarm = s_used - s_reach;
+ s_left = s_total - s_used;
+ }
+
+ var s_usedData = sv_trafficStaticalInfo.data.used;
+ if (s_reach - s_used > 0) {
+ s_usedData.value = s_used;
+ } else {
+ s_usedData.value = s_reach;
+ }
+ s_usedData.name = $.i18n.prop("echarts_used");
+ sv_trafficGraphOptions.series[0].data.push(s_usedData);
+
+ if (s_left1 > 0) {
+ var s_left1Data = sv_trafficStaticalInfo.data.left1;
+ s_left1Data.value = s_left1;
+ s_left1Data.name = $.i18n.prop("echarts_left1");
+ sv_trafficGraphOptions.series[0].data.push(s_left1Data);
+ }
+
+ var s_alertData = sv_trafficStaticalInfo.data.alert;
+ s_alertData.value = s_total / 200;
+ s_alertData.name = $.i18n.prop("echarts_alert");
+ sv_trafficGraphOptions.series[0].data.push(s_alertData);
+
+ if (s_alarm > 0) {
+ var s_alarmData = sv_trafficStaticalInfo.data.alarm;
+ s_alarmData.value = s_alarm;
+ s_alarmData.name = $.i18n.prop("echarts_alarm");
+ sv_trafficGraphOptions.series[0].data.push(s_alarmData);
+ }
+
+ var s_freeData = sv_trafficStaticalInfo.data.free;
+ s_freeData.value = s_left;
+ s_freeData.name = $.i18n.prop("echarts_free");
+ sv_trafficGraphOptions.series[0].data.push(s_freeData);
+ }
+ }
+
+ }else{// ʱ¼ä
+
+ sv_trafficGraphOptions.series[0].data = [];
+
+ if (fwVm.limitTimeMonth() == 0) {
+ var s_usedData = sv_trafficStaticalInfo.data.used;
+ s_usedData.value = 1;
+ s_usedData.selected = false;
+ s_usedData.name = $.i18n.prop("echarts_used");
+ sv_trafficGraphOptions.series[0].data.push(s_usedData);
+ } else {
+ s_total = fwVm.limitTimeMonth() * fwVm.selectedTimeUnit();
+ s_used = sv_sourceData.monthlyConnectedTime;
+ s_reach = s_total * fwVm.alertTimeReach() / 100;
+
+ if (s_used >= s_total) {
+ var fullTime = sv_trafficStaticalInfo.data.full;
+ fullTime.value = 100;
+ fullTime.name = $.i18n.prop("echarts_full");
+ sv_trafficGraphOptions.series[0].data.push(fullTime);
+ s_startName = $.i18n.prop("echarts_full");
+ } else {
+ if (s_reach - s_used > 0) {
+ s_left1 = s_reach - s_used;
+ s_left = s_total - s_reach;
+ } else {
+ s_alarm = s_used - s_reach;
+ s_left = s_total - s_used;
+ }
+
+ var s_usedTime = sv_trafficStaticalInfo.data.used;
+ if (s_reach - s_used > 0) {
+ s_usedTime.value = s_used;
+ } else {
+ s_usedTime.value = s_reach;
+ }
+ s_usedTime.name = $.i18n.prop("echarts_used");
+ sv_trafficGraphOptions.series[0].data.push(s_usedTime);
+
+ if (s_left1 > 0) {
+ var s_left1Time = sv_trafficStaticalInfo.data.left1;
+ s_left1Time.value = s_left1;
+ s_left1Time.name = $.i18n.prop("echarts_left1");
+ sv_trafficGraphOptions.series[0].data.push(s_left1Time);
+ }
+
+ var s_alertTime = sv_trafficStaticalInfo.data.alert;
+ s_alertTime.value = s_total / 200;
+ s_alertTime.name = $.i18n.prop("echarts_alert");
+ sv_trafficGraphOptions.series[0].data.push(s_alertTime);
+
+ if (s_alarm > 0) {
+ var s_alarmTime = sv_trafficStaticalInfo.data.alarm;
+ s_alarmTime.value = s_alarm;
+ s_alarmTime.name = $.i18n.prop("echarts_alarm");
+ sv_trafficGraphOptions.series[0].data.push(s_alarmTime);
+ }
+
+ var s_freeTime = sv_trafficStaticalInfo.data.free;
+ s_freeTime.value = s_left;
+ s_freeTime.name = $.i18n.prop("echarts_free");
+ sv_trafficGraphOptions.series[0].data.push(s_freeTime);
+ }
+ }
+ }
+ } else {
+ var s_usedData = sv_trafficStaticalInfo.data.used;
+ s_usedData.value = 1;
+ s_usedData.selected = false;
+ s_usedData.name = $.i18n.prop("echarts_no");
+
+ sv_trafficGraphOptions.series[0].data = [s_usedData];
+ sv_trafficGraphOptions.title.text = '';
+ }
+ sv_trafficStaticalInfo.setFlowDiagramInfo(sv_trafficGraphOptions, s_startName);
+ },
+
+
+ // ÖØ»æÁ÷Á¿Í¼
+ setFlowDiagramInfo: function (i_options, i_startName) {
+ var s_startPart = sv_trafficStaticalInfo.data.start;
+
+ s_startPart.name = i_startName;
+ s_startPart.selected = false;
+ s_startPart.value = 0;
+
+ var s_arr = [s_startPart].concat(i_options.series[0].data);
+ i_options.series[0].data = s_arr;
+ sv_trafficGraph.setOption(i_options, true);
+
+ addTimeout(function () {
+ sv_trafficGraph.resize();
+ }, 1000);
+ }
+ };
+
+
+ // Á÷Á¿Í¼»ù±¾ÅäÖÃ
+ var sv_trafficGraphOptions = {
+ animation: false,
+ color: ['red', 'red', 'red', 'red', 'red'],
+ series: [
+ {
+ name: 'Á÷Á¿¿ØÖÆ',
+ radius: ['0', '75'],
+ selectedOffset: 3,
+ type: 'pie',
+ data: [
+
+ ],
+ itemStyle: {
+ normal: {
+ labelLine: {
+ show: false
+ },
+ label: {
+ show: false
+ }
+ }
+ }
+ }
+ ],
+ title: {
+ itemGap: 0,
+ text: '',
+ subtextStyle: {
+ color: '#FFF',
+ fontFamily: '΢ÈíÑźÚ',
+ fontSize: 16,
+ fontWeight: 'bolder'
+ },
+ textStyle: {
+ color: '#FFF',
+ fontFamily: '΢ÈíÑźÚ',
+ fontSize: 20,
+ fontWeight: 'bolder'
+ },
+ x: 'center',
+ y: 'center'
+ },
+ tooltip: {
+ formatter: "{b}"
+ }
+ };
+
+
+ // »ñÈ¡Á÷Á¿ÌáÐÑÊý¾Ý
+ function getTrafficAlertInfo() {
+ return service.getTrafficAlertInfo();
+ }
+
+
+
+ // Á÷Á¿ÌáÐÑViewModel
+
+ function trafficViewModel() {
+
+ var target = this;
+
+ var info = sv_trafficStaticalInfo.fetchTrafficAlertInfo();
+ var dataMonth = info.limitDataMonth.split("_");
+
+ sv_usedDataModified = false;
+ sv_usedTimeModified = false;
+
+ target.alertDataReach = ko.observable(info.alertDataReach || 0);
+ target.alertTimeReach = ko.observable(info.alertTimeReach || 0);
+ target.dataLimitChecked = ko.observable(info.dataLimitChecked == '0' ? '0' : '1');
+ target.dataLimitTypeChecked = ko.observable(info.dataLimitTypeChecked == '0' ? '0' : '1');
+ target.limitTimeMonth = ko.observable(info.limitTimeMonth || 0);
+
+
+ // ×¢Òâ˳Ðò
+ target.usedDataText = ko.observable(transUnit(parseInt(info.monthlySent, 10) + parseInt(info.monthlyReceived, 10), false));
+ var sv_staticalDataInfo = sv_trafficStaticalInfo.getTrafficStatisticalDatalnfo(target.usedDataText());
+ var sv_staticalInfoData = sv_staticalDataInfo.data;
+ target.dataUsed = ko.observable(sv_staticalInfoData);
+ var sv_staticalInfoUnit = sv_staticalDataInfo.unit;
+ target.selectedDataUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_staticalInfoUnit));
+ target.usedDataTextDescData = ko.observable("");
+
+ target.limitDataMonth = ko.observable(dataMonth[0] || 0);
+ target.selectedDataUnit = ko.observable(dataMonth[1] || 1);
+
+ var limitDataMonthTmp = transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1024 * 1024, false);
+ var limitDataMonthUnitTmp = limitDataMonthTmp.substring(limitDataMonthTmp.length-2);
+ target.limitDataMonth(limitDataMonthTmp.substring(0, limitDataMonthTmp.length-2));
+ target.selectedDataUnit(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(limitDataMonthUnitTmp));
+
+ target.usedDataTextDesc = ko.computed(sf_usedDataTextDesc);
+ target.limitDataMonthDescData = ko.observable("");
+ target.limitDataMonthDesc = ko.computed(sf_limitDataMonthDesc);
+ target.alertDataReachDescData = ko.observable("");
+ target.alertDataReachDesc = ko.computed(sf_alertDataReachDesc);
+ target.leftDataDescData = ko.observable("");
+ target.leftDataDesc = ko.computed(sf_leftDataDesc);
+ target.monthlyConnectedTime = ko.observable(transSecond2Time(info.monthlyConnectedTime));
+
+ var sv_timeInfo1 = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(info.monthlyConnectedTime));
+ target.usedTime = ko.observable(sv_timeInfo1.data);
+ target.selectedTimeUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfo1.unit));
+
+ target.usedTimeTextDescData = ko.observable("");
+ target.usedTimeTextDesc = ko.computed(sf_usedTimeTextDesc);
+
+ var sv_timeInfoNew = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(parseFloat(target.limitTimeMonth()) * 3600));
+ target.selectedTimeUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfoNew.unit));
+ target.limitTimeMonth(sv_timeInfoNew.data);
+
+
+ target.limitTimeMonthDescData = ko.observable("");
+ target.limitTimeMonthDescText = ko.observable("traffic_limit_time_h");
+ target.limitTimeMonthDesc = ko.computed(sf_limitTimeMonthDesc);
+ target.alertTimeReachDescData = ko.observable("");
+ target.alertTimeReachDesc = ko.computed(sf_alertTimeReachDesc);
+ target.leftTimeDescData = ko.observable("");
+ target.leftTimeDesc = ko.computed(sf_leftTimeDesc);
+ target.save = sf_save;
+ target.viewEditUsedData = ko.observable(false);
+ target.editUsedDataHandler = sf_editUsedDataHandler;
+ target.editUsedDataSaveHandler = sf_editUsedDataSaveHandler;
+ target.saveUsedData = sf_saveUsedData;
+ target.editUsedDataCancelHandler = sf_editUsedDataCancelHandler;
+ target.viewEditTotalData = ko.observable(false);
+ target.editTotalDataHandler = sf_editTotalDataHandler;
+ target.editTotalDataSaveHandler = sf_editTotalDataSaveHandler;
+ target.editTotalDataCancelHandler = sf_editTotalDataCancelHandler;
+ target.viewEditAlertData = ko.observable(false);
+ target.editAlertDataHandler = sf_editAlertDataHandler;
+ target.editAlertDataSaveHandler = sf_editAlertDataSaveHandler;
+ target.editAlertDataCancelHandler = sf_editAlertDataCancelHandler;
+ target.viewEditUsedTime = ko.observable(false);
+ target.editUsedTimeHandler = sf_editUsedTimeHandler;
+ target.saveUsedTime = sf_saveUsedTime;
+ target.editUsedTimeSaveHandler = sf_editUsedTimeSaveHandler;
+ target.editUsedTimeCancelHandler = sf_editUsedTimeCancelHandler;
+ target.viewEditTotalTime = ko.observable(false);
+ target.editTotalTimeHandler = sf_editTotalTimeHandler ;
+ target.editTotalTimeSaveHandler = sf_editTotalTimeSaveHandler;
+ target.editTotalTimeCancelHandler = sf_editTotalTimeCancelHandler;
+ target.viewEditAlertTime = ko.observable(false);
+ target.editAlertTimeHandler = sf_editAlertTimeHandler;
+ target.editAlertTimeSaveHandler = sf_editAlertTimeSaveHandler;
+ target.editAlertTimeCancelHandler = sf_editAlertTimeCancelHandler;
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
+
+
+ // Á÷Á¿ÌáÐÑÃèÊöÓï
+ function sf_alertDataReachDesc() {
+ if(isNaN(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach())) {
+ target.alertDataReachDescData(target.alertDataReach() + ', ');
+ return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), ' ');
+ }
+
+ var s_value = transUnit(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach() * 1048576 / 100, false);
+ target.alertDataReachDescData(target.alertDataReach() + ',' + s_value);
+ return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), s_value);
+ }
+ // ʱ¼äÌáÐÑÃèÊöÓï
+ function sf_alertTimeReachDesc() {
+ if(isNaN(target.limitTimeMonth() * target.alertTimeReach())) {
+ target.alertTimeReachDescData(target.alertTimeReach() + ', ');
+ return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), ' ');
+ }
+ var s_value = transSecond2Time(target.limitTimeMonth() * target.selectedTimeUnit() * target.alertTimeReach() / 100);
+ target.alertTimeReachDescData(target.alertTimeReach() + ',' + s_value);
+ return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), s_value);
+ }
+
+
+ // Á÷Á¿ÌáÐÑֵȡÏû±à¼°´Å¥Ê¼þ
+ function sf_editAlertDataCancelHandler() {
+ target.alertDataReach(sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue'));
+ target.viewEditAlertData(false);
+ }
+
+ // Á÷Á¿ÌáÐÑÖµ±à¼°´Å¥Ê¼þ
+ function sf_editAlertDataHandler() {
+ sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue', target.alertDataReach());
+ target.viewEditAlertData(true);
+ }
+
+ // Á÷Á¿ÌáÐÑÖµ±£´æ±à¼°´Å¥Ê¼þ
+ function sf_editAlertDataSaveHandler() {
+ if (sv_trafficStaticalInfo.getEle('alertDataReach').valid()) {
+ target.viewEditAlertData(false);
+ }
+ }
+
+ // ʱ¼äÌáÐÑֵȡÏû±à¼°´Å¥Ê¼þ
+ function sf_editAlertTimeCancelHandler() {
+ target.alertTimeReach(sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue'));
+ target.viewEditAlertTime(false);
+ }
+ // ʱ¼äÌáÐÑÖµ±à¼°´Å¥Ê¼þ
+ function sf_editAlertTimeHandler() {
+ sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue', target.alertTimeReach());
+ target.viewEditAlertTime(true);
+ }
+ // ʱ¼äÌáÐÑÖµ±£´æ±à¼°´Å¥Ê¼þ
+ function sf_editAlertTimeSaveHandler() {
+ if (sv_trafficStaticalInfo.getEle('alertTimeReach').valid()) {
+ target.viewEditAlertTime(false);
+ }
+ }
+
+ // ÌײÍÁ÷Á¿±à¼°´Å¥Ê¼þ
+ function sf_editTotalDataHandler() {
+ sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue', target.limitDataMonth());
+ sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue', target.selectedDataUnit());
+ target.viewEditTotalData(true);
+ }
+
+ // ÌײÍÁ÷Á¿±£´æ±à¼°´Å¥Ê¼þ
+ function sf_editTotalDataSaveHandler() {
+ if (sv_trafficStaticalInfo.getEle('limitDataMonth').valid()) {
+ target.usedDataText(transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1048576, false));
+ target.viewEditTotalData(false);
+ }
+ }
+
+ // ÌײÍÁ÷Á¿È¡Ïû±à¼°´Å¥Ê¼þ
+ function sf_editTotalDataCancelHandler() {
+ target.limitDataMonth(sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue'));
+ target.selectedDataUnit(sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue'));
+ target.viewEditTotalData(false);
+ }
+ // ÌײÍʱ¼äÈ¡Ïû±à¼°´Å¥Ê¼þ
+ function sf_editTotalTimeCancelHandler() {
+ target.limitTimeMonth(sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue'));
+ target.viewEditTotalTime(false);
+ }
+ // ÌײÍʱ¼ä±à¼°´Å¥Ê¼þ
+ function sf_editTotalTimeHandler() {
+ sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue', target.limitTimeMonth());
+ target.viewEditTotalTime(true);
+ }
+ // ÌײÍʱ¼ä±£´æ±à¼°´Å¥Ê¼þ
+ function sf_editTotalTimeSaveHandler() {
+ if (sv_trafficStaticalInfo.getEle('limitTimeMonth').valid()) {
+ target.viewEditTotalTime(false);
+ }
+ }
+
+ // ÒÑÓÃÁ÷Á¿È¡Ïû±à¼°´Å¥Ê¼þ
+ function sf_editUsedDataCancelHandler() {
+ target.dataUsed(sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue'));
+ target.selectedDataUsedUnit(sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue'));
+ sv_trafficStaticalInfo.getEle('editUsedDataCancel').siblings('label.error').hide();
+ target.viewEditUsedData(false);
+ }
+ // ÒÑÓÃÁ÷Á¿±à¼°´Å¥Ê¼þ
+ function sf_editUsedDataHandler() {
+ sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue', target.dataUsed());
+ sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue', target.selectedDataUsedUnit());
+ target.dataUsed(target.dataUsed());
+ target.viewEditUsedData(true);
+ }
+ // ÒÑÓÃÁ÷Á¿±£´æ°´Å¥Ê¼þ
+ function sf_editUsedDataSaveHandler() {
+ if (sv_trafficStaticalInfo.getEle('dataUsed').valid()) {
+ sv_usedDataModified = true;
+ target.viewEditUsedData(false);
+ }
+ }
+ // ÒÑÓÃʱ¼äÈ¡Ïû±à¼°´Å¥Ê¼þ
+ function sf_editUsedTimeCancelHandler() {
+ target.usedTime(sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue'));
+ target.viewEditUsedTime(false);
+ }
+ // ÒÑÓÃʱ¼ä±à¼°´Å¥Ê¼þ
+ function sf_editUsedTimeHandler() {
+ sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue', target.usedTime());
+ target.viewEditUsedTime(true);
+ }
+
+ // ÒÑÓÃʱ¼ä±£´æ±à¼°´Å¥Ê¼þ
+ function sf_editUsedTimeSaveHandler() {
+ if (sv_trafficStaticalInfo.getEle('usedTime').valid()) {
+ target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
+ target.viewEditUsedTime(false);
+ sv_usedTimeModified = true;
+ }
+ }
+
+ // Ê£ÓàÁ÷Á¿ÃèÊöÓï
+ function sf_leftDataDesc() {
+ var s_left = (target.limitDataMonth() * target.selectedDataUnit() - target.dataUsed() * target.selectedDataUsedUnit()) * 1048576;
+ if(s_left < 0) {
+ s_left = 0;
+ }
+
+ if(isNaN(s_left)) {
+ target.leftDataDescData('');
+ return $.i18n.prop('traffic_data_left_text', ' ');
+ }
+
+ target.leftDataDescData(transUnit(s_left, false));
+ return $.i18n.prop('traffic_data_left_text', transUnit(s_left, false));
+ }
+ //Ê£Óàʱ¼äÃèÊöÓï
+ function sf_leftTimeDesc() {
+ var s_surplus = target.limitTimeMonth() * target.selectedTimeUnit() - sv_trafficStaticalInfo.getTrafficTimeToSeconds(target.monthlyConnectedTime());
+ if(s_surplus < 0) {
+ s_surplus = 0;
+ }
+
+ if(isNaN(s_surplus)) {
+ target.leftTimeDescData(' ');
+ return $.i18n.prop('traffic_data_left_text', ' ');
+ }
+ target.leftTimeDescData(transSecond2Time(s_surplus));
+ return $.i18n.prop('traffic_data_left_text', transSecond2Time(s_surplus));
+ }
+ // ÌײÍÁ÷Á¿ÃèÊöÓï
+ function sf_limitDataMonthDesc() {
+ if(isNaN(target.limitDataMonth())) {
+ target.limitDataMonthDescData("");
+ return $.i18n.prop('traffic_limit_data_text', ' ');
+ }else{
+ // todo
+ }
+
+ target.limitDataMonthDescData(target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
+ return $.i18n.prop('traffic_limit_data_text', target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
+ }
+ // ÌײÍʱ¼äÃèÊöÓï
+ function sf_limitTimeMonthDesc() {
+ if(isNaN(target.limitTimeMonth())) {
+ target.limitTimeMonthDescData(' ');
+ target.limitTimeMonthDescText('traffic_limit_time_h');
+ return $.i18n.prop('traffic_limit_time_h', ' ');
+ }else{
+ // todo:
+ }
+
+ target.limitTimeMonthDescData(target.limitTimeMonth());
+
+ if(target.selectedTimeUnit() == "60"){
+ target.limitTimeMonthDescText('traffic_limit_time_m');
+ return $.i18n.prop('traffic_limit_time_m', target.limitTimeMonth());
+ }else{
+ target.limitTimeMonthDescText('traffic_limit_time_h');
+ return $.i18n.prop('traffic_limit_time_h', target.limitTimeMonth());
+ }
+ }
+
+ // Ó¦Óð´Å¥Ê¼þ
+ function sf_save() {
+ if (sv_trafficStaticalInfo.isFormEditable(target) && target.dataLimitChecked() == '1') {
+ return false;
+ }
+
+ if (target.selectedDataUnit() == '1' && target.selectedDataUsedUnit() == '1048576' && target.dataLimitTypeChecked() == "1" && target.dataLimitChecked() == '1' && !(parseInt(target.dataUsed(), 10) < parseInt('4096', 10)) ) {
+ showAlert('traffic_over_note');
+ return false;
+ }
+
+ showLoading();
+ service.setTrafficAlertInfo({
+ alertDataReach: parseInt(target.alertDataReach(), 10),
+ alertTimeReach: parseInt(target.alertTimeReach(), 10),
+ dataLimitChecked: target.dataLimitChecked(),
+ dataLimitTypeChecked: target.dataLimitTypeChecked(),
+ limitDataMonth: target.limitDataMonth() + "_" + target.selectedDataUnit(),
+ limitTimeMonth: target.selectedTimeUnit() == "60" ? target.limitTimeMonth()/60 : target.limitTimeMonth()//save by hours
+ }, function (data) {
+ if (data.result == 'success') {
+ if(target.dataLimitTypeChecked() == "1" && sv_usedDataModified) {
+ target.saveUsedData();
+ } else if(target.dataLimitTypeChecked() == "0" && sv_usedTimeModified) {
+ target.saveUsedTime();
+ } else {
+ sv_trafficStaticalInfo.fetchTrafficAlertInfo();
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
+ status.setTrafficAlertPopuped(false);
+ successOverlay();
+ }
+ } else {
+ errorOverlay();
+ }
+ }, function () {
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
+ errorOverlay();
+ });
+ }
+
+ // ±£´æÒÑÓÃÊý¾ÝÁ÷Á¿
+ function sf_saveUsedData() {
+ var val = target.dataUsed() * target.selectedDataUsedUnit();
+ service.trafficCalibration({
+ way: 'data',
+ value: val
+ }, function(){
+ sv_trafficStaticalInfo.fetchTrafficAlertInfo();
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
+ successOverlay();
+ target.viewEditUsedData(false);
+ status.setTrafficAlertPopuped(false);
+ sv_usedDataModified = false;
+ }, function(){
+ sv_trafficStaticalInfo.fetchTrafficAlertInfo();
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
+ errorOverlay();
+ });
+ }
+
+
+
+ function sf_saveUsedTime() {
+ service.trafficCalibration({
+ way: 'time',
+ value: target.selectedTimeUsedUnit() == "60" ? parseFloat(target.usedTime())/60 : target.usedTime()
+ }, function(){
+ sv_trafficStaticalInfo.fetchTrafficAlertInfo();
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
+ successOverlay();
+ target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
+ target.viewEditUsedTime(false);
+ status.setTrafficAlertPopuped(false);
+ sv_usedTimeModified = false;
+ }, function(){
+ sv_trafficStaticalInfo.fetchTrafficAlertInfo();
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
+ errorOverlay();
+ });
+ }
+
+
+ // ÒÑÓÃÁ÷Á¿ÃèÊöÓï
+ function sf_usedDataTextDesc() {
+ if(isNaN(target.dataUsed())) {
+ target.usedDataTextDescData("");
+ return $.i18n.prop('traffic_used_text', ' ');
+ }
+ target.usedDataTextDescData(target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
+ return $.i18n.prop('traffic_used_text', target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
+ }
+ // ÒÑÓÃʱ¼äÃèÊöÓï
+ function sf_usedTimeTextDesc() {
+ target.usedTimeTextDescData(target.monthlyConnectedTime());
+ return $.i18n.prop('traffic_used_text', target.monthlyConnectedTime());
+ }
+
+
+ }
+
+ function init() {
+ sv_trafficGraph = echarts.init($("#traffic_graphic")[0]);
+ window.onresize = sv_trafficGraph.resize;
+ var s_container = $('#container');
+ ko.cleanNode(s_container[0]);
+ var fwVm = new trafficViewModel();
+ ko.applyBindings(fwVm, s_container[0]);
+ $('#trafficAlertForm').validate({
+ submitHandler: function () {
+ fwVm.save();
+ },
+
+
+ errorPlacement: function (error, para) {
+ if (para.attr("name") == "alertDataReach") {
+ error.insertAfter("#editAlertDataDiv");
+ } else if (para.attr("name") == "alertTimeReach") {
+ error.insertAfter("#editAlertTimeDiv");
+ } else if (para.attr("name") == "dataUsed") {
+ error.insertAfter("#editUsedDataDiv");
+ } else if (para.attr("name") == "limitDataMonth") {
+ error.insertAfter("#editTotalDataDiv");
+ } else if (para.attr("name") == "limitTimeMonth") {
+ error.insertAfter("#editTotalTimeDiv");
+ } else if (para.attr("name") == "usedTime") {
+ error.insertAfter("#editUsedTimeDiv");
+ } else {
+ error.insertAfter(para);
+ }
+ },
+
+ rules: {
+ alertDataReach: {
+ range: [ 1, 100 ],
+ digits: true
+ },
+ alertTimeReach: {
+ range: [ 1, 100 ],
+ digits: true
+ },
+ dataUsed: {
+ range : [ 0, 9999 ],
+ decimalRange : true
+ },
+ limitDataMonth: {
+ range : [ 1, 9999 ],
+ decimalRange : true
+ },
+ limitTimeMonth: {
+ range : [ 1, 9999 ],
+ decimalRange : true
+ },
+ usedTime: {
+ range : [ 0, 9999 ],
+ decimalRange : true
+ }
+ }
+
+ });
+
+ var sv_originalLan = window.language;
+ window.setInterval(function(){
+ if(sv_originalLan != window.language){
+ sv_originalLan = window.language;
+ sv_trafficStaticalInfo.refreshFlowDiagramInfo(fwVm);
+ }
+ }, 1000);
+
+ }
+
+ return {
+ init: init
+ };
+});
+
+// ״̬À¸ÌáʾÓïʵÏÖ
+define("tooltip",[ "jquery" ],
+
+ function($) {
+
+
+ // ¼ÆËãÔªËØÎ»ÖÃÐÅÏ¢
+ // @method calculatePositionInfo
+ // @param trigger ÔªËØ
+ // @param tooltip ״̬À¸
+ // @param {JSON} config λÖÃÅäÖÃ
+
+ function calculatePositionInfo(trigger, tooltip, config) {
+ var top = trigger.offset().top;
+ var left = trigger.offset().left;
+ var position = config.position[0];
+ var height = tooltip.outerHeight() + trigger.outerHeight();
+ var width = tooltip.outerWidth() + trigger.outerWidth();
+
+ top -= tooltip.outerHeight() - config.offset[0];
+ left += trigger.outerWidth() + config.offset[1];
+
+ if (/iPad/i.test(navigator.userAgent)) {
+ top -= $(window).scrollTop();
+ }
+
+ if (position == 'center') {
+ top += height / 2;
+ }
+ if (position == 'bottom') {
+ top += height;
+ }
+ position = config.position[1];
+ if (position == 'center') {
+ left -= width / 2;
+ }else if (position == 'left') {
+ left -= width;
+ }
+
+ return {
+ top : top,
+ left : left
+ };
+ }
+
+ // ״̬À¸³õʼ»¯
+ function init() {
+
+ $(".statusItem", "#statusBar").each(function(i, n){
+ var $this = $(this);
+ $this.attr("tipTitle", $this.attr("title")).removeAttr("title");
+ }).hover(
+ function() {
+ var $this = $(this);
+ var title = $this.attr("tipTitle");
+ var tooltip = $("<div>").addClass("tooltip in").appendTo(document.body).hide()
+ .append($this.attr("i18n") ? $.i18n.prop(title) : title);
+ if ($this.attr("i18n")) {
+ tooltip.attr("data-trans", title).attr("id", "tooltip_" + $this.attr("id"));
+ }
+ var pos = calculatePositionInfo($this, tooltip, {
+ position : [ 'bottom', 'center' ],
+ offset : [ 0, 0 ]
+ });
+ tooltip.css({
+ position : 'absolute',
+ top : pos.top,
+ left : pos.left
+ }).show();
+ }, function() {
+ $(".tooltip").hide().remove();
+ });
+ }
+
+ return {
+ init : init
+ };
+ });
+
+define("menu","set service knockout underscore jquery".split(" "),
+ function (set, fnc, libko, libus, libjq) {
+ var displayMenuWhenLogout = false;
+ var vmMenu;
+ var menu = [];
+ var menuResource = "";
+
+ function menuExistCheck(path) {
+ for (var i = 0; i < menu.length; i++) {
+ if (menu[i].path == path) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function getIsLoggedin() {
+ var loginStatus = fnc.getLoginStatus();
+ return (loginStatus.status == "loggedIn");
+ }
+
+ function buildNew() {
+ var loggedIn = getIsLoggedin();
+ var menuMain = libus.filter(menu, function (param) {
+ return (param.level == '1' && ((param.requireLogin && loggedIn) || !param.requireLogin) && param.hash != "#entry");
+ });
+ vmMenu.menuMain(menuMain);
+ vmMenu.loggedIn(loggedIn);
+
+ getMainWth(vmMenu.menuMain().length);
+ vmMenu.showMenu(loggedIn || displayMenuWhenLogout);
+ libjq("#nav").translate();
+ }
+
+ function getMainWth(len) {
+ var width = 100 / len;
+ libjq('ul#list-nav li').each(function () {
+ libjq(this).css('width', width + '%');
+ });
+ }
+
+ function menuRefresh() {
+ var currentHash = window.location.hash;
+ var itmRoot = libus.find(menu, function (param) {
+ return param.hash == currentHash;
+ });
+ while (itmRoot.parent) {
+ itmRoot = libus.find(menu, function (param) {
+ return param.hash == itmRoot.parent;
+ });
+ }
+ if (!itmRoot.parent) {
+ libjq("#list-nav li").removeClass("active");
+ var mid = itmRoot.hash.substring(1, itmRoot.hash.length);
+ libjq("#list-nav li[mid=" + mid + "]").addClass("active");
+ }
+ vmMenu.changeMenu(itmRoot);
+ }
+
+ function menuSearch(hashVal) {
+ hashVal = hashVal || window.location.hash;
+ var loggedIn = getIsLoggedin();
+ return libus.filter(menu, function (param) {
+ return (hashVal == param.hash && ((param.requireLogin && loggedIn) || !param.requireLogin));
+ });
+ }
+
+ function menuRenderSub(level, baseItem) {
+ var levelItem = libus.find(menu, function (param) {
+ return param.parent == baseItem.hash && param.path == baseItem.path;
+ });
+ libjq(".menu-" + level + "-level").removeClass("active");
+ if (levelItem) {
+ if (level == "two") {
+ menuRenderSub("three", levelItem);
+ //forward/backward support
+ clickMenuTrig(levelItem.hash, level);
+ }
+ libjq(".menu-" + level + "-level." + levelItem.hash.substring(1)).addClass("active");
+ }
+ }
+
+ function menuActSub() {
+ var currentHash = window.location.hash;
+ var itmRoot = libus.find(menu, function (param) {
+ return param.hash == currentHash;
+ });
+ if (itmRoot.level == 1) {
+ menuRenderSub("two", itmRoot);
+ }
+ if (itmRoot.level == 2) {
+ menuRenderSub("three", itmRoot);
+ //forward/backward support
+ clickMenuTrig(itmRoot.hash, itmRoot.level);
+ }
+ if (itmRoot.level == 3) {
+ //forward/backward support
+ clickMenuTrig(itmRoot.parent, itmRoot.level);
+ libjq(".menu-three-level").removeClass("active");
+ libjq(".menu-three-level." + itmRoot.hash.substring(1)).addClass("active");
+ }
+ }
+
+ function clickMenuTrig(hash, level) {
+ libjqobj = libjq(".menu-two-level." + hash.substring(1));
+ var levelArr = ['3', 'three', '2', 'two'];
+ if (libus.indexOf(levelArr, level) != -1 && libjqobj.hasClass('active')) {
+ return;
+ }
+
+ libjqobj.siblings().removeClass('active');
+ libjqobj.addClass('active');
+
+ libjqobj.siblings().not('.menu-two-level').slideUp();
+ libjqobj.next().has('ul li').slideDown();
+ }
+
+ set.blc_wan_mode = fnc.getOpMode().blc_wan_mode;
+ if (!set.RJ45_SUPPORT) {
+ menuResource = "menu";
+ } else {
+ switch (set.blc_wan_mode) {
+ case "PPPOE":
+ case "AUTO_PPPOE":
+ menuResource = "menu_pppoe";
+ break;
+ default:
+ menuResource = "menu";
+ break;
+ }
+ }
+
+ require([set.DEVICE + '/' + menuResource], function (otherMenu) {
+ menu = otherMenu;
+ if (set.SD_CARD_SUPPORT) {
+ menu = menu.concat([{ hash: '#httpshare_guest', path: 'sd_httpshare', level: '', requireLogin: false, checkSIMStatus: false},
+ { hash: '#sdcard', path: 'sd', level: '', requireLogin: true, checkSIMStatus: false},
+ { hash: '#httpshare', path: 'sd_httpshare', level: '', requireLogin: true, checkSIMStatus: false}]);
+ }
+ });
+
+ function initialize() {
+ vmMenu = new Menu_vm();
+ }
+
+ function Menu_vm() {
+ var loginState = getIsLoggedin();
+ var target = this;
+ target.loggedIn = libko.observable(loginState);
+
+ target.showMenu = libko.observable(loginState || displayMenuWhenLogout);
+
+ var menuMain = libus.filter(menu, function (param) {
+ return (param.level == '1' && ((param.requireLogin && target.loggedIn()) || !param.requireLogin) && param.hash != "#entry");
+ });
+
+ target.menuMain = libko.observableArray(menuMain);
+ target.secondMenu = libko.observableArray([]);
+ //target.curThirdMenu; cov_2
+ target.changeMenu = function (data) {
+ var secondMenu = getSubMenu(data);
+ if (secondMenu.length == 0) {
+ libjq("#container").addClass("fixContainerWidth");
+ } else {
+ libjq("#container").removeClass("fixContainerWidth");
+ }
+
+ target.secondMenu(secondMenu);
+ return true;
+ };
+ target.thirdMenu = function () {
+ return target.curThirdMenu;
+ };
+ target.getThirdMenu = function (data) {
+ target.curThirdMenu = getSubMenu(data);
+ };
+ function getSubMenu(data) {
+ return libus.filter(menu, function (param) {
+ return ((param.parent && param.parent == data.hash) && ((param.requireLogin && target.loggedIn()) || !param.requireLogin));
+ });
+ }
+ }
+
+ return {
+ activeSubMenu: menuActSub,
+ checkIsMenuExist: menuExistCheck,
+ findMenu: menuSearch,
+ rebuild: buildNew,
+ refreshMenu: menuRefresh,
+ init: initialize
+ };
+});
+
\ No newline at end of file
diff --git a/lynq/R305/ap/app/zte_webui/js/ext/set_aic8800.js b/lynq/R305/ap/app/zte_webui/js/ext/set_aic8800.js
new file mode 100755
index 0000000..e69cbe9
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/js/ext/set_aic8800.js
@@ -0,0 +1,65 @@
+define(function () {
+ var config = {
+ WEBUI_TITLE: 'Mobiletek 4G CPE',
+ PRODUCT_TYPE: 'CPE', // ²úÆ·ÀàÐÍUFI¡¢CPE
+ HAS_BLACK_AND_WHITE_FILTER: true, //ÊÇ·ñÖ§³ÖºÚ°×Ãûµ¥
+ AP_STATION_SUPPORT: true,
+ MAX_STATION_NUMBER: 8,
+ STATION_BLOCK_SUPPORT: true, // ÒÑÁ¬½ÓÉ豸ÊÇ·ñÖ§³ÖBlock¹¦ÄÜ
+ HAS_MULTI_SSID: true, //¶àssid¹¦ÄÜ
+ WIFI_BANDWIDTH_SUPPORT_40MHZ: true, //Ƶ´ø¿í¶ÈÊÇ·ñÖ§³Ö40MHZ,reltekоƬ֧³Ö
+ WIFI_BANDWIDTH_SUPPORT: true,
+ WIFI_BAND_SUPPORT: true,
+ SD_CARD_SUPPORT: false, //ÊÇ·ñÖ§³ÖSD¿¨
+ DDNS_SUPPORT: false, //DDNS
+ NETWORK_UNLOCK_SUPPORT: true,
+ NETWORK_MODES : [ {
+ name : '802.11 b/g/n/ax',
+ value : '6'
+ } ],
+ WIFI_SUPPORT_QR_CODE: false,
+ HAS_PHONEBOOK: true,
+ HAS_BATTERY: false, //ÊÇ·ñÓÐµç³Ø
+ FAST_BOOT_SUPPORT: false, //ÊÇ·ñÖ§³Ö¿ìËÙ¿ª»ú
+ TURN_OFF_SUPPORT: false, //ÊÇ·ñÖ§³Ö¹Ø»ú
+ WIFI_SLEEP_SUPPORT: false, // ÊÇ·ñÖ§³ÖwifiÐÝÃß
+ HAS_USSD: true, // ÊÇ·ñÖ§³ÖUSSD
+ //station¼ÓÃÜģʽ
+ AUTH_MODES_ALL: [{
+ name: 'NO ENCRYPTION',
+ value: 'OPEN'
+ }, {
+ name: 'SHARED',
+ value: 'SHARED'
+ }, {
+ name: 'WPA-PSK',
+ value: 'WPAPSK'
+ }, {
+ name: 'WPA2-PSK',
+ value: 'WPA2PSK'
+ }, {
+ name: 'WPA-PSK/WPA2-PSK',
+ value: 'WPAPSKWPA2PSK'
+ }, {
+ name: 'WPA3-Personal',
+ value: 'WPA3Personal'
+ }, {
+ name: 'WPA2(AES)/WPA3-Personal',
+ value: 'WPA2WPA3'
+ }
+ ],
+ AUTO_MODES: [{
+ name: 'Automatic',
+ value: 'NETWORK_auto'
+ }, {
+ name: '4G Only',
+ value: 'Only_LTE'
+ }, {
+ name: '3G Only',
+ value: 'Only_WCDMA'
+ }
+ ]
+ };
+
+ return config;
+});
diff --git a/lynq/R305/ap/app/zte_webui/js/net.js b/lynq/R305/ap/app/zte_webui/js/net.js
new file mode 100755
index 0000000..22a9d2b
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/js/net.js
@@ -0,0 +1,4233 @@
+
+define("firewall_url_filter","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ //system url filter setting VM
+
+ function UrlFilterSettingVM() {
+ var target = this;
+ var urlFltInfo = service.getUrlFilterList();
+ var columnsTmpl = [{
+ columnType: "checkbox",
+ rowText: "index",
+ width: "30%"
+ }, {
+ headerTextTrans: "url",
+ rowText: "url",
+ width: "70%"
+ }
+ ];
+ target.rules = ko.observableArray(urlFltInfo.urlFilterRules);
+
+ target.gridTemplate = new ko.simpleGrid.viewModel({
+ data: target.rules(),
+ idName: "index",
+ columns: columnsTmpl,
+ tmplType: 'list',
+ pageSize: 10
+ });
+
+ target.clear = clearFunc;
+
+ target.callback = callbackFunc;
+ //删除规则
+
+ target.deleteRule = deleteRuleFunc;
+
+ //添加规则
+
+ target.addRule = addRuleFunc;
+ function callbackFunc(elem) {
+ if (elem.result != "success") {
+ errorOverlay();
+ } else {
+ target.clear();
+ initialize(target);
+ successOverlay();
+ $("#urlFilters").translate();
+ }
+ }
+
+ //添加规则
+ function addRuleFunc() {
+ if (target.rules().length >= config.urlFilterMax) {
+ showAlert({
+ msg: "url_filter_max",
+ params: config.urlFilterMax
+ });
+ return false;
+ }
+ var tmpArr = [];
+ for (var idx = 0; idx < target.rules().length; idx++) {
+ tmpArr.push(target.rules()[idx].url);
+ }
+ if ($.inArray($("#addURLFilter").val(), tmpArr) != -1) {
+ showAlert("url_repeated");
+ return false;
+ }
+
+ showLoading();
+ var urlFltParams = {
+ goformId: "URL_FILTER_ADD",
+ addURLFilter: $("#addURLFilter").val()
+ };
+ service.addUrlFilterRule(urlFltParams, target.callback);
+ }
+ //删除规则
+ function deleteRuleFunc() {
+ showConfirm('confirm_data_delete', function () {
+ showLoading();
+ var urlFltParams = {
+ goformId: "URL_FILTER_DELETE",
+ url_filter_delete_id: target.gridTemplate.selectedIds().join(";") + ";"
+ };
+ service.deleteSelectedRules(urlFltParams, target.callback);
+ });
+ }
+
+ }
+
+ function clearFunc() {
+ $("#addURLFilter").val("");
+ }
+
+ //页面初始化
+
+ function initialize() {
+
+ var vm = new UrlFilterSettingVM();
+ bindContainer(vm);
+ }
+ function bindContainer(vm){
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+ $('#urlFilterForm').validate({
+ submitHandler: function () {
+ vm.addRule();
+ },
+ rules: {
+ addURLFilter: 'url_filter_check'
+ }
+ });
+
+ $("#urlFilterListForm").validate({
+ submitHandler: function () {
+ vm.deleteRule();
+ }
+ });
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("firewall_upnp_set","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ //system upnp setting VM
+
+ function UpnpSettingVM() {
+ var target = this;
+ var upnpInfo = getUpnpSetting();
+
+ target.upnpSetting = ko.observable(upnpInfo.upnpSetting);
+
+ target.save = saveFunc;
+ function saveFunc() {
+ showLoading();
+ var upnpParams = {};
+ upnpParams.upnpSetting = target.upnpSetting();
+ service.setUpnpSetting(upnpParams, function (rlt) {
+ if (rlt.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+
+ }
+ }
+
+
+ //获取upnp 信息
+
+ function getUpnpSetting() {
+ return service.getUpnpSetting();
+ }
+
+ //初始化UpnpSettingVM model
+
+ function initialize() {
+
+ var vm = new UpnpSettingVM();
+ bindContainer(vm);
+
+ }
+ function bindContainer(vm) {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+ $('#upnpSettingForm').validate({
+ submitHandler: function () {
+ vm.save();
+ }
+ });
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("firewall_upnp_set","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ //system upnp setting VM
+
+ function UpnpSettingVM() {
+ var target = this;
+ var upnpInfo = getUpnpSetting();
+
+ target.upnpSetting = ko.observable(upnpInfo.upnpSetting);
+
+ target.save = saveFunc;
+ function saveFunc() {
+ showLoading();
+ var upnpParams = {};
+ upnpParams.upnpSetting = target.upnpSetting();
+ service.setUpnpSetting(upnpParams, function (rlt) {
+ if (rlt.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+
+ }
+ }
+
+
+ //获取upnp 信息
+
+ function getUpnpSetting() {
+ return service.getUpnpSetting();
+ }
+
+ //初始化UpnpSettingVM model
+
+ function initialize() {
+
+ var vm = new UpnpSettingVM();
+ bindContainer(vm);
+
+ }
+ function bindContainer(vm) {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+ $('#upnpSettingForm').validate({
+ submitHandler: function () {
+ vm.save();
+ }
+ });
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+//端口映射
+
+define("firewall_port_map","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var protocolModes = _.map(config.MAP_PROTOCOL_MODES, function (ele) {
+ return new Option(ele.name, ele.value);
+ });
+
+ var columnsTmpl = [{
+ columnType: "checkbox",
+ rowText: "index",
+ width: "8%"
+ }, {
+ headerTextTrans: "source_port",
+ rowText: "sourcePort",
+ width: "20%"
+ }, {
+ headerTextTrans: "dest_ip_address",
+ rowText: "destIpAddress",
+ width: "20%"
+ }, {
+ headerTextTrans: "dest_port",
+ rowText: "destPort",
+ width: "20%"
+ }, {
+ headerTextTrans: "protocol",
+ rowText: "protocol",
+ width: "12%"
+ }, {
+ headerTextTrans: "comment",
+ rowText: "comment",
+ width: "20%"
+ }
+ ];
+
+ //prot_map VM
+
+ function PortMapVM() {
+ var target = this;
+ var mapInfo = getPortMap();
+
+ target.oriPortMapEnable = ko.observable(mapInfo.portMapEnable);
+ target.rules = ko.observableArray(mapInfo.portMapRules);
+ target.portMapEnable = ko.observable(mapInfo.portMapEnable);
+
+
+ target.comment = ko.observable('');
+ target.selectedMode = ko.observable('TCP&UDP');
+ target.modes = ko.observableArray(protocolModes);
+
+ target.destPort = ko.observable('');
+ target.destIpAddress = ko.observable('');
+ target.sourcePort = ko.observable('');
+
+
+
+ target.gridTemplate = new ko.simpleGrid.viewModel({
+ data: target.rules(),
+ idName: "index",
+ columns: columnsTmpl,
+ tmplType: 'list',
+ pageSize: 10
+ });
+
+ //设定,新增,删除回调函数
+
+ target.callback = callbackFunc;
+
+ //删除规则
+
+ target.deleteMapRules = deleteMapRulesFunc;
+
+ //检查新增规则是否已经存在
+
+ target.checkExist = checkExistFunc;
+
+ //设定端口映射
+
+ target.enablePortMap = enablePortMapFunc;
+
+ //保存规则
+
+ target.save = saveFunc;
+
+ //保存规则
+ function saveFunc() {
+ if (target.rules().length >= config.portForwardMax) {
+ showAlert({
+ msg: "rules_max",
+ params: config.portForwardMax
+ });
+ return;
+ }
+
+ if (target.checkExist()) {
+ showAlert("rule_exist");
+ return;
+ }
+
+ showLoading();
+ var mapParams = {};
+ mapParams.portMapEnable = target.portMapEnable();
+ mapParams.sourcePort = target.sourcePort();
+ mapParams.destIpAddress = target.destIpAddress();
+ mapParams.destPort = target.destPort();
+ mapParams.protocol = target.selectedMode();
+ mapParams.comment = target.comment();
+ service.setPortMap(mapParams, target.callback);
+ }
+
+ //检查新增规则是否已经存在
+ function checkExistFunc() {
+ var newMapRule = {
+ sourcePort: target.sourcePort(),
+ destIpAddress: target.destIpAddress(),
+ destPort: target.destPort(),
+ protocol: transProtocolValue(target.selectedMode())
+ };
+
+ var oldMapRule;
+ var mapRules = target.rules();
+ for (var idx = 0; idx < mapRules.length; idx++) {
+ oldMapRule = {
+ sourcePort: mapRules[idx].sourcePort,
+ destIpAddress: mapRules[idx].destIpAddress,
+ destPort: mapRules[idx].destPort,
+ protocol: mapRules[idx].protocol
+ };
+
+ if (_.isEqual(newMapRule, oldMapRule)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //设定端口映射
+ function enablePortMapFunc() {
+ showLoading();
+ var mapParams = {};
+ mapParams.portMapEnable = target.portMapEnable();
+ service.enablePortMap(mapParams, target.callback);
+ }
+
+ //删除规则
+ function deleteMapRulesFunc() {
+ var ids = target.gridTemplate.selectedIds();
+ if (ids.length == 0) {
+ showAlert("no_data_selected");
+ return;
+ }
+
+ showConfirm("confirm_data_delete", function () {
+ showLoading();
+ var mapParams = {};
+ mapParams.indexs = ids;
+ service.deleteMapRules(mapParams, target.callback);
+ });
+ }
+
+ //设定,新增,删除回调函数
+ function callbackFunc(ret) {
+ if (ret.result == "success") {
+ clear();
+ initialize(target);
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }
+
+ //情况添加规则输入
+
+ function clear() {
+ target.sourcePort('');
+ target.destIpAddress('');
+ target.destPort('');
+ target.selectedMode('TCP&UDP');
+ target.comment('');
+ }
+ }
+
+ //获取port map信息
+
+ function getPortMap() {
+ return service.getPortMap();
+ }
+
+ function bindingContainer(vm){
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+
+ }
+ //初始化port map view model
+
+ function initialize(viewModel) {
+ var vm;
+ if (viewModel) {
+ vm = viewModel;
+ var mapInfo = getPortMap();
+ vm.portMapEnable(mapInfo.portMapEnable);
+ vm.oriPortMapEnable(mapInfo.portMapEnable);
+ vm.rules(mapInfo.portMapRules);
+ vm.gridTemplate.clearAllChecked();
+ vm.gridTemplate.data(mapInfo.portMapRules);
+ refreshTableHeight();
+ renderCheckbox();
+ return;
+ }
+
+ vm = new PortMapVM();
+ bindingContainer(vm);
+ fixTableHeight();
+
+ $('#mapBasicForm').validate({
+ submitHandler: function () {
+ vm.enablePortMap();
+ }
+ });
+
+ $('#portMapListForm').validate({
+ submitHandler: function () {
+ vm.deleteMapRules();
+ }
+ });
+
+ $('#portMapForm').validate({
+ submitHandler: function () {
+ vm.save();
+ },
+ rules: {
+ txtDestIpAddress: {
+ ip_check: true
+ },
+ txtSourcePort: {
+ digits: true,
+ range_except: [1, 65000]
+ },
+ txtDestPort: {
+ digits: true,
+ range_except: [1, 65000]
+ },
+ txtComment: {
+ comment_check: true
+ }
+ },
+ errorPlacement: function (error, element) {
+ if (element.attr("name") == "txtDestIpAddress") {
+ error.appendTo("#txtDestIpAddressErrorDiv");
+ } else if (element.attr("name") == "txtSourcePort") {
+ error.appendTo("#txtSourcePortErrorDiv");
+ } else if (element.attr("name") == "txtDestPort") {
+ error.appendTo("#txtDestPortErrorDiv");
+ } else
+ error.insertAfter(element);
+ }
+ });
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+//端口转发
+
+define("firewall_port_forward","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var protocolModes = _.map(config.FORWARD_PROTOCOL_MODES, function (ele) {
+ return new Option(ele.name, ele.value);
+ });
+ //列表模板的columns项
+
+ var columnsTmpl = [{
+ columnType: "checkbox",
+ rowText: "index",
+ width: "8%"
+ }, {
+ headerTextTrans: "ip_address",
+ rowText: "ipAddress",
+ width: "23%"
+ }, {
+ headerTextTrans: "port_range",
+ rowText: "portRange",
+ width: "23%"
+ }, {
+ headerTextTrans: "protocol",
+ rowText: "protocol",
+ width: "23%"
+ }, {
+ headerTextTrans: "comment",
+ rowText: "comment",
+ width: "23%"
+ }
+ ];
+
+ //prot_forward VM
+
+ function PortForwardVM() {
+ var target = this;
+ var fwdinfo = getPortForward();
+
+ target.portForwardEnable = ko.observable(fwdinfo.portForwardEnable);
+ target.oriPortForwardEnable = ko.observable(fwdinfo.portForwardEnable);
+
+ target.portEnd = ko.observable('');
+ target.portStart = ko.observable('');
+ target.ipAddress = ko.observable('');
+
+ target.comment = ko.observable('');
+ target.selectedMode = ko.observable('3');
+ target.modes = ko.observableArray(protocolModes);
+
+ target.rules = ko.observableArray(fwdinfo.portForwardRules);
+
+ //设定,新增,删除回调函数
+
+ target.callback = callbackFunc;
+
+ //创建列表模板
+
+ target.gridTemplate = new ko.simpleGrid.viewModel({
+ data: target.rules(),
+ idName: "index",
+ columns: columnsTmpl,
+ tmplType: 'list',
+ pageSize: 10
+ });
+
+ //检查新增规则是否已经存在
+
+ target.checkExist = checkExistFunc;
+
+ //保存规则
+
+ target.save = saveFunc;
+
+ //删除规则
+
+ target.deleteForwardRules = deleteForwardRulesFunc;
+
+ //设定虚拟服务器
+
+ target.enableVirtualServer = enableVirtualServerFunc;
+
+ //设定虚拟服务器
+ function enableVirtualServerFunc() {
+ showLoading();
+ var fwdParams = {};
+ fwdParams.portForwardEnable = target.portForwardEnable();
+ service.enableVirtualServer(fwdParams, target.callback);
+ }
+
+ //删除规则
+ function deleteForwardRulesFunc() {
+ var ids = target.gridTemplate.selectedIds();
+ if (ids.length == 0) {
+ showAlert("no_data_selected");
+ return;
+ }
+
+ showConfirm("confirm_data_delete", function () {
+ showLoading('deleting');
+ var fwdParams = {};
+ fwdParams.indexs = ids;
+ service.deleteForwardRules(fwdParams, target.callback);
+ });
+ }
+
+ //保存规则
+ function saveFunc() {
+ if (target.rules().length >= config.portForwardMax) {
+ showAlert({
+ msg: "rules_max",
+ params: config.portForwardMax
+ });
+ return;
+ }
+
+ if (target.checkExist()) {
+ showAlert("rule_exist");
+ return;
+ }
+
+ showLoading();
+ var fwdParams = {};
+ fwdParams.comment = target.comment();
+ fwdParams.protocol = target.selectedMode();
+ fwdParams.portEnd = target.portEnd();
+ fwdParams.portStart = target.portStart();
+ fwdParams.ipAddress = target.ipAddress();
+ service.setPortForward(fwdParams, target.callback);
+ }
+ //情况添加规则输入
+ function clear() {
+ target.ipAddress('');
+ target.portStart('');
+ target.portEnd('');
+ target.selectedMode('TCP&UDP');
+ target.comment('');
+ }
+
+ //设定,新增,删除回调函数
+ function callbackFunc(ret) {
+ if (ret.result == "success") {
+ clear();
+ initialize(target);
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }
+
+ //检查新增规则是否已经存在
+ function checkExistFunc() {
+ var newRule = {
+ ipAddress: target.ipAddress(),
+ portRange: target.portStart() + ' - ' + target.portEnd(),
+ protocol: transProtocolValue(target.selectedMode())
+ };
+
+ var oldRule;
+ var fwdrules = target.rules();
+ for (var ki = 0; ki < fwdrules.length; ki++) {
+ oldRule = {
+ ipAddress: fwdrules[ki].ipAddress,
+ portRange: fwdrules[ki].portRange,
+ protocol: fwdrules[ki].protocol
+ };
+
+ if (_.isEqual(newRule, oldRule)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ //获取port forward信息
+
+ function getPortForward() {
+ return service.getPortForward();
+ }
+
+ //初始化port forward view model
+
+ function initialize(viewModel) {
+ var vm;
+ if (viewModel) {
+ vm = viewModel;
+ var fwdinfo = getPortForward();
+ vm.gridTemplate.clearAllChecked();
+ vm.gridTemplate.data(fwdinfo.portForwardRules);
+ vm.rules(fwdinfo.portForwardRules);
+ vm.portForwardEnable(fwdinfo.portForwardEnable);
+ vm.oriPortForwardEnable(fwdinfo.portForwardEnable);
+ refreshTableHeight();
+ return;
+ }
+
+ vm = new PortForwardVM();
+ bindContainer(vm);
+
+ fixTableHeight();
+ renderCheckbox();
+
+ $('#virtualServerForm').validate({
+ submitHandler: function () {
+ vm.enableVirtualServer();
+ }
+ });
+
+ $('#portForwardListForm').validate({
+ submitHandler: function () {
+ vm.deleteForwardRules();
+ }
+ });
+
+ $('#portForwardForm').validate({
+ submitHandler: function () {
+ vm.save();
+ },
+ rules: {
+ txtIpAddress: {
+ ip_check: true
+ },
+ txtPortStart: {
+ digits: true,
+ range: [1, 65535],
+ portCompare: "#txtPortEnd"
+ },
+ txtPortEnd: {
+ digits: true,
+ range: [1, 65535],
+ portCompare: "#txtPortStart"
+ },
+ txtComment: {
+ comment_check: true
+ }
+ },
+ groups: {
+ range: "txtPortStart txtPortEnd"
+ },
+ errorPlacement: function (error, element) {
+ if (element.attr("name") == "txtIpAddress") {
+ error.appendTo("#ipErrorDiv");
+ } else if (element.attr("name") == "txtPortStart" || element.attr("name") == "txtPortEnd") {
+ error.appendTo("#portRangeErrorDiv");
+ } else
+ error.insertAfter(element);
+ }
+ });
+ }
+
+ function bindContainer(vm){
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+
+ }
+
+
+ return {
+ init: initialize
+ };
+});
+
+define("firewall_port_filter","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var PROTOCOLS = {
+ ICMP: 'ICMP',
+ NONE: 'None'
+ };
+
+ var columnsTmpl = [{
+ columnType: "checkbox",
+ rowText: "index",
+ width: "4%"
+ }, {
+ headerTextTrans: "mac_address",
+ rowText: "macAddress",
+ width: "12%"
+ }, {
+ headerTextTrans: "ip_type",
+ rowText: "ipType",
+ width: "5%",
+ display: config.IPV6_SUPPORT
+ }, {
+ headerTextTrans: "source_ip_address",
+ rowText: "sourceIpAddress",
+ width: "12%"
+ }, {
+ headerTextTrans: "dest_ip_address",
+ rowText: "destIpAddress",
+ width: "12%"
+ }, {
+ headerTextTrans: "protocol",
+ rowText: "protocol",
+ width: "12%",
+ needTrans: true
+ }, {
+ headerTextTrans: "source_port_range",
+ rowText: "sourcePortRange",
+ width: "12%"
+ }, {
+ headerTextTrans: "dest_port_range",
+ rowText: "destPortRange",
+ width: "12%"
+ }, {
+ headerTextTrans: "port_filter_action",
+ rowText: "action",
+ width: "12%",
+ needTrans: true
+ }, {
+ headerTextTrans: "comment",
+ rowText: "comment",
+ width: "12%"
+ }
+ ];
+
+ var protocolModes = _.map(config.FILTER_PROTOCOL_MODES, function (elem) {
+ return new Option(elem.name, elem.value);
+ });
+ //prot_filter VM
+
+ function PortFilterVM() {
+ var target = this;
+ var info = getPortFilter();
+
+ target.oriDefaultPolicy = ko.observable(info.defaultPolicy);
+ target.defaultPolicy = ko.observable(info.defaultPolicy);
+ target.oriPortFilterEnable = ko.observable(info.portFilterEnable);
+ target.portFilterEnable = ko.observable(info.portFilterEnable);
+ target.rules = ko.observableArray(info.portFilterRules);
+
+ target.ipv6Support = ko.observable(config.IPV6_SUPPORT);
+ target.comment = ko.observable('');
+ target.selectedMode = ko.observable('5');
+ target.modes = ko.observableArray(protocolModes);
+ target.sourcePortEnd = ko.observable('');
+ target.sourcePortStart = ko.observable('');
+ target.destPortEnd = ko.observable('');
+ target.destPortStart = ko.observable('');
+ target.destIpv6Address = ko.observable('');
+ target.sourceIpv6Address = ko.observable('');
+ target.sourceIpAddress = ko.observable('');
+ target.destIpAddress = ko.observable('');
+ target.macAddress = ko.observable('');
+ target.portFilterAction = ko.observable('');
+
+ target.ipType = ko.observable('ipv4');
+
+ //设定,新增,删除回调函数
+
+ target.callback = callbackFunc;
+
+ //创建列表模板
+
+ target.gridTemplate = new ko.simpleGrid.viewModel({
+ data: target.rules(),
+ idName: "index",
+ columns: columnsTmpl,
+ tmplType: 'list',
+ pageSize: 20
+ });
+ //default policy change handler
+
+ target.policyChangeHandler = policyChangeHandlerFunc;
+
+ //保存规则
+
+ target.save = saveFunc;
+
+ //设定过滤基本信息
+
+ target.setPortFilterBasic = setPortFilterBasicFunc;
+
+ //清空添加规则输入
+
+ target.clear = clearFunc;
+
+ //检查新增规则是否已经存在
+
+ target.checkExist = checkExistFunc;
+
+ //ip类型变化事件监听
+
+ target.ipTypeChangeHandler = ipTypeChangeHandlerFunc;
+
+ //协议变化事件监听
+
+ target.protocolChangeHandler = protocolChangeHandlerFunc;
+
+ //删除规则
+
+ target.deleteFilterRules = deleteFilterRulesFunc;
+
+ //init to call
+ target.policyChangeHandler();
+
+ //设定,新增,删除回调函数
+ function callbackFunc(ret) {
+ if (ret.result != "success") {
+ errorOverlay();
+ } else {
+ target.clear();
+ initialize(target);
+ successOverlay();
+ }
+ }
+ //default policy change handler
+ function policyChangeHandlerFunc() {
+ var action = target.defaultPolicy() != "1" ? "Drop" : "Accept";
+ target.portFilterAction(action);
+ return true;
+ }
+
+ //保存规则
+ function saveFunc() {
+ target.sourceIpAddress(target.sourceIpAddress().replace(/\s+/g, ''));
+ target.destIpAddress(target.destIpAddress().replace(/\s+/g, ''));
+ target.sourceIpv6Address(target.sourceIpv6Address().replace(/\s+/g, ''));
+ target.destIpv6Address(target.destIpv6Address().replace(/\s+/g, ''));
+ target.macAddress(target.macAddress().replace(/\s+/g, ''));
+ if (target.ipv6Support() == false) {
+ if (target.rules().length >= config.portForwardMax) {
+ showAlert({
+ msg: "rules_max",
+ params: config.portForwardMax
+ });
+ return;
+ }
+
+ if (target.checkExist()) {
+ showAlert("rule_exist");
+ return;
+ }
+
+ } else {
+ var type = target.ipType() == "ipv4" ? "IPv4" : "IPv6";
+ var oldRules = _.filter(target.rules(), function (item) {
+ return item.ipType == type;
+ });
+
+ if (oldRules.length >= config.portForwardMax) {
+ showAlert({
+ msg: "rules_max_v4v6",
+ params: [type, config.portForwardMax]
+ });
+ return;
+ }
+
+ if (target.checkExist()) {
+ showAlert({
+ msg: "rule_exist_v4v6",
+ params: type
+ });
+ return;
+ }
+ }
+ showConfirm("confirm_data_effect", function () {
+ showLoading();
+ var fltParams = {};
+ fltParams.macAddress = target.macAddress();
+
+ if (target.ipv6Support() && target.ipType() != 'ipv6') {
+ fltParams.destIpAddress = target.destIpAddress();
+ fltParams.sourceIpAddress = target.sourceIpAddress();
+ } else {
+ fltParams.destIpAddress = target.destIpv6Address();
+ fltParams.sourceIpAddress = target.sourceIpv6Address();
+ }
+
+ fltParams.ipType = target.ipType();
+ fltParams.comment = target.comment();
+ fltParams.protocol = target.selectedMode();
+ fltParams.action = target.portFilterAction();
+ fltParams.sourcePortEnd = target.sourcePortEnd();
+ fltParams.sourcePortStart = target.sourcePortStart();
+ fltParams.destPortEnd = target.destPortEnd();
+ fltParams.destPortStart = target.destPortStart();
+ service.setPortFilter(fltParams, target.callback);
+ });
+ }
+
+ //设定过滤基本信息
+ function setPortFilterBasicFunc() {
+ showLoading();
+ var elems = {};
+ elems.defaultPolicy = target.defaultPolicy();
+ elems.portFilterEnable = target.portFilterEnable();
+ service.setPortFilterBasic(elems, target.callback);
+ }
+ //清空添加规则输入
+ function clearFunc() {
+ target.comment('');
+ target.selectedMode('None');
+ target.sourcePortEnd('0');
+ target.sourcePortStart('0');
+ target.destPortEnd('0');
+ target.destPortStart('0');
+ target.sourceIpv6Address('');
+ target.sourceIpAddress('');
+ target.destIpv6Address('');
+ target.destIpAddress('');
+ target.macAddress('');
+ clearValidateMsg();
+ }
+
+ //检查新增规则是否已经存在
+ function checkExistFunc() {
+ target.macAddress(target.macAddress().toUpperCase());
+ var currIpType = target.ipType().toUpperCase();
+ var newRule = {
+ macAddress: target.macAddress(),
+ destIpAddress: currIpType == "IPV4" ? target.destIpAddress() : target.destIpv6Address(),
+ sourceIpAddress: currIpType == "IPV4" ? target.sourceIpAddress() : target.sourceIpv6Address(),
+ destPortRange: target.destPortStart() == '0' ? '' : target.destPortStart() + ' - ' + target.destPortEnd(),
+ sourcePortRange: target.sourcePortStart() == '0' ? '' : target.sourcePortStart() + ' - ' + target.sourcePortEnd(),
+ action: target.portFilterAction() == "Drop" ? "filter_drop" : "filter_accept",
+ protocol: transProtocolValue(target.selectedMode()),
+ ipType: currIpType
+ };
+
+ var oldRule;
+ var rules = target.rules();
+ for (var ki = 0; ki < rules.length; ki++) {
+ oldRule = {
+ macAddress: rules[ki].macAddress,
+ destIpAddress: rules[ki].destIpAddress,
+ sourceIpAddress: rules[ki].sourceIpAddress,
+ destPortRange: rules[ki].destPortRange,
+ sourcePortRange: rules[ki].sourcePortRange,
+ action: rules[ki].action,
+ protocol: rules[ki].protocol,
+ ipType: rules[ki].ipType.toUpperCase()
+ };
+
+ if (_.isEqual(newRule, oldRule)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //协议变化事件监听
+ function protocolChangeHandlerFunc() {
+ if (target.selectedMode() == PROTOCOLS.ICMP || target.selectedMode() == PROTOCOLS.NONE) {
+ target.sourcePortEnd('0');
+ target.sourcePortStart('0');
+ target.destPortEnd('0');
+ target.destPortStart('0');
+ clearValidateMsg('#portRangeArea');
+ } else {
+ target.sourcePortEnd('65535');
+ target.sourcePortStart('1');
+ target.destPortEnd('65535');
+ target.destPortStart('1');
+ }
+ return true;
+ }
+
+ //删除规则
+ function deleteFilterRulesFunc() {
+ var ids = target.gridTemplate.selectedIds();
+ if (ids.length == 0) {
+ showAlert("no_data_selected");
+ return;
+ }
+
+ showConfirm("confirm_data_effect", function () {
+ showLoading('deleting');
+ var rules = {};
+ rules.indexs = ids;
+ service.deleteFilterRules(rules, target.callback);
+ });
+ }
+
+ }
+
+ //获取port filter信息
+
+ function getPortFilter() {
+ return service.getPortFilter();
+ }
+
+ //ip类型变化事件监听
+ function ipTypeChangeHandlerFunc() {
+ clearValidateMsg();
+ return true;
+ }
+
+ //初始化port filter view model
+
+ function initialize(viewModel) {
+ var vm;
+ if (viewModel) {
+ vm = viewModel;
+ var fltinfo = getPortFilter();
+ vm.gridTemplate.clearAllChecked();
+ vm.gridTemplate.data(fltinfo.portFilterRules);
+ vm.defaultPolicy(fltinfo.defaultPolicy);
+ vm.oriDefaultPolicy(fltinfo.defaultPolicy);
+ vm.portFilterEnable(fltinfo.portFilterEnable);
+ vm.oriPortFilterEnable(fltinfo.portFilterEnable);
+ vm.rules(fltinfo.portFilterRules);
+ refreshTableHeight();
+ $('#portFilters').find('tbody').translate();
+ renderCheckbox();
+ $('.notes-content').translate();
+ return;
+ }
+
+ vm = new PortFilterVM();
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+
+ fixTableHeight();
+
+ $('#filterBasicForm').validate({
+ submitHandler: function () {
+ showConfirm("confirm_data_effect", function () {
+ vm.setPortFilterBasic();
+ });
+ }
+ });
+
+ $('#portFilterListForm').validate({
+ submitHandler: function () {
+ vm.deleteFilterRules();
+ }
+ });
+
+ $('#portFilterForm').validate({
+ submitHandler: function () {
+ vm.save();
+ },
+ rules: {
+ txtMacAddress: {
+ filter_optional: true,
+ mac_check: true
+ },
+ txtDestIpAddress: {
+ ip_check: true
+ },
+ txtSourceIpAddress: {
+ ip_check: true
+ },
+ txtSourceIpv6Address: {
+ ipv6: true
+ },
+ txtDestIpv6Address: {
+ ipv6: true
+ },
+ txtDestPortStart: {
+ digits: true,
+ range: [1, 65535],
+ portCompare: "#txtDestPortEnd"
+ },
+ txtDestPortEnd: {
+ digits: true,
+ range: [1, 65535],
+ portCompare: "#txtDestPortStart"
+ },
+ txtSourcePortStart: {
+ digits: true,
+ range: [1, 65535],
+ portCompare: "#txtSourcePortEnd"
+ },
+ txtSourcePortEnd: {
+ digits: true,
+ range: [1, 65535],
+ portCompare: "#txtSourcePortStart"
+ },
+
+ txtComment: {
+ comment_check: true
+ }
+ },
+ groups: {
+ destPort: "txtDestPortStart txtDestPortEnd",
+ sourcePort: "txtSourcePortStart txtSourcePortEnd"
+ },
+ errorPlacement: function (error, element) {
+ if (element.attr("name") == "txtMacAddress") {
+ error.appendTo("#macErrorDiv");
+ } else if (element.attr("name") == "txtDestPortStart" || element.attr("name") == "txtDestPortEnd") {
+ error.appendTo("#destPortErrorDiv");
+ } else if (element.attr("name") == "txtSourcePortStart" || element.attr("name") == "txtSourcePortEnd") {
+ error.appendTo("#sourcePortErrorDiv");
+ } else
+ error.insertAfter(element);
+ }
+ });
+ }
+
+ $.validator.addMethod("filter_optional", function (value, element, param) {
+ var result = _.any(['#txtMacAddress', '#txtDestIpAddress', '#txtSourceIpAddress', '#txtSourceIpv6Address', '#txtDestIpv6Address'],
+ function (item) {
+ var tmp = $(item).val().replace(/\s+/g, '');
+ return $(item + ':visible').length > 0 && tmp != '';
+ });
+
+ var portResult = _.any(['#txtDestPortStart', '#txtDestPortEnd', '#txtSourcePortStart', '#txtSourcePortEnd'],
+ function (item) {
+ return $(item).val() != '0';
+ });
+
+ return result || portResult;
+ });
+
+ return {
+ init: initialize
+ };
+});
+
+//家长控制
+
+define("firewall_parental_control","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var maxItem = 10;
+ var pcVm = null;
+ var PAGES = {
+ MAIN: 0,
+ MANAGE: 1,
+ RULE: 2
+ };
+
+
+ function ParentalControlVM() {
+ var target = this;
+ var hostNameList = service.getHostNameList({}).devices;
+ target.currentPage = ko.observable(PAGES.MAIN);
+ target.pages = PAGES;
+
+
+ target.childGroupList = ko.observable([]);
+ target.childGroupMac = ko.computed(function () {
+ return _.map(target.childGroupList(), function (data) {
+ return data.mac;
+ });
+ });
+
+ target.currentUserInChildGroup = ko.observable(true);
+ //获取儿童组设备列表
+
+ target.fetchChildGroupList = fetchChildGroupListFunc;
+
+ target.fetchChildGroupList();
+
+ target.manageHandler = manageHandlerFunc;
+ function manageHandlerFunc() {
+ target.currentPage(PAGES.MANAGE);
+ target.fetchAttachedDevices();
+ }
+ target.attachedDevices = ko.observable([]);
+ //获取已连接设备列表
+
+ target.fetchAttachedDevices = fetchAttachedDevicesFunc;
+
+
+ //儿童组设备 标签按钮事件
+
+ target.backToMainHandler = backToMainHandlerFunc;
+
+
+ ko.computed(function () {
+ target.attachedDevices();
+ target.childGroupList();
+ $("#pc_children_group_form").translate();
+ }).extend({
+ notify: 'always',
+ throttle: 300
+ });
+
+ //添加至儿童组
+
+ function addChildGroupFun(flag, eleData) {
+ showLoading();
+ service.addChildGroup(eleData, function (data) {
+ target.fetchChildGroupList(function () {
+ target.fetchAttachedDevices(function () {
+ hideLoading();
+ if (flag) {
+ service.logout({}, function () {
+ window.location = 'index.html';
+ });
+ }
+ });
+ });
+ }, function (data) {
+ errorOverlay();
+ });
+ }
+
+ //移除按钮事件
+
+ target.removeChildGroupHandler = removeChildGroupHandlerFunc;
+
+
+ //添加按钮事件
+
+ target.addChildGroupHandler = addChildGroupHandlerFunc;
+
+
+ target.dealElement = dealElementFunc;
+
+
+
+ //取消编辑主机名按钮事件
+
+ target.cancelEditHostNameHandler = cancelEditHostNameHandlerFunc;
+
+ //主机名编辑保存按钮事件
+
+ target.saveHostNameHandler = saveHostNameHandlerFunc;
+
+ //主机名编辑按钮事件
+
+ target.editHostNameHandler = editHostNameHandlerFunc;
+
+
+ target.selectedIds = ko.observableArray([]);
+ target.siteList = ko.observable([]);
+ /////////////////////////////////////////////////////////////////
+ target.disableAdd = ko.computed(function () {
+ return target.siteList().length == maxItem;
+ });
+
+ ko.computed(function () {
+ target.siteList();
+ target.selectedIds();
+ setTimeout(function () {
+ renderCheckbox();
+ }, 100);
+ $("#pc_site_white_list_form").translate();
+ });
+
+ //网站白名单添加按钮事件
+
+ target.openAddSitePopoverHandler = openAddSitePopoverHandlerFunc;
+
+ //网站白名单列表选择框点击事件
+
+ target.checkboxClickHandler = checkboxClickHandlerFunc;
+
+ //获取网站白名单列表
+
+ target.fetchSiteWhiteList = fetchSiteWhiteListFunc;
+
+ //网站白名单删除函数
+
+ function removeSiteWhiteItem(ids) {
+ showConfirm('confirm_data_delete', function () {
+ showLoading();
+ service.removeSiteWhite({
+ ids: ids
+ }, function (data) {
+ target.fetchSiteWhiteList(function () {
+ successOverlay();
+ });
+ }, function (data) {
+ target.fetchSiteWhiteList(function () {
+ errorOverlay();
+ });
+ });
+ });
+ }
+ //网站白名单删除所有按钮事件
+
+ target.removeAllWhiteSite = removeAllWhiteSiteFunc;
+
+ //网站白名单删除按钮事件
+
+ target.removeSelectedWhiteSite = removeSelectedWhiteSiteFunc;
+
+ //网站白名单移除按钮事件
+
+ target.removeWhiteSite = removeWhiteSiteFunc;
+
+
+
+ //网站白名单添加框保存按钮事件
+
+ target.saveSiteWhite = saveSiteWhiteFunc;
+
+ //////////////////////////////////////////////////////////////////
+ target.notSave = ko.observable(false);
+ //获取时间限制信息
+
+ target.fetchTimeLimited = fetchTimeLimitedFunc;
+
+
+ //上网时间设置时间表格事件绑定
+
+ target.bindEvent = bindEventFunc;
+
+ //上网时间设置保存按钮事件
+
+ target.saveTimeLimitedHandler = saveTimeLimitedHandlerFunc;
+
+ //////////////////////////////////////////////////////////////////
+ var isBinded = false;
+ //上网规则标签点击事件
+
+ target.openRulePage = openRulePageFunc;
+ function openRulePageFunc() {
+ if (target.currentPage() == PAGES.RULE) {
+ return;
+ }
+ target.currentPage(PAGES.RULE);
+ target.currentUserInChildGroup(service.checkCurrentUserInChildGroup().result);
+ initTableData();
+ if (!isBinded) {
+ if (!target.currentUserInChildGroup()) {
+ target.bindEvent();
+ }
+ isBinded = true;
+ }
+ showLoading();
+ target.fetchTimeLimited();
+ target.fetchSiteWhiteList(function () {
+ hideLoading();
+ });
+ }
+
+ //获取儿童组设备列表
+ function fetchChildGroupListFunc(cb) {
+ service.childGroupList({}, function (data) {
+ target.currentUserInChildGroup(service.checkCurrentUserInChildGroup(data.devices).result);
+ target.childGroupList([]);
+ _.map(data.devices, function (elem, idx) {
+ elem.idx = idx;
+ elem.hostname = pcUtil.getHostName(elem.hostname, elem.mac, hostNameList);
+ });
+ target.childGroupList(data.devices);
+ if (_.isFunction(cb)) {
+ cb.apply(this);
+ }
+ });
+ }
+
+ //获取已连接设备列表
+ function fetchAttachedDevicesFunc(cb) {
+ target.attachedDevices([]);
+ var counter = 0;
+ var currDevices = [];
+ //RJ45 已连接设备
+ service.getAttachedCableDevices({}, function (data) {
+ counter++;
+ var devs = _.map(data.attachedDevices, function (elem) {
+ elem.idx = _.uniqueId('wireless_');
+ elem.hostName = pcUtil.getHostName(elem.hostName, elem.macAddress, hostNameList);
+ elem.inChildGroup = _.contains(target.childGroupMac(), elem.macAddress);
+ return elem;
+ });
+ if (counter != 1) {
+ target.attachedDevices(_.flatten([currDevices, devs]));
+ if (_.isFunction(cb)) {
+ cb.apply(this);
+ }
+ } else {
+ currDevices = devs;
+ }
+ });
+
+ //wifi 已连接设备
+ service.getCurrentlyAttachedDevicesInfo({}, function (data) {
+ counter++;
+ var devs = _.map(data.attachedDevices, function (elem) {
+ elem.idx = _.uniqueId('wireless_');
+ elem.hostName = pcUtil.getHostName(elem.hostName, elem.macAddress, hostNameList);
+ elem.inChildGroup = _.contains(target.childGroupMac(), elem.macAddress);
+ return elem;
+ });
+ if (counter != 1) {
+ target.attachedDevices(_.flatten([currDevices, devs]));
+ if (_.isFunction(cb)) {
+ cb.apply(this);
+ }
+ } else {
+ currDevices = devs;
+ }
+ });
+ }
+ //儿童组设备 标签按钮事件
+ function backToMainHandlerFunc() {
+ target.currentPage(PAGES.MAIN);
+ }
+
+ //移除按钮事件
+ function removeChildGroupHandlerFunc(ele) {
+ showLoading();
+ service.removeChildGroup(ele, function (data) {
+ target.fetchChildGroupList(function () {
+ target.fetchAttachedDevices(function () {
+ hideLoading();
+ });
+ });
+ }, function (data) {
+ errorOverlay();
+ });
+ }
+
+ //添加按钮事件
+ function addChildGroupHandlerFunc(data) {
+ var uMacAddr = service.getCurretnMAC();
+ if (uMacAddr != data.macAddress) {
+ addChildGroupFun(false, data);
+ } else {
+ showConfirm("parental_add_self", function () {
+ addChildGroupFun(true, data);
+ })
+ }
+ }
+
+ //取消编辑主机名按钮事件
+ function cancelEditHostNameHandlerFunc(eleData) {
+ target.dealElement(false, eleData.idx);
+ }
+
+ //主机名编辑保存按钮事件
+ function saveHostNameHandlerFunc(ele) {
+ var $hostInput = $("#hostname_input_" + ele.idx);
+ var hostname = $.trim($hostInput.val());
+ if (hostname.indexOf(" ") == 0 || hostname.lastIndexOf(" ") == (hostname.length - 1) || /[\*\+\$\[&:,;<>'"\\`\]¥]{1,32}/.test(hostname)) {
+ showAlert('modify_hostname_invalid');
+ return false;
+ }else if (hostname == '') {
+ $(".promptErrorLabel", "#confirm-message-container").text($.i18n.prop("required"));
+ var $closestTD = $hostInput.closest('td').addClass('has-error');
+ addTimeout(function () {
+ $closestTD.removeClass('has-error');
+ }, 5000);
+ showAlert('required');
+ return false;
+ }
+ showLoading();
+ ele.hostname = hostname;
+ service.editHostName(ele, function () {
+ service.getHostNameList({}, function (hostNameData) {
+ hostNameList = hostNameData.devices;
+ target.fetchChildGroupList(function () {
+ hideLoading();
+ });
+ target.fetchAttachedDevices();
+ });
+ }, function () {
+ errorOverlay();
+ });
+ }
+
+ //主机名编辑按钮事件
+ function editHostNameHandlerFunc(ele) {
+ $("#hostname_input_" + ele.idx).val(ele.hostname);
+ target.dealElement(true, ele.idx);
+ return false;
+ }
+ //网站白名单添加按钮事件
+ function openAddSitePopoverHandlerFunc() {
+ var addNewSiteTmpl = $("#addNewSiteTmpl").html();
+ popover.open({
+ target: $("#openAddSiteBtn"),
+ html: addNewSiteTmpl,
+ width: "300px",
+ validation: addValidation
+ });
+ }
+
+ //网站白名单列表选择框点击事件
+ function checkboxClickHandlerFunc(eleData, evt) {
+ addTimeout(function () {
+ target.selectedIds(getSelectedValues());
+ }, 100);
+ }
+ //获取网站白名单列表
+ function fetchSiteWhiteListFunc(cb) {
+ service.getSiteWhiteList({}, function (eledata) {
+ target.selectedIds([]);
+ target.siteList(eledata.siteList);
+ _.isFunction(cb) && cb.apply(this);
+ }, function () {
+ target.siteList([]);
+ _.isFunction(cb) && cb.apply(this);
+ });
+ }
+
+ //网站白名单删除所有按钮事件
+ function removeAllWhiteSiteFunc() {
+ removeSiteWhiteItem(getAllCheckboxValues());
+ }
+ //网站白名单删除按钮事件
+ function removeSelectedWhiteSiteFunc() {
+ removeSiteWhiteItem(getSelectedValues());
+ }
+ //网站白名单移除按钮事件
+ function removeWhiteSiteFunc(ele, evt) {
+ removeSiteWhiteItem([ele.id]);
+ }
+
+ //网站白名单添加框保存按钮事件
+ function saveSiteWhiteFunc(name, site) {
+ popover.hide();
+ var matched = _.find(target.siteList(), function (one) {
+ return one.site == site;
+ });
+ if (matched) {
+ showAlert("pc_link_exist", function () {
+ setTimeout(function () {
+ popover.show();
+ }, 200);
+ });
+ return false;
+ }
+
+ showLoading();
+ service.saveSiteWhite({
+ name: name,
+ site: site
+ }, function () {
+ target.fetchSiteWhiteList(function () {
+ popover.close();
+ successOverlay();
+ });
+ }, function () {
+ target.fetchSiteWhiteList(function () {
+ errorOverlay();
+ popover.show();
+ });
+ });
+ }
+
+ //上网时间设置时间表格事件绑定
+ function bindEventFunc() {
+ $("td:not('.col-head')", "#pc_time_limited_tbody").addClass('cursorhand').die().click(function () {
+ target.notSave(true);
+ $(this).toggleClass('active');
+ }).hover(function () {
+ var $this = $(this);
+ var w = $this.data('week');
+ var h = $this.data('hour');
+ $("tr:nth-child(" + (w + 1) + ") td:first-child", "#pc_time_limited_tbody").addClass('time_td_hover');
+ $("#col_" + h).addClass('time_td_hover');
+ if ($this.not('.active')) {
+ $this.addClass('time_td_hover');
+ }
+ }, function () {
+ var $this = $(this);
+ var w = $this.data('week');
+ var h = $this.data('hour');
+ $("tr:nth-child(" + (w + 1) + ") td:first-child", "#pc_time_limited_tbody").removeClass('time_td_hover');
+ $("#col_" + h).removeClass('time_td_hover');
+ $this.removeClass('time_td_hover');
+ });
+ }
+
+ //上网时间设置保存按钮事件
+ function saveTimeLimitedHandlerFunc() {
+ showLoading();
+ var tds = getSelectedTds();
+ var timeStr = getSavedData(tds);
+ service.saveTimeLimited({
+ time: timeStr
+ }, function () {
+ target.notSave(false);
+ successOverlay();
+ }, function () {
+ errorOverlay();
+ });
+ }
+
+ }
+
+ function dealElementFunc(flag, idx) {
+ if (flag == false) {
+ $("#edit_btn_" + idx + ",#hostname_txt_" + idx).show();
+ $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).hide();
+ } else {
+ $("#edit_btn_" + idx + ",#hostname_txt_" + idx).hide();
+ $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).show();
+ }
+ }
+
+ //获取时间限制信息
+ function fetchTimeLimitedFunc() {
+ service.getTimeLimited({}, function (ele) {
+ for (var ki in ele) {
+ for (var idx = 0; idx < ele[ki].length; idx++) {
+ var id = 'td_' + ki + '_' + ele[ki][idx];
+ $("#" + id).addClass('active');
+ }
+ }
+ }, function () {});
+ }
+
+ var pcUtil = {
+ getHostName: function (hostName, mac, hostNameList) {
+ var ele = _.find(hostNameList, function (ele) {
+ return ele.mac == mac;
+ });
+ return ele ? ele.hostname : hostName;
+ }
+ };
+ function getCheckboxValues(flag) {
+ var selectedValues = [];
+ $(":checkbox" + (flag ? ":checked" : ""), "#pb_white_list").each(function (i, n) {
+ selectedValues.push(n.value)
+ });
+ return selectedValues;
+ }
+ //获取列表中被选中项的value值
+
+ function getSelectedValues() {
+ return getCheckboxValues(true);
+ }
+ function getAllCheckboxValues() {
+ return getCheckboxValues(false);
+ }
+
+ //增加网站白名单表单提交函数绑定和校验规则设置
+
+ function addValidation() {
+ $('#whiteSiteAddForm').validate({
+ submitHandler: function () {
+ var name = $("#siteName").val();
+ var site = $("#siteLink").val();
+ pcVm.saveSiteWhite(name, site);
+ },
+ rules: {
+ siteName: 'siteName_check',
+ siteLink: 'siteLink_check'
+ }
+ });
+ }
+
+ function getSavedData(timeDatas) {
+ var ret = '';
+ for (var ki in timeDatas) {
+ var hours = _.sortBy(timeDatas[ki], function (n) {
+ return n;
+ });
+ if (timeDatas[ki].length) {
+ ret += ki + '+';
+ ret += hours.join(',');
+ ret += ';'
+ }
+ }
+ return ret.substring(0, ret.length - 1);
+ }
+ //获取时间表格选中的时间
+
+ function getSelectedTds() {
+ var defaultValue = {
+ '0': [],
+ '1': [],
+ '2': [],
+ '3': [],
+ '4': [],
+ '5': [],
+ '6': []
+ };
+ $("td.active", "#pc_time_limited_tbody").each(function (i, n) {
+ var $this = $(n);
+ var week = $this.data('week');
+ var hour = $this.data('hour');
+ defaultValue[week].push(hour);
+ });
+ return defaultValue;
+ }
+
+ function convertHour(hour) {
+ if (hour <= 16) {
+ return hour + 7;
+ } else {
+ return hour - 17;
+ }
+ }
+ //初始化时间表格
+
+ function initTableData() {
+ $("tr", "#pc_time_limited_tbody").each(function (idx, n) {
+ var $tr = $(n);
+ $("td:not(:first)", $tr).each(function (j, m) {
+ var $td = $(m);
+ var hour = convertHour(j);
+ $td.attr({
+ id: 'td_' + idx + '_' + hour
+ }).data({
+ week: idx,
+ hour: hour
+ });
+ });
+ });
+ $("td.active", "#pc_time_limited_tbody").removeClass("active");
+ $("thead td:not(:first)", "#pc_time_limited_form").each(function (idx, n) {
+ var hour = convertHour(idx);
+ $(n).attr({
+ id: 'col_' + hour
+ });
+ });
+ pcVm.notSave(false);
+ }
+
+
+ //页面初始化
+
+ function initialize() {
+
+ pcVm = new ParentalControlVM();
+ bindContainer(pcVm);
+ }
+ function bindContainer(pcVm)
+ {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(pcVm, container[0]);
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("firewall_dmz_set","underscore jquery knockout set service".split(" "),
+ function ( _, $, ko, config, service) {
+
+ //system dmz setting VM
+
+ function DmzSettingVM() {
+ var target = this;
+ var dmzInfo = getDmzSetting();
+ target.dmzSetting = ko.observable(dmzInfo.dmzSetting);
+ target.ipAddress = ko.observable(dmzInfo.ipAddress);
+ target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';
+
+ target.clear = clearFunc;
+ //应用按钮事件
+
+ target.save = saveFunc;
+
+ function saveFunc() {
+ showLoading();
+ var params = {};
+ params.dmzSetting = target.dmzSetting();
+ params.ipAddress = target.ipAddress();
+ service.setDmzSetting(params, function (result) {
+ if (result.result != "success") {
+ errorOverlay();
+ } else {
+ target.clear();
+ successOverlay();
+ }
+ });
+ }
+
+ }
+
+ function clearFunc() {
+ initialize();
+ }
+
+
+ //获取dmz 信息
+
+ function getDmzSetting() {
+ return service.getDmzSetting();
+ }
+
+ //初始化DmzSettingVM model
+
+ function initialize() {
+
+ var dmzVm = new DmzSettingVM();
+ bindContainer(dmzVm);
+ }
+ function bindContainer(dmzVm){
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(dmzVm, container[0]);
+ $('#dmzSettingForm').validate({
+ submitHandler: function () {
+ dmzVm.save();
+ },
+ rules: {
+ txtIpAddress: 'dmz_ip_check'
+ }
+ });
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("firewall","underscore jquery knockout set service".split(" "),
+
+function(_, $, ko, config, service) {
+
+ function FirewallVM() {
+ var target = this;
+ target.hasDdns = config.DDNS_SUPPORT;
+ target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
+ target.hasUrlFilter = config.HAS_URL;
+ target.hasUssd = config.HAS_USSD;
+ target.hasUpnp = config.HAS_UPNP;
+ }
+
+ function initialize() {
+ var fwVm = new FirewallVM();
+ bindingContainer(fwVm);
+ }
+ function bindingContainer(fwVm)
+ {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(fwVm, container[0]);
+ }
+ return {
+ init : initialize
+ };
+});
+
+define("ddns","underscore jquery knockout set service".split(" "), function (_, $, ko, config, service) {
+ var ddnsSetModes = _.map(config.DDNSSetMode, newOption);
+ var ddnsProviderList = _.map(config.DDNSDDP, newOption);
+ var ddns_mode_select = _.map(config.ddns_Modeselect, newOption);
+ function newOption(optItem) {
+ return new Option(optItem.name, optItem.value);
+ }
+ function DdnsViewModel() {
+ var target = this;
+ target.hasUssd = config.HAS_USSD;
+ target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
+ var data = service.getDdnsParams();
+ target.ddnsSetModes = ko.observableArray(ddnsSetModes);
+ target.ddnsProviderList = ko.observableArray(ddnsProviderList);
+ target.ddns_mode_select = ko.observableArray(ddns_mode_select);
+ target.currentMode = ko.observable(data.DDNS_Enable);
+ target.currentModeselect = ko.observable(data.DDNS_Mode);
+ target.currentProviderList = ko.observable("dyndns.org");
+ $.each(config.DDNSDDP, function (i, n) {
+ if (data.DDNSProvider == n.value) {
+ target.currentProviderList(data.DDNSProvider);
+ }
+ });
+ target.DDNSaccount = ko.observable(data.DDNSAccount);
+ target.DDNSpasswd = ko.observable(data.DDNSPassword);
+ target.DDNSname = ko.observable(data.DDNS);
+ target.DDNS_HashValue = ko.observable(data.DDNS_Hash_Value);
+ target.isddnsStatusTrans = ko.observable();
+ target.isEnableSet = ko.observable();
+ target.isHashValue = ko.observable();
+ target.isddnsaccount = ko.observable();
+ target.isddnspasswd = ko.observable();
+ target.isDDNSStatus = ko.observable();
+ target.isddnsdomainName = ko.observable();
+ target.isNone = ko.observable();
+ target.onStates = ko.observable();
+ target.showPassword_ddns = ko.observable(false);
+ target.showPasswordHandler_ddns = showPasswordHandler_ddns;
+ changeddnsProviderList();
+ target.changeDdnsProvider = changeDdnsProviderFunc;
+ changeSetDdnsMode();
+ target.changeSetDdnsMode = changeSetDdnsModeFunc;
+ updateScanDdnsStatus();
+ target.apply = applyFunc;
+ function updateScanDdnsStatus() {
+ var trans = "";
+ $.getJSON("/reqproc/proc_get", {
+ cmd: "getddns_status",
+ "_": new Date().getTime()
+ }, function (data) {
+ if (data.getddns_status == "0") {
+ trans = "register successful";
+ target.onStates(true);
+ } else if (data.getddns_status == "1") {
+ trans = "login error";
+ target.onStates(true);
+ } else if (data.getddns_status == "2") {
+ trans = "network error";
+ target.onStates(true);
+ } else if (data.getddns_status == "3") {
+ trans = "registering";
+ target.onStates(true);
+ } else if (data.getddns_status == "4") {
+ trans = "not registered";
+ target.onStates(true);
+ } else if (data.getddns_status == "5") {
+ trans = "error registering";
+ target.onStates(true);
+ } else if (data.getddns_status == "-1") {
+ trans = "";
+ target.onStates(true);
+ }
+ target.isddnsStatusTrans($.i18n.prop(trans));
+ addTimeout(updateScanDdnsStatus, 2000);
+ });
+ }
+ function changeSetDdnsMode() {
+ if (target.currentMode() != "1") {
+ target.isEnableSet(false);
+ } else {
+ target.isEnableSet(true);
+ }
+ return true;
+ }
+ function changeSetDdnsModeFunc() {
+ changeSetDdnsMode();
+ }
+ function showPasswordHandler_ddns() {
+ $("#ddns_secretcode_input").parent().find(".error").hide();
+ var checkbox = $("#showPassword_ddns:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showPassword_ddns(true);
+ } else {
+ target.showPassword_ddns(false);
+ }
+ }
+ function changeDdnsProviderFunc() {
+ if (data.DDNSProvider != target.currentProviderList()) {
+ target.DDNSaccount("");
+ target.DDNSpasswd("");
+ target.DDNSname("");
+ } else {
+ target.DDNSaccount(data.DDNSAccount);
+ target.DDNSpasswd(data.DDNSPassword);
+ target.DDNSname(data.DDNS);
+ }
+ changeddnsProviderList();
+ }
+ function changeddnsProviderList() {
+ if (target.currentProviderList() != "none") {
+ target.isddnsaccount(true);
+ target.isddnspasswd(true);
+ target.isddnsdomainName(true);
+ target.isHashValue(true);
+ target.isDDNSStatus(true);
+ } else {
+ target.isddnsaccount(false);
+ target.isddnspasswd(false);
+ target.isddnsdomainName(false);
+ target.isHashValue(false);
+ target.isDDNSStatus(false);
+ }
+ if (target.currentProviderList() != "freedns.afraid.org") {
+ target.isHashValue(false);
+ } else {
+ target.isHashValue(true);
+ }
+ return true;
+ }
+ function applyFunc() {
+ showLoading();
+ var params = {};
+ params.goformId = "DDNS";
+ params.DDNS_Enable = target.currentMode();
+ if (target.currentMode() == "1") {
+ params.DDNS_Mode = target.currentModeselect();
+ params.DDNSProvider = target.currentProviderList();
+ if (target.currentProviderList() != "none") {
+ params.DDNS = target.DDNSname();
+ params.DDNSPassword = target.DDNSpasswd();
+ params.DDNSAccount = target.DDNSaccount();
+ }
+ if (target.currentProviderList() == "freedns.afraid.org") {
+ params.DDNS_Hash_Value = target.DDNS_HashValue();
+ }
+ }
+ service.setDDNSForward(params, function (result) {
+ if (result.result == "success") {
+ successOverlay();
+ data = service.getDdnsParams();
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+ }
+ function initialize() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var vm = new DdnsViewModel();
+ ko.applyBindings(vm, container[0]);
+ $("#ddnsForm").validate({
+ submitHandler: function () {
+ vm.apply();
+ },
+ rules: {
+ ddns_secretcode_input: "secretcode_check",
+ DDNS_Hash_Value: "ddns_hashvalue_check",
+ ddns_secretcode_inputshow: "secretcode_check"
+ },
+ errorPlacement: function (error, element) {
+ var id = element.attr("id");
+ if (id == "ddns_secretcode_input" || id == "ddns_secretcode_inputshow") {
+ error.insertAfter("#lblShowPassword");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+ }
+ return {
+ init: initialize
+ };
+});
+
+
+//选网模块
+
+define("network_net_select","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var selectModes = _.map(config.AUTO_MODES, function (item) {
+ return new Option(item.name, item.value);
+ });
+
+ //选网功能view model
+
+ function NetSelectVM() {
+ var target = this;
+
+ target.networkList = ko.observableArray([]);
+ target.selectNetwork = ko.observable('');
+ target.enableFlag = ko.observable(true);
+ target.types = ko.observableArray(selectModes);
+ target.selectedType = ko.observable();
+ target.selectMode = ko.observable();
+
+ target.networkText = networkTextFunc;
+
+ target.networkStatusId = networkStatusIdFunc;
+
+ target.networkStatus = networkStatusFunc;
+
+ target.subnetworkType = subnetworkTypeFunc;
+
+ target.networkType = networkTypeFunc;
+
+ target.operatorName = operatorNameFunc;
+
+ target.networkValue = networkValueFunc;
+
+ target.networkTypeId = networkTypeIdFunc;
+
+ target.subnetTypeId = subnetTypeIdFunc;
+ //手动搜网.
+
+ target.search = searchFunc;
+
+ //自动选网时设置网络模式.
+
+ target.save = saveFunc;
+
+ target.checkEnable = checkEnableFunc;
+
+ //注册选择的网络.
+
+ target.register = registerFunc;
+
+ //init data
+ target.checkEnable();
+ var info = getNetSelectInfo();
+ if ("manual_select" == info.net_select_mode || "manual_select" == info.m_netselect_save) {
+ target.selectMode("manual_select");
+ } else {
+ target.selectMode("auto_select");
+ }
+
+ target.selectedType(info.net_select);
+
+ //注册选择的网络.
+ function registerFunc() {
+ showLoading('registering_net');
+ var networkToSet = target.selectNetwork().split(',');
+ service.setNetwork(networkToSet[0], parseInt(networkToSet[1]), parseInt(networkToSet[2]), function (result) {
+ if (result) {
+ target.networkList([]);
+ var autoType = getNetSelectInfo();
+ target.selectedType(autoType.net_select);
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+
+ function checkEnableFunc() {
+ var status = service.getStatusInfo();
+ if (status.connectStatus == "ppp_connected" || status.connectStatus == "ppp_connecting") {
+ target.enableFlag(false);
+ } else {
+ target.enableFlag(true);
+ }
+ }
+
+ //自动选网时设置网络模式.
+ function saveFunc() {
+ showLoading();
+
+ //AutoSelect call SetBearerPreference
+ var params = {};
+ params.strBearerPreference = target.selectedType();
+ service.setBearerPreference(params, function (result) {
+ if (result.result == "success") {
+ target.networkList([]);
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+
+ //手动搜网.
+ function searchFunc() {
+ showLoading('searching_net');
+ service.scanForNetwork(function (result, networkList) {
+ hideLoading();
+ if (result) {
+ target.networkList(networkList);
+ for (var i = 0; i < networkList.length; i++) {
+ var n = networkList[i];
+ if (n.nState == '2') {
+ target.selectNetwork(n.strNumeric + ',' + n.nRat + ',' + n.SubAct);
+ return;
+ }
+ }
+ } else {
+ target.networkList([]);
+ }
+ });
+ }
+
+ function subnetTypeIdFunc(data) {
+ return getSubNetworkTypeTog(data.nRat, data.SubAct);
+ }
+
+ function networkTypeIdFunc(data) {
+ return getNetworkType(data.nRat);
+ }
+
+ function networkValueFunc(data) {
+ var result = [];
+ result.push(data.strNumeric); //strNumeric
+ result.push(data.nRat); //nRat
+ result.push(data.SubAct);
+ return result.join(',');
+ }
+
+ function operatorNameFunc(data) {
+ return data.strShortName;
+ }
+
+ function networkTypeFunc(data) {
+ var result = getNetworkType(data.nRat);
+ if (result == "auto")
+ result = $.i18n.prop("auto");
+ return result;
+ }
+
+ function subnetworkTypeFunc(data) {
+ var result = getSubNetworkTypeTog(data.nRat, data.SubAct);
+ return result;
+ }
+
+ function networkStatusFunc(data) {
+ return $.i18n.prop(getNetworkStatusTog(data.nState));
+ }
+
+ function networkStatusIdFunc(data) {
+ return getNetworkStatusTog(data.nState);
+ }
+
+ function networkTextFunc(data) {
+ return data.strNumeric;
+ }
+
+ }
+
+ //获取网络选择信息.
+
+ function getNetSelectInfo() {
+ return service.getNetSelectInfo();
+ }
+
+ //搜网结果中的状态转换为对应的语言项.
+
+ function getNetworkStatusTog(status) {
+ if ("3" == status) {
+ return "forbidden";
+ } else if ("2" == status) {
+ return "current";
+ } else if ("1" == status) {
+ return "available";
+ }else if ("0" == status) {
+ return "unknown";
+ }
+ }
+ //子网络类型转换.
+
+ function getSubNetworkTypeTog(type, subtype) {
+ var type_3g = [2, 4, 5, 6, 8];
+ if ("1" == subtype) {
+ if ("7" == type) {
+ subtype = "FDD-LTE";
+ } else if ($.inArray(type, type_3g) != -1) {
+ subtype = "WCDMA";
+ }else {
+ subtype = "GSM";
+ }
+ } else if ("0" == subtype) {
+ if ("7" == type) {
+ subtype = "TD-LTE";
+ } else if ($.inArray(type, type_3g) != -1) {
+ subtype = "TD-SCDMA";
+ } else {
+ subtype = "GSM";
+ }
+ } else {
+ subtype = "";
+ }
+ return subtype;
+ }
+ //网络类型转换.
+
+ function getNetworkType(type) {
+ if ("7" == type) {
+ return "4G";
+ } else if ("2" == type) {
+ return "3G";
+ } else if ("0" == type) {
+ return "2G";
+ } else {
+ return "auto";
+ }
+ }
+
+ function bindContainer(vm){
+
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+ }
+
+ //初始化选网功能view model.
+
+ function initialize() {
+ var vm = new NetSelectVM();
+ bindContainer(vm);
+ addInterval(vm.checkEnable, 1000);
+ }
+
+ return {
+ init: initialize
+ };
+});
+define("locknet","jquery knockout service jquery set main".split(" "),
+ function ($, ko, service, config, home) {
+
+ function initialize() {
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ var vm = new locknetViewMode();
+ ko.applyBindings(vm, container);
+
+ $("#frmNetworkLock").validate({
+ submitHandler: function () {
+ vm.unlock();
+ },
+ rules: {
+ txtLockNumber: "unlock_code_check"
+ }
+ });
+ }
+
+ function locknetViewMode() {
+ var target = this;
+ var curCableMode = false;
+ target.isCPE = config.PRODUCT_TYPE == 'CPE';
+ target.hasRj45 = config.RJ45_SUPPORT;
+ target.hasSms = config.HAS_SMS;
+ target.hasPhonebook = config.HAS_PHONEBOOK;
+ target.isSupportSD = config.SD_CARD_SUPPORT;
+ if (config.WIFI_SUPPORT_QR_SWITCH == false) {
+ target.showQRCode = config.WIFI_SUPPORT_QR_CODE;
+ } else {
+ var wifiInfo = service.getWifiBasic();
+ target.showQRCode = config.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
+ }
+ if(config.WIFI_SUPPORT_QR_CODE){
+ target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + $.now();
+ } else {
+ target.qrcodeSrc = './pic/res_blacktrans.png';
+ }
+ target.hasParentalControl = ko.observable(config.HAS_PARENTAL_CONTROL && curCableMode);
+ target.deviceInfo = ko.observable([]);
+ target.isHomePage = ko.observable(false);
+ if (window.location.hash == "#main") {
+ target.isHomePage(true);
+ }
+
+ target.supportUnlock = config.NETWORK_UNLOCK_SUPPORT;
+ target.unlockCode = ko.observable();
+
+ var info = service.getNetworkUnlockTimes();
+ target.times = ko.observable(info.unlock_nck_time);
+
+ //显示工作模式设置窗口
+ target.showOpModeWindow = showOpModeWindowFunc;
+
+ target.isLoggedIn = ko.observable(false);
+ target.enableFlag = ko.observable(false);
+ //解锁
+ target.unlock = unlockFunc;
+
+ //更新工作模式状态
+ target.refreshOpmodeInfo = refreshOpmodeInfoFunc;
+
+ //定时检查工作模式状态
+ if (target.hasRj45) {
+ target.refreshOpmodeInfo();
+ addInterval(function () {
+ target.refreshOpmodeInfo();
+ }, 1000);
+ }
+
+ //更新工作模式状态
+ function refreshOpmodeInfoFunc() {
+ var obj = service.getStatusInfo();
+ target.isLoggedIn(obj.isLoggedIn);
+
+ if (!curCableMode && checkCableMode(obj.blc_wan_mode)) { //如果有线,则重新加载
+ window.location.reload();
+ return;
+ }
+
+ curCableMode = checkCableMode(obj.blc_wan_mode);
+ target.hasParentalControl(config.HAS_PARENTAL_CONTROL && curCableMode);
+ if (curCableMode && obj.ethWanMode.toUpperCase() == "DHCP") {
+ target.enableFlag(true);
+ } else if ((!curCableMode && obj.connectStatus != "ppp_disconnected") || (curCableMode && obj.rj45ConnectStatus != "idle" && obj.rj45ConnectStatus != "dead")) {
+ target.enableFlag(false);
+ } else {
+ target.enableFlag(true);
+ }
+ var getMode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;
+ var currMode = "";
+ switch (getMode) {
+ case "PPP":
+ currMode = "opmode_gateway";
+ break;
+ case "PPPOE":
+ currMode = "opmode_cable";
+ break;
+ case "AUTO":
+ currMode = "opmode_auto";
+ break;
+ default:
+ break;
+ }
+ $("#opmode").attr("data-trans", currMode).text($.i18n.prop(currMode));
+ }
+
+ //解锁
+ function unlockFunc() {
+ showLoading();
+ service.unlockNetwork({
+ unlock_network_code: target.unlockCode()
+ }, function (data) {
+ target.unlockCode("");
+ if (data && data.result == "success") {
+ successOverlay();
+ if (window.location.hash == "#main") {
+ setTimeout(function () {
+ window.location.reload();
+ }, 500);
+ } else {
+ window.location.hash = "#main";
+ }
+ } else {
+ var info = service.getNetworkUnlockTimes();
+ target.times(info.unlock_nck_time);
+ errorOverlay();
+ }
+ })
+ }
+
+ //显示工作模式设置窗口
+ function showOpModeWindowFunc() {
+ showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
+ }
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+// RJ45联网设置模块
+
+define("network_dial_set_cpe","underscore jquery knockout set service".split(" "),
+function(_, $, ko, config, service) {
+ var dialActions = _.map(config.dialActions, function(elem){
+ return new Option(elem.name, elem.value);
+ });
+
+ var dialModes = _.map(config.pppoeModes, function(elem) {
+ return new Option(elem.name, elem.value);
+ });
+
+ var checkStatusTimer = 0;
+ var checkConCounter = 0;
+ var timeoutTipShowed = false;
+
+ // 联网设置view model.
+
+ function PPPoEViewModel() {
+ var pppObj = service.getPppoeParams();
+ var ethParams = pppObj;
+ var target = this;
+
+ target.staticNoticeShow = ko.observable();
+ target.dhcpNoticeShow = ko.observable();
+ target.pppoeNoticeShow = ko.observable();
+ target.autoNoticeShow = ko.observable();
+ target.staticNotice = ko.observable();
+ target.dhcpNotice = ko.observable();
+ target.pppoeNotice = ko.observable();
+ target.autoNotice = ko.observable();
+ target.dhcpNoticeText = ko.observable();
+ target.staticNoticeText = ko.observable();
+ target.pppoeNoticeText = ko.observable();
+ target.autoNoticeText = ko.observable();
+ target.currentMode = ko.observable(pppObj.ethwan_mode);//auto dhcp pppoe static
+ target.showPassword = ko.observable(false);
+ target.modes = ko.observableArray(dialModes);
+ target.isPppoeMode = ko.observable(false);
+ target.isStaticMode = ko.observable(false);
+ target.isAutoMode = ko.observable(false);
+ target.action = ko.observable();
+ target.btnTrans = ko.observable();
+ target.enableFlag = ko.observable();
+ target.isShowDisbtn = ko.observable();
+ target.isShowCancelbtn = ko.observable();
+
+ if(pppObj.rj45_state == "dead"){
+ checkRj45DeadTip();
+ } else if(pppObj.rj45_state == "connect"){
+ timeoutTipShowed = true;
+ setRj45CheckTimer("connect");
+ } else if(pppObj.rj45_state == "working"){
+ setRj45WorkingTip();
+ }
+
+ target.user = ko.observable(pppObj.pppoe_username);
+ target.password = ko.observable(pppObj.pppoe_cc);
+ target.autoUser = ko.observable(pppObj.pppoe_username);
+ target.autoPassword = ko.observable(pppObj.pppoe_cc);
+ target.pppMode = ko.observable(pppObj.ethwan_dialmode);
+ initContronler();
+
+
+ //下拉框选择改变下面DIV模块
+ target.changeModeDiv = changeModeDivFunc;
+
+ target.radioHandler = radioHandlerFunc;
+
+ target.primaryDNS = ko.observable(pppObj.static_wan_primary_dns);
+ target.secondaryDNS = ko.observable(pppObj.static_wan_secondary_dns);
+ target.ipAddress = ko.observable(pppObj.static_wan_ipaddr);
+ target.subnetMask = ko.observable(pppObj.static_wan_netmask);
+ target.defaultGateway = ko.observable(pppObj.static_wan_gateway);
+
+ addInterval(function(){
+ ethParams = service.getPppoeParams();
+ pppObj.rj45_state = ethParams.rj45_state;
+ initContronler();
+ }, 1000);
+
+ // 取消连接按钮事件.
+
+ target.cancelConnect = cancelConnectFunc;
+
+ // 应用按钮事件.
+
+ target.save = saveFunc;
+
+ //密码显示事件
+ target.showPasswordHandler = function () {
+ var checkbox = $("#showPassword:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showPassword(true);
+ } else {
+ target.showPassword(false);
+ }
+ };
+
+ // 更新当前界面状态、按钮、提示语等.
+
+ function initContronler() {
+ checkRj45DeadTip();
+ if(target.currentMode() == "PPPOE"){
+ target.isPppoeMode(true);
+ target.isStaticMode(false);
+ target.isAutoMode(false);
+ target.staticNoticeShow(false);
+ target.dhcpNoticeShow(false);
+ target.autoNoticeShow(false);
+ } else if(target.currentMode() == "AUTO"){
+ target.isStaticMode(false);
+ target.isPppoeMode(false);
+ target.isAutoMode(true);
+ target.dhcpNoticeShow(false);
+ target.pppoeNoticeShow(false);
+ target.staticNoticeShow(false);
+ } else if(target.currentMode() == "STATIC"){
+ target.isStaticMode(true);
+ target.isPppoeMode(false);
+ target.isAutoMode(false);
+ target.dhcpNoticeShow(false);
+ target.pppoeNoticeShow(false);
+ target.autoNoticeShow(false);
+ } else{
+ target.isStaticMode(false);
+ target.isPppoeMode(false);
+ target.isAutoMode(false);
+ target.staticNoticeShow(false);
+ target.pppoeNoticeShow(false);
+ target.autoNoticeShow(false);
+ }
+ if(ethParams.ethwan_dialmode != "auto_dial" && (pppObj.rj45_state == "working" || pppObj.rj45_state =="connect") ){
+ target.enableFlag(false);
+ } else {
+ target.enableFlag(true);
+ }
+ if(pppObj.rj45_state == "connect"){
+ if(target.pppMode() == "auto_dial"){
+ target.action("connect");
+ }else{
+ target.action("disconnect");
+ }
+ } else if(pppObj.rj45_state == "working"){
+ target.action("disconnect");
+ }else{
+ target.action("connect");
+ }
+ //应用/连接按钮
+ if(target.pppMode() != "auto_dial" && target.currentMode() == ethParams.ethwan_mode){
+ target.btnTrans("connect");
+ } else{
+ target.btnTrans("apply");
+ }
+ if(pppObj.rj45_state != "idle"){
+ $("#pppoeApply").attr("disabled", true);
+ }else {
+ $("#pppoeApply").attr("disabled", false);
+ }
+
+ //取消/断开按钮
+ target.isShowDisbtn(target.pppMode() != "auto_dial" && pppObj.rj45_state == "working");
+ target.isShowCancelbtn(target.pppMode() != "auto_dial" && pppObj.rj45_state == "connect");
+
+ $("#pppoeApply").translate();
+ }
+ // 设置后通过定时检查rj45_state状态,判断连接或断开操作结果.
+
+ function setRj45CheckTimer(action){
+ checkStatusTimer && window.clearInterval(checkStatusTimer);
+ if("connect" != action){
+ checkStatusTimer = addInterval(function () {
+ checkDisconnectStatus();
+ }, 2000);
+ }else{
+ if(target.currentMode() == "PPPOE"){
+ target.pppoeNoticeShow(true);
+ target.pppoeNotice("pppoe_processing");
+ target.pppoeNoticeText($.i18n.prop("pppoe_processing"));
+ } else if(target.currentMode() == "STATIC"){
+ target.staticNoticeShow(true);
+ target.staticNotice("static_processing");
+ target.staticNoticeText($.i18n.prop("static_processing"));
+ } else if(target.currentMode() == "DHCP"){
+ target.dhcpNoticeShow(true);
+ target.dhcpNotice("dyn_processing");
+ target.dhcpNoticeText($.i18n.prop("dyn_processing"));
+ }else{
+ target.autoNoticeShow(true);
+ target.autoNotice("auto_processing");
+ target.autoNoticeText($.i18n.prop("auto_processing"));
+ }
+ checkStatusTimer = addInterval(function () {
+ checkConnectionStatus();
+ }, 2000);
+ }
+ }
+ // 设置后通过定时检查rj45_state状态,判断连接操作结果.
+
+ function checkConnectionStatus(){
+ if(checkConCounter < 1){
+ checkConCounter++;
+ return;
+ }
+ if(pppObj.rj45_state == "connect"){
+ if(target.currentMode() != ethParams.ethwan_mode){
+ if(target.currentMode() == "AUTO"){
+ target.autoNoticeShow(true);
+ }else if(target.currentMode() == "PPPOE"){
+ target.pppoeNoticeShow(true);
+ }else if(target.currentMode() == "STATIC"){
+ target.staticNoticeShow(true);
+ }else if(target.currentMode() == "DHCP"){
+ target.dhcpNoticeShow(true);
+ }
+ }
+ if(checkConCounter > 6){
+ if(timeoutTipShowed == false){
+ timeoutTipShowed = true;
+ showAlert("ussd_operation_timeout");
+ }
+ }
+ checkConCounter++;
+ } else if (pppObj.rj45_state == "working") {
+ hideLoading();
+ setRj45WorkingTip();
+ window.clearInterval(checkStatusTimer);
+ } else if (pppObj.rj45_state == "dead") {
+ hideLoading();
+ checkRj45DeadTip();
+ window.clearInterval(checkStatusTimer);
+ } else if(pppObj.rj45_state == "idle"){
+ hideLoading();
+ if(target.currentMode() == "DHCP" && ethParams.ethwan_mode == "DHCP") {
+ timeoutTipShowed == false && target.dhcpNoticeShow(true);
+ target.dhcpNotice("dyn_fail");
+ target.dhcpNoticeText($.i18n.prop("dyn_fail"));
+ }
+ if(target.currentMode() == "STATIC" && ethParams.ethwan_mode == "STATIC") {
+ timeoutTipShowed == false && target.staticNoticeShow(true);
+ target.staticNotice("static_fail");
+ target.staticNoticeText($.i18n.prop("static_fail"));
+ }
+ if(target.currentMode() == "PPPOE" && ethParams.ethwan_mode == "PPPOE") {
+ timeoutTipShowed == false && target.pppoeNoticeShow(true);
+ target.pppoeNotice("pppoe_fail");
+ target.pppoeNoticeText($.i18n.prop("pppoe_fail"));
+ }
+ if(target.currentMode() == "AUTO" && ethParams.ethwan_mode == "AUTO") {
+ timeoutTipShowed == false && target.autoNoticeShow(true);
+ target.autoNotice("auto_fail");
+ target.autoNoticeText($.i18n.prop("auto_fail"));
+ }
+ window.clearInterval(checkStatusTimer);
+ } else{
+ hideLoading();
+ window.clearInterval(checkStatusTimer);
+ }
+ }
+ // 设置连接成功时提示语状态.
+
+ function setRj45WorkingTip(){
+ if(target.currentMode() == ethParams.ethwan_mode){
+ if(target.currentMode() == "AUTO") {
+ target.autoNoticeShow(true);
+ target.autoNotice("auto_success");
+ target.autoNoticeText($.i18n.prop("auto_success"));
+ }else if(target.currentMode() == "PPPOE") {
+ target.pppoeNoticeShow(true);
+ target.pppoeNotice("pppoe_success");
+ target.pppoeNoticeText($.i18n.prop("pppoe_success"));
+ }else if(target.currentMode() == "STATIC") {
+ target.staticNoticeShow(true);
+ target.staticNotice("static_success");
+ target.staticNoticeText($.i18n.prop("static_success"));
+ }else if(target.currentMode() == "DHCP" ) {
+ target.dhcpNoticeShow(true);
+ target.dhcpNotice("dyn_success");
+ target.dhcpNoticeText($.i18n.prop("dyn_success"));
+ }
+ }
+ }
+
+ // 设置网线断开提示语状态.
+
+ function checkRj45DeadTip(){
+ if(pppObj.rj45_state != "dead"){
+ if(target.currentMode() == "AUTO" && target.autoNotice() == "pppoe_msg") {
+ target.autoNoticeShow(false);
+ }else if(target.currentMode() == "PPPOE" && target.pppoeNotice() == "pppoe_msg") {
+ target.pppoeNoticeShow(false);
+ }else if(target.currentMode() == "STATIC" && target.staticNotice() == "pppoe_msg") {
+ target.staticNoticeShow(false);
+ }else if(target.currentMode() == "DHCP" && target.dhcpNotice() == "pppoe_msg") {
+ target.dhcpNoticeShow(false);
+ }
+
+ } else{
+ target.dhcpNotice("pppoe_msg");
+ target.dhcpNoticeText($.i18n.prop("pppoe_msg"));
+ target.staticNotice("pppoe_msg");
+ target.staticNoticeText($.i18n.prop("pppoe_msg"));
+ target.pppoeNotice("pppoe_msg");
+ target.pppoeNoticeText($.i18n.prop("pppoe_msg"));
+ target.autoNotice("pppoe_msg");
+ target.autoNoticeText($.i18n.prop("pppoe_msg"));
+ if(target.currentMode() == "AUTO") {
+ target.autoNoticeShow(true);
+ }else if(target.currentMode() == "PPPOE") {
+ target.pppoeNoticeShow(true);
+ }else if(target.currentMode() == "STATIC") {
+ target.staticNoticeShow(true);
+ }else if(target.currentMode() == "DHCP") {
+ target.dhcpNoticeShow(true);
+ }
+ }
+ }
+ // 设置后通过定时检查rj45_state状态,判断断开操作结果.
+
+ function checkDisconnectStatus(){
+ if(checkConCounter < 1){
+ checkConCounter++;
+ } else if (pppObj.rj45_state != "working" && pppObj.rj45_state != "connect") {
+ target.dhcpNoticeShow(false);
+ target.staticNoticeShow(false);
+ target.pppoeNoticeShow(false);
+ target.autoNoticeShow(false);
+ window.clearInterval(checkStatusTimer);
+ successOverlay();
+ } else if(checkConCounter > 6){
+ if(timeoutTipShowed == false){
+ timeoutTipShowed = true;
+ showAlert("ussd_operation_timeout");
+ }
+ window.clearInterval(checkStatusTimer);
+ } else if(checkConCounter < 7) {
+ checkConCounter++;
+ } else {
+ hideLoading();
+ window.clearInterval(checkStatusTimer);
+ }
+ }
+
+ //应用按钮事件.
+ function saveFunc(){
+ target.dhcpNoticeShow(false);
+ target.staticNoticeShow(false);
+ target.pppoeNoticeShow(false);
+ target.autoNoticeShow(false);
+ if(pppObj.rj45_state == "dead"){
+ showAlert("pppoe_msg");
+ return;
+ }
+ var requestParams = {};
+ if($("#pppoe_mode").val() == "PPPOE") {
+ requestParams = $.extend({}, {
+ goformId: "WAN_GATEWAYMODE_PPPOE",
+ pppoe_username: target.user(),
+ pppoe_cc: target.password()
+ });
+ } else if($("#pppoe_mode").val() == "AUTO") {
+ requestParams = $.extend({}, {
+ goformId: "WAN_GATEWAYMODE_AUTO",
+ pppoe_username: target.autoUser(),
+ pppoe_cc: target.autoPassword()
+ });
+ } else if($("#pppoe_mode").val() == "STATIC") {
+ if(target.ipAddress() == target.defaultGateway()){
+ showAlert("ip_gate_not_same");
+ return;
+ }
+ if(isStaticIPValid(target.ipAddress(), pppObj.lan_ipaddr, pppObj.lan_netmask)){
+ showAlert("ip_innergate_not_same");
+ return;
+ }
+ requestParams = $.extend({}, {
+ goformId: "WAN_GATEWAYMODE_STATIC",
+ static_wan_ipaddr: target.ipAddress(),
+ static_wan_netmask: target.subnetMask(),
+ static_wan_gateway: target.defaultGateway(),
+ static_wan_primary_dns: target.primaryDNS(),
+ static_wan_secondary_dns: target.secondaryDNS(),
+ WAN_MODE: "STATIC"
+ });
+ } else {
+ requestParams = $.extend({}, {
+ goformId: "WAN_GATEWAYMODE_DHCP"
+ });
+ }
+ requestParams.action_link = "connect";
+ requestParams.dial_mode = target.pppMode();
+ showLoading("waiting");
+
+ service.setPppoeDialMode(requestParams, function(data){
+ if(data.result){
+ target.currentMode($("#pppoe_mode").val());
+ pppObj = service.getPppoeParams();
+ checkConCounter = 0;
+ timeoutTipShowed = false;
+ setRj45CheckTimer("connect");
+ $("#pppoeApply").translate();
+ } else {
+ errorOverlay("pppoe_message_send_fail");
+ }
+ });
+
+ }
+
+ //取消连接按钮事件.
+ function cancelConnectFunc(){
+ target.dhcpNoticeShow(false);
+ target.staticNoticeShow(false);
+ target.pppoeNoticeShow(false);
+ target.autoNoticeShow(false);
+ if(pppObj.rj45_state == "dead"){
+ showAlert("pppoe_msg");
+ return;
+ }
+ var requestParams = {
+ dial_mode: target.pppMode(),
+ action_link: "disconnect"
+ };
+ if(pppObj.ethwan_mode == "PPPOE") {
+ requestParams = $.extend(requestParams, {
+ goformId: "WAN_GATEWAYMODE_PPPOE",
+ pppoe_username: pppObj.pppoe_username,
+ pppoe_cc: pppObj.pppoe_cc
+ });
+ }else if(pppObj.ethwan_mode == "AUTO") {
+ requestParams = $.extend(requestParams, {
+ goformId: "WAN_GATEWAYMODE_AUTO",
+ pppoe_username: pppObj.pppoe_username,
+ pppoe_cc: pppObj.pppoe_cc
+ });
+ }else if(pppObj.ethwan_mode == "STATIC") {
+ requestParams = $.extend(requestParams, {
+ goformId: "WAN_GATEWAYMODE_STATIC",
+ static_wan_ipaddr: pppObj.static_wan_ipaddr,
+ static_wan_netmask: pppObj.static_wan_netmask,
+ static_wan_gateway: pppObj.static_wan_gateway,
+ static_wan_primary_dns: pppObj.static_wan_primary_dns,
+ static_wan_secondary_dns: pppObj.static_wan_secondary_dns,
+ WAN_MODE: "STATIC"
+ });
+ }else {
+ requestParams = $.extend(requestParams, {
+ goformId: "WAN_GATEWAYMODE_DHCP"
+ });
+ }
+ showLoading("waiting");
+ service.setPppoeDialMode(requestParams, function(data){
+ if(data.result){
+ checkConCounter = 0;
+ timeoutTipShowed = false;
+ setRj45CheckTimer("disconnect");
+ $("#pppoeApply").translate();
+ } else {
+ errorOverlay("pppoe_message_send_fail");
+ }
+ });
+
+ }
+
+ function radioHandlerFunc(){
+ initContronler();
+ return true;
+ }
+
+ function changeModeDivFunc(){
+ initContronler();
+ }
+
+ }
+
+ function bindContainer(vm){
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+
+ }
+ // 联网设置初始化.
+
+ function initialize() {
+ var vm = new PPPoEViewModel();
+ bindContainer(vm);
+
+ $("#pppoeApply").translate();
+
+ $('#pppoeForm').validate({
+ submitHandler : function() {
+ vm.save();
+ },
+ rules: {
+ txtPin: "wps_pin_check",
+ txtIpAddress: "dmz_ip_check",
+ txtSubnetMask: {
+ ipv4: true,
+ subnetmask_check: true
+ },
+ txtDefaultGateway: {
+ ipv4: true,
+ gateway_check: true
+ },
+ txtPrimaryDNS: {
+ ipv4: true,
+ dns_check:true
+ },
+ txtSecondaryDNS: {
+ ipv4: true,
+ dns_check:true
+ }
+ }
+ });
+ }
+
+
+//from 4.0
+ // 有效DNS检查.
+
+function validateDns(dns){
+ if ( "0.0.0.0" == dns || "255.255.255.255" == dns) {
+ return false;
+ }
+ return true;
+}
+ // 联网设置初始化.
+
+function isStaticIPValid(ip, lanip, lanmask){
+ if(!ip || !lanip || !lanmask){//各参数不能为空
+ return false;
+ }
+ if(ip == lanip){// 与内网IP相等
+ return true;
+ }
+ var res1 = [], res2 = [], mask = [];
+ addr1 = ip.split(".");
+ addr2 = lanip.split(".");
+ mask = lanmask.split(".");
+ for(var i = 0; i < addr1.length; i += 1){
+ res1.push(parseInt(addr1[i]) & parseInt(mask[i]));
+ res2.push(parseInt(addr2[i]) & parseInt(mask[i]));
+ }
+ if(res1.join(".") == res2.join(".")){//在同一个网段
+ return true;
+ }else{//不在同一个网段
+ return false;
+ }
+}
+
+// 有效子网掩码验证.
+
+function isNetmaskIPValid(ip) {
+ if (ip == 255 || ip == 254 || ip == 252 || ip == 248
+ || ip == 240 || ip == 224 || ip == 192 || ip == 128 || ip == 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+ // 有效子网掩码检查.
+
+function validateNetmask(netmask) {
+ var array = new Array();
+ array = netmask.split(".");
+
+ if (array.length != 4) {
+ return false;
+ }
+
+ array[0] = parseInt(array[0]);
+ array[1] = parseInt(array[1]);
+ array[2] = parseInt(array[2]);
+ array[3] = parseInt(array[3]);
+
+ if (array[3] != 0) {
+ if (array[2] != 255 || array[1] != 255 || array[0] != 255) {
+ return false;
+ } else {
+ if (!isNetmaskIPValid(array[3])) {
+ return false;
+ }
+ }
+ }
+
+ if (array[2] != 0) {
+ if (array[1] != 255 || array[0] != 255) {
+ return false;
+ } else {
+ if (!isNetmaskIPValid(array[2])) {
+ return false;
+ }
+ }
+ }
+
+ if (array[1] != 0) {
+ if (array[0] != 255) {
+ return false;
+ } else{
+ if (!isNetmaskIPValid(array[1])) {
+ return false;
+ }
+ }
+ }
+ if(array[0]!=255) {
+ return false;
+ }
+ if ( "0.0.0.0" == netmask || "255.255.255.255" == netmask) {
+ return false;
+ }
+ return true;
+}
+
+ // subnetmask_check校验规则
+
+jQuery.validator.addMethod("subnetmask_check", function (value, element, param) {
+ var result = validateNetmask(value);
+ return this.optional(element) || result;
+});
+ // dns_check校验规则
+
+jQuery.validator.addMethod("dns_check", function (value, element, param) {
+ var result = validateDns(value);
+ return this.optional(element) || result;
+});
+ // 有效网关检查.
+
+function validateGateway(wanIp, netmaskIp, gatewayIp) {
+ if(myConcat(wanIp,netmaskIp) == myConcat(netmaskIp, gatewayIp)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+ // IP和子网掩码转换成数组形式并相与,返回相与后的IP.
+
+function myConcat(ip1,ip2){
+ var result = [];
+ var iplArr = ip1.split(".");
+ var ip2Arr = ip2.split(".");
+ for(var i = 0; i < iplArr.length;i++){
+ result[i] = (iplArr[i] & ip2Arr[i]);
+ }
+ return result.join(".");
+}
+ // gateway_check校验规则
+
+jQuery.validator.addMethod("gateway_check", function (value, element, param) {
+ var result = validateGateway($('#txtIpAddress').val(), $('#txtSubnetMask').val(), $("#txtDefaultGateway").val());
+ return this.optional(element) || result;
+});
+
+ return {
+ init: initialize
+ };
+});
+//联网设置模块
+define("network_dial_set","underscore jquery knockout set service".split(" "),
+function(_, $, ko, config, service) {
+
+ //联网设置view model
+ function DialVM() {
+ var dialMode = service.getConnectionMode();
+ var target = this;
+
+ target.selectMode = ko.observable(dialMode.connectionMode);
+ target.enableFlag = ko.observable(true);
+ target.isAllowedRoaming = ko.observable(dialMode.isAllowedRoaming);
+ var originalRoaming = dialMode.isAllowedRoaming;
+
+ target.setAllowedRoaming = setAllowedRoamingFunc;
+
+ var checkboxFlag = $(".checkboxToggle");
+ target.checkEnable = checkEnableFunc;
+
+ //修改联网模式
+ target.save = saveFunc;
+
+ function saveFunc() {
+ showLoading();
+ var connMode = target.selectMode();
+ //当选择自动时,下发原先的勾选状态
+ if (connMode == 'auto_dial') {
+ originalRoaming = target.isAllowedRoaming();
+ } else {
+ target.isAllowedRoaming(originalRoaming);
+ }
+ service.setConnectionMode({
+ connectionMode: connMode,
+ isAllowedRoaming: target.isAllowedRoaming()
+ }, function (result) {
+ if (result.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+
+ function setAllowedRoamingFunc() {
+ if(!$("#roamBtn").hasClass("disable")){
+ var checkbox = $("#isAllowedRoaming:checked");
+ if(checkbox && checkbox.length == 0 ){
+ target.isAllowedRoaming("on");
+ }else{
+ target.isAllowedRoaming("off");
+ }
+ }
+ }
+
+ function checkEnableFunc() {
+ var status = service.getStatusInfo();
+
+ if (status.connectStatus == "ppp_connected" || status.connectStatus == "ppp_connecting") {
+ target.enableFlag(false);
+ disableCheckbox(checkboxFlag);
+ }
+ else {
+ target.enableFlag(true);
+ enableCheckbox(checkboxFlag);
+ }
+ }
+
+ }
+
+ //联网设置初始化.
+ function initialize() {
+ var vm = new DialVM();
+ bindContainer(vm);
+
+ vm.checkEnable();
+ addInterval( vm.checkEnable, 1000);
+ }
+
+ function bindContainer(vm){
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+
+ }
+
+ return {
+ init: initialize
+ };
+});
+// APN Setting 模块
+define("network_apn_set","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ //获取鉴权方式
+
+ function getAuthModes() {
+ return _.map(config.APN_AUTH_MODES, function (item) {
+ return new Option(item.name, item.value);
+ });
+ }
+
+ function getApnPdpTypes() {
+ var pdpTypesArray = [new Option('IPv4', 'IP')];
+ if (config.IPV6_SUPPORT) {
+ pdpTypesArray.push(new Option('IPv6', 'IPv6'));
+ if (config.IPV4V6_SUPPORT) {
+ pdpTypesArray.push(new Option('IPv4v6', 'IPv4v6'));
+ }
+ if (config.IPV4_AND_V6_SUPPORT) {
+ pdpTypesArray.push(new Option('IPv4 & IPv6', 'IPv4v6'));
+ }
+ }
+ return pdpTypesArray;
+ }
+
+ //获取apn相关信息
+
+ function getApnSet() {
+ var apnInfo = service.getApnSettings();
+ apnInfo.ipv6ApnConfigs = getApnConfigs(apnInfo.ipv6APNs, true);
+ apnInfo.apnConfigs = getApnConfigs(apnInfo.APNs, false);
+ apnInfo.autoApnConfigs = getAutoApnsConfig(apnInfo.autoApns, apnInfo.autoApnsV6);
+ return apnInfo;
+ }
+ var apnConfigs = {};
+ var ipv6ApnConfigs = {};
+ var autoApnConfigs = {};
+
+ //解析自动apn信息
+
+ function getAutoApnsConfig(autoApnV4, autoApnV6) {
+ var autoApnsV4 = [];
+ var autoApnsV6 = [];
+
+ if (autoApnV4 && autoApnV4.length > 5) {
+ var apnArr = autoApnV4.split("||");
+ for (var ki = 0; ki < apnArr.length; ki++) {
+ if (apnArr[ki] != "") {
+ var apnItem = parseApnItem(apnArr[ki], false);
+ autoApnsV4.push(apnItem);
+ }
+ }
+ }
+ if (autoApnV6 && autoApnV6.length > 5) {
+ var apnArr = autoApnV6.split("||");
+ for (var ki = 0; ki < apnArr.length; ki++) {
+ if (apnArr[ki] != "") {
+ var apnItem = parseApnItem(apnArr[ki], false);
+ autoApnsV6.push(apnItem);
+ }
+ }
+ }
+ return dealAutoApnsV4V6(autoApnsV4, autoApnsV6);
+ }
+ //解析apn信息
+
+ function getApnConfigs(apnsStr, isIpv6) {
+ var apnCfgs = [];
+ var theApnConfigs = {};
+ if (apnsStr && apnsStr.length > 10) {
+ var apnArr = apnsStr.split("||");
+ for (var ki = 0; ki < apnArr.length; ki++) {
+ if (apnArr[ki] != "") {
+ var apnItem = parseApnItem(apnArr[ki], isIpv6);
+ apnCfgs.push(apnItem);
+ theApnConfigs[apnItem.profileName] = apnItem;
+ }
+ }
+ }
+ if (isIpv6 == false) {
+ apnConfigs = theApnConfigs;
+ } else {
+ ipv6ApnConfigs = theApnConfigs;
+ }
+ return apnCfgs;
+ }
+
+ //解析单条apn信息
+
+ function parseApnItem(apnStr, isIpv6) {
+ var apnItem = {};
+ var items = apnStr.split("($)");
+ for (var ki = 0; ki < items.length; ki++) {
+ apnItem.profileName = items[0];
+ apnItem.pdpType = items[7];
+ if (isIpv6 == false) {
+ apnItem.dnsMode = items[10];
+ apnItem.dns1 = items[11];
+ apnItem.dns2 = items[12];
+ apnItem.wanApn = items[1];
+ apnItem.authMode = items[4].toLowerCase();
+ apnItem.username = items[5];
+ apnItem.password = items[6];
+ } else {
+ apnItem.dnsModeV6 = items[10];
+ apnItem.dns1V6 = items[11];
+ apnItem.dns2V6 = items[12];
+ apnItem.wanApnV6 = items[1];
+ apnItem.authModeV6 = items[4].toLowerCase();
+ apnItem.usernameV6 = items[5];
+ apnItem.passwordV6 = items[6];
+ }
+ }
+ return apnItem;
+ }
+ //合并V4\V6自动apn信息
+
+ function dealAutoApnsV4V6(v4, v6) {
+ autoApnConfigs = {};
+ var autoApns = [];
+ for (var ki = 0; ki < v4.length; ki++) {
+ var apnElem = v4[ki];
+ var itemsV6 = v6[ki];
+ if (itemsV6 && (itemsV6.pdpType == 'IPv6' || itemsV6.pdpType == 'IPv4v6')) {
+ apnElem.usernameV6 = itemsV6.username;
+ apnElem.passwordV6 = itemsV6.password;
+ apnElem.dns1V6 = itemsV6.dns1;
+ apnElem.dns2V6 = itemsV6.dns2;
+ apnElem.wanApnV6 = itemsV6.wanApn;
+ apnElem.authModeV6 = itemsV6.authMode;
+ apnElem.dnsModeV6 = itemsV6.dnsMode;
+ }
+ autoApns.push(apnElem);
+ autoApnConfigs[apnElem.profileName] = apnElem;
+ }
+ return autoApns;
+ }
+
+ function getProfileOptions(apns) {
+ return _.map(apns, function (item) {
+ return new Option(item.profileName, item.profileName);
+ });
+ }
+
+ //APNViewModel
+
+ function APNViewModel() {
+ var target = this;
+ var apnSettings = getApnSet();
+ if (apnSettings.apnNumPreset) {
+ config.maxApnNumber = apnSettings.apnNumPreset;
+ }
+
+ target.defApn = ko.observable(apnSettings.profileName); //当前默认APN
+ target.apnMode = ko.observable(apnSettings.apnMode);
+ target.autoProfiles = ko.observableArray(getProfileOptions(apnSettings.autoApnConfigs));
+ target.profiles = ko.observableArray(getProfileOptions(apnSettings.apnConfigs));
+ target.wanDial = ko.observable(apnSettings.wanDial);
+
+ target.showApnDns = ko.observable(config.SHOW_APN_DNS);
+ target.index = ko.observable(apnSettings.currIndex);
+ target.supportIPv6 = ko.observable(config.IPV6_SUPPORT);
+ target.supportIpv4AndIpv6 = ko.observable(config.IPV4_AND_V6_SUPPORT);
+
+ target.apn = ko.observable(apnSettings.wanApn);
+ target.dnsMode = ko.observable(apnSettings.dnsMode == 'manual' ? 'manual' : 'auto');
+ target.dns1 = ko.observable(apnSettings.dns1);
+ target.dns2 = ko.observable(apnSettings.dns2);
+ target.authModes = ko.observableArray(getAuthModes());
+ target.username = ko.observable(apnSettings.username);
+ target.password = ko.observable(apnSettings.password);
+
+ target.pdpTypes = ko.observableArray(getApnPdpTypes());
+ target.selectedPdpType = ko.observable(apnSettings.pdpType);
+ target.selectedPdpTypeTmp = ko.observable(apnSettings.pdpType); //the PdpType select's value before chang
+ target.profileName = ko.observable(apnSettings.profileName); //当前编辑框中的
+ target.selectedProfile = ko.observable(apnSettings.profileName); //当前下拉框选择的APN
+
+ target.showPassword = ko.observable(false);
+
+ target.apnV6 = ko.observable(apnSettings.wanApnV6);
+ target.dnsModeV6 = ko.observable(apnSettings.dnsModeV6 == 'manual' ? 'manual' : 'auto');
+ target.dns1V6 = ko.observable(apnSettings.dns1V6);
+ target.dns2V6 = ko.observable(apnSettings.dns2V6);
+ target.authModesV6 = ko.observableArray(getAuthModes());
+ target.usernameV6 = ko.observable(apnSettings.usernameV6);
+ target.passwordV6 = ko.observable(apnSettings.passwordV6);
+ target.pdpTypeNote = ko.observable(true);
+ if (apnSettings.autoApnConfigs && apnSettings.autoApnConfigs.length > 0) {
+ target.selectedAutoProfile = ko.observable(apnSettings.autoApnConfigs[0].profileName);
+ } else {
+ target.selectedAutoProfile = ko.observable();
+ }
+
+ if (config.EMPTY_APN_SUPPORT == false) {
+ $("#apn_ipv4_apn").addClass("required");
+ $("#apn_ipv6_apn").addClass("required");
+ } else {
+ $("#apn_ipv4_apn").removeClass("required");
+ $("#apn_ipv6_apn").removeClass("required");
+ }
+
+ target.disableProfile = ko.observable(false); //表示处于新增页面
+ target.addApnHide = ko.observable(true);
+ target.defaultCfg = ko.observable(true); //当前选中的是默认APN
+ target.predeterminedCfg = ko.observable(true); //当前选中的是预置的APN
+
+ target.selectedAuthentication = ko.observable(apnSettings.authMode);
+ target.selectedAuthenticationV6 = ko.observable(apnSettings.authModeV6);
+
+
+ target.transApnV6 = ko.observable('apn');
+ target.transDnsModeV6 = ko.observable('apn_dns_mode');
+ target.transDns1V6 = ko.observable('apn_dns1');
+ target.transDns2V6 = ko.observable('apn_dns2');
+ target.transAuthV6 = ko.observable('apn_authentication');
+ target.transUserNameV6 = ko.observable('apn_user_name');
+ target.transPasswordV6 = ko.observable('apn_password');
+
+ target.transApn = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_ipv4_apn' : 'apn');
+ target.transDnsMode = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_dns_mode_ipv4' : 'apn_dns_mode');
+ target.transDns1 = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_dns1_ipv4' : 'apn_dns1');
+ target.transDns2 = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_dns2_ipv4' : 'apn_dns2');
+ target.transAuth = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_authentication_ipv4' : 'apn_authentication');
+ target.transUserName = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_user_name_ipv4' : 'apn_user_name');
+ target.transPassword = ko.observable(config.IPV4_AND_V6_SUPPORT ? 'apn_password_ipv4' : 'apn_password');
+
+ target.setDefaultVisible = ko.observable(!isConnectedNetWork());
+
+ target.tmp1 = ko.computed(function () {
+ if (target.selectedPdpType() == "IPv6") {
+ target.transApnV6('apn');
+ target.transDnsModeV6('apn_dns_mode');
+ target.transDns1V6('apn_dns1');
+ target.transDns2V6('apn_dns2');
+ target.transAuthV6('apn_authentication');
+ target.transUserNameV6('apn_user_name');
+ target.transPasswordV6('apn_password');
+ } else if (config.IPV4_AND_V6_SUPPORT && target.selectedPdpType() == 'IPv4v6') {
+ target.transApn('apn_ipv4_apn');
+ target.transDnsMode('apn_dns_mode_ipv4');
+ target.transDns1('apn_dns1_ipv4');
+ target.transDns2('apn_dns2_ipv4');
+ target.transAuth('apn_authentication_ipv4');
+ target.transUserName('apn_user_name_ipv4');
+ target.transPassword('apn_password_ipv4');
+
+ target.transApnV6('apn_ipv6_apn');
+ target.transDnsModeV6('apn_dns_mode_ipv6');
+ target.transDns1V6('apn_dns1_ipv6');
+ target.transDns2V6('apn_dns2_ipv6');
+ target.transAuthV6('apn_authentication_ipv6');
+ target.transUserNameV6('apn_user_name_ipv6');
+ target.transPasswordV6('apn_password_ipv6');
+ } else if (target.selectedPdpType() == "IP" || target.selectedPdpType() == "IPv4") {
+ target.transApn('apn');
+ target.transDnsMode('apn_dns_mode');
+ target.transDns1('apn_dns1');
+ target.transDns2('apn_dns2');
+ target.transAuth('apn_authentication');
+ target.transUserName('apn_user_name');
+ target.transPassword('apn_password');
+ } else { //config.IPV4V6_SUPPORT && target.selectedPdpType() == 'IPv4v6'
+ target.transApn('apn');
+ target.transDnsMode('apn_dns_mode');
+ target.transDns1('apn_dns1');
+ target.transDns2('apn_dns2');
+ target.transAuth('apn_authentication');
+ target.transUserName('apn_user_name');
+ target.transPassword('apn_password');
+ }
+ $("#apn_setting_form").translate();
+ });
+
+ target.autoApnChecked = ko.computed(function () {
+ return target.apnMode() == "auto";
+ });
+
+ target.hasCapacity = ko.computed(function () {
+ if (target.profiles().length < config.maxApnNumber) {
+ return true;
+ } else {
+ return false;
+ }
+ });
+
+ target.showDnsV6 = ko.computed(function () {
+ return target.dnsModeV6() == "manual";
+ });
+
+ target.showDns = ko.computed(function () {
+ return target.dnsMode() == "manual";
+ });
+
+
+ checkDefaultProfileStatus();
+ target.checkInputDisable = ko.computed(function () {
+ if (target.apnMode() != "auto" && (target.predeterminedCfg() == false && target.defaultCfg() == true) && !isConnectedNetWork()) {
+ return false;
+ }
+ if (((target.apnMode() != "auto" && (target.predeterminedCfg() || target.defaultCfg()) && !target.disableProfile())) || target.apnMode() == "auto") {
+ return true;
+ }
+ if ((!target.disableProfile() || !(target.predeterminedCfg() || target.defaultCfg())) && target.apnMode() != "auto") {
+ return false;
+ }
+ return false;
+ });
+
+ var data = service.getDeviceInfo();
+ target.pdpTypeChangeAlert = pdpTypeChangeAlertFunc;
+
+
+ target.showAutoApnDetail = ko.computed(function () {
+ if (target.apnMode() != "auto") {
+ return true;
+ } else {
+ return target.autoProfiles().length > 0;
+ }
+ });
+ //密码显示事件
+ target.showPasswordHandler = function () {
+ var checkbox = $("#showPassword:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showPassword(true);
+ } else {
+ target.showPassword(false);
+ }
+ };
+ //auto apn profile change 事件处理
+
+ target.autoProfileChangeHandler = autoProfileChangeHandlerFunc;
+
+
+ //profile change 事件处理
+
+ target.profileChangeHandler = profileChangeHandlerFunc;
+
+
+ //切换profile时重置下面的显示项
+ target.setUIData = setUIDataFunc;
+
+
+ //设置默认apn状态
+
+ function checkDefaultProfileStatus() {
+ var index = getApnIndex();
+ //默认apn不允许编辑
+ if (target.apnMode() != "auto") { //当前选中与实际不一致的话
+ if (target.selectedProfile() != target.defApn()) {
+ target.defaultCfg(false);
+ } else {
+ target.defaultCfg(true); //默认APN
+ }
+ } else {
+ if (target.selectedAutoProfile() != target.defApn()) {
+ target.defaultCfg(false);
+ } else {
+ target.defaultCfg(true); //默认APN
+ }
+ }
+
+ if (index >= config.defaultApnSize) {
+ target.predeterminedCfg(false);
+ } else {
+ target.predeterminedCfg(true); //预置APN
+ }
+ }
+
+
+ //设置为默认apn
+
+ target.setDefaultAct = setDefaultActFunc;
+
+
+
+ //APN mode change 事件处理
+
+ target.apnModeChangeHandler = apnModeChangeHandlerFunc;
+
+
+ function doSetDefaultAct() {
+ var index = 0;
+ if (target.apnMode() != 'auto') {
+ index = getApnIndex();
+ target.selectedProfile($("#profile").val());
+ } else {
+ index = getAutoApnIndex();
+ target.selectedAutoProfile($("#autoProfile").val());
+ }
+ var selectedProfileDetail = target.getSelectedManualProfile();
+ service.setDefaultApn({
+ index: index,
+ apnMode: target.apnMode(),
+ pdpType: selectedProfileDetail.pdpType,
+
+ profileName: selectedProfileDetail.profileName,
+ wanApn: selectedProfileDetail.wanApn,
+ authMode: selectedProfileDetail.authMode,
+ username: selectedProfileDetail.username,
+ password: selectedProfileDetail.password,
+ dnsMode: config.SHOW_APN_DNS ? selectedProfileDetail.dnsMode : 'auto',
+ dns1: config.SHOW_APN_DNS ? selectedProfileDetail.dns1 : '',
+ dns2: config.SHOW_APN_DNS ? selectedProfileDetail.dns2 : ''
+ }, function (data) {
+ if (data.result) {
+ //showLoading("apn_alert_restart");
+ //restartDevice(service);
+ addTimeout(function () {
+ initialize(true);
+ target.apnModeChangeHandler();
+ successOverlay();
+ }, 500);
+ } else {
+ errorOverlay();
+ }
+ }, function (data) {
+ errorOverlay();
+ });
+ }
+
+ target.getSelectedManualProfile = getSelectedManualProfileFunc;
+
+
+ //获取自动apn索引
+
+ function getAutoApnIndex() {
+ var configs = $("#autoProfile option");
+ for (var ki = 0; ki < configs.length; ki++) {
+ if (configs[ki].value == target.selectedAutoProfile()) {
+ return ki;
+ }
+ }
+ return configs.length - 1;
+ }
+
+ //获取apn索引
+
+ function getApnIndex() {
+ var configs = $("#profile option");
+ if (configs.length == 0) {
+ configs = target.profiles();
+ }
+ var ki = 0;
+ for (; ki < configs.length; ki++) {
+ if (configs[ki].value == target.selectedProfile()) {
+ break;
+ }
+ }
+ return ki;
+ }
+
+ //保存APN设置信息
+
+ target.saveAct = saveActFunc;
+
+ //编辑APN信息
+
+ function editApnSetting(preAct) { //默认设置按钮触发为TRUE
+ showLoading();
+ var apnIndex = getApnIndex();
+ var sameInfo = false;
+ if (config.IPV4V6_SUPPORT && target.selectedPdpType() == 'IPv4v6') {
+ sameInfo = true;
+ }
+ var needDoDefault = false;
+ if (preAct || (target.predeterminedCfg() || target.defaultCfg())) {
+ needDoDefault = true;
+ }
+ service.addOrEditApn({
+ profileName: target.profileName(),
+ pdpType: target.selectedPdpType(),
+ index: apnIndex,
+
+ wanApn: target.apn(),
+ authMode: target.selectedAuthentication(),
+ username: target.username(),
+ password: target.password(),
+ dnsMode: config.SHOW_APN_DNS ? target.dnsMode() : 'auto',
+ dns1: config.SHOW_APN_DNS ? target.dns1() : '',
+ dns2: config.SHOW_APN_DNS ? target.dns2() : '',
+
+ wanApnV6: sameInfo ? target.apn() : target.apnV6(),
+ authModeV6: sameInfo ? target.selectedAuthentication() : target.selectedAuthenticationV6(),
+ usernameV6: sameInfo ? target.username() : target.usernameV6(),
+ passwordV6: sameInfo ? target.password() : target.passwordV6(),
+ dnsModeV6: config.SHOW_APN_DNS ? (sameInfo ? target.dnsMode() : target.dnsModeV6()) : 'auto',
+ dns1V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns1() : target.dns1V6()) : '',
+ dns2V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns2() : target.dns2V6()) : ''
+ }, function (data) {
+ if (data.result) {
+ apnSettings = getApnSet();
+ if (target.profileName() != target.selectedProfile()) {
+ var newProfileName = target.profileName();
+ target.profiles(getProfileOptions(apnSettings.apnConfigs));
+ $('#profile').val(newProfileName).trigger('change');
+ }
+ if (needDoDefault == false) {
+ successOverlay();
+ } else {
+ doSetDefaultAct();
+ }
+ } else {
+ errorOverlay();
+ }
+ }, function (data) {
+ errorOverlay();
+ });
+ }
+
+ //新增APN信息
+
+ function addNewApnSetting() {
+ showLoading("waiting");
+ var optionLen = $("option", "#profile").length;
+ if (optionLen < config.defaultApnSize) {
+ errorOverlay();
+ return;
+ }
+ // 支持IPv4v6,并且选择IPv4v6时,IPv4 与 IPv6下发相同的信息
+ // 支持IPv4 & v6,并且选择IPv4v6时,IPv4 与 IPv6下发各自的信息
+ var sameInfo = false;
+ if (config.IPV4V6_SUPPORT && target.selectedPdpType() == 'IPv4v6') {
+ sameInfo = true;
+ }
+
+ service.addOrEditApn({
+ profileName: target.profileName(),
+ pdpType: target.selectedPdpType(),
+ index: optionLen,
+
+ wanApn: target.apn(),
+ authMode: target.selectedAuthentication(),
+ username: target.username(),
+ password: target.password(),
+ dnsMode: config.SHOW_APN_DNS ? target.dnsMode() : 'auto',
+ dns1: config.SHOW_APN_DNS ? target.dns1() : '',
+ dns2: config.SHOW_APN_DNS ? target.dns2() : '',
+
+ wanApnV6: sameInfo ? target.apn() : target.apnV6(),
+ authModeV6: sameInfo ? target.selectedAuthentication() : target.selectedAuthenticationV6(),
+ usernameV6: sameInfo ? target.username() : target.usernameV6(),
+ passwordV6: sameInfo ? target.password() : target.passwordV6(),
+ dnsModeV6: config.SHOW_APN_DNS ? (sameInfo ? target.dnsMode() : target.dnsModeV6()) : 'auto',
+ dns1V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns1() : target.dns1V6()) : '',
+ dns2V6: config.SHOW_APN_DNS ? (sameInfo ? target.dns2() : target.dns2V6()) : ''
+ }, function (data) {
+ if (data.result) {
+ apnSettings = getApnSet();
+ if (target.profileName() != target.selectedProfile()) {
+ var newProfileName = target.profileName();
+ target.profiles(getProfileOptions(apnSettings.apnConfigs));
+ $('#profile').val(newProfileName).trigger('change');
+ }
+ doSetDefaultAct();
+ } else {
+ errorOverlay();
+ }
+ }, function (data) {
+ errorOverlay();
+ });
+ }
+
+
+
+ var tempApn = {};
+ //删除APN
+
+ target.deleteAct = deleteActFunc;
+
+ //取消新增APN
+
+ target.cancelAddAct = cancelAddActFunc;
+
+ //进入新增APN页面
+
+ target.addAct = addActFunc;
+ //进入新增APN页面
+ function addActFunc() {
+ clearValidateMsg('#apn_setting_form');
+ target.pdpTypeNote(true);
+ target.disableProfile(true);
+ target.addApnHide(true);
+ tempApn = {
+ profileName: target.profileName(),
+ selectedPdpType: target.selectedPdpType(),
+
+ wanApnV6: target.apnV6(),
+ dnsModeV6: config.SHOW_APN_DNS ? target.dnsModeV6() : 'auto',
+ dns1V6: config.SHOW_APN_DNS ? target.dns1V6() : '',
+ dns2V6: config.SHOW_APN_DNS ? target.dns2V6() : '',
+ authModeV6: target.selectedAuthenticationV6(),
+ usernameV6: target.usernameV6(),
+ passwordV6: target.passwordV6(),
+
+ wanApn: target.apn(),
+ dnsMode: config.SHOW_APN_DNS ? target.dnsMode() : 'auto',
+ dns1: config.SHOW_APN_DNS ? target.dns1() : '',
+ dns2: config.SHOW_APN_DNS ? target.dns2() : '',
+ authMode: target.selectedAuthentication(),
+ username: target.username(),
+ password: target.password(),
+
+ };
+ target.profileName("");
+ target.selectedPdpType("IP");
+ target.selectedPdpTypeTmp("IP");
+
+ target.apnV6("");
+ target.dnsModeV6("auto");
+ target.dns1V6("");
+ target.dns2V6("");
+ target.selectedAuthenticationV6("none");
+ target.usernameV6("");
+ target.passwordV6("");
+
+ target.apn("");
+ target.dnsMode("auto");
+ target.dns1("");
+ target.dns2("");
+ target.selectedAuthentication("none");
+ target.username("");
+ target.password("");
+
+ }
+
+ //取消新增APN
+ function cancelAddActFunc() {
+ clearValidateMsg('#apn_setting_form');
+ target.pdpTypeNote(false);
+ target.disableProfile(false);
+ target.addApnHide(false);
+ target.profileName(tempApn.profileName);
+ target.selectedPdpType(tempApn.selectedPdpType);
+ target.selectedPdpTypeTmp(tempApn.selectedPdpType);
+
+ target.apnV6(tempApn.wanApnV6);
+ target.dnsModeV6(tempApn.dnsModeV6);
+ target.dns1V6(tempApn.dns1V6);
+ target.dns2V6(tempApn.dns2V6);
+ target.selectedAuthenticationV6(tempApn.authModeV6);
+ target.usernameV6(tempApn.usernameV6);
+ target.passwordV6(tempApn.passwordV6);
+
+ target.apn(tempApn.wanApn);
+ target.dnsMode(tempApn.dnsMode);
+ target.dns1(tempApn.dns1);
+ target.dns2(tempApn.dns2);
+ target.selectedAuthentication(tempApn.authMode);
+ target.username(tempApn.username);
+ target.password(tempApn.password);
+
+ }
+
+ //删除APN
+ function deleteActFunc() {
+ if (!target.selectedProfile()) {
+ showAlert("apn_no_select_alert");
+ return false;
+ }
+ if (target.predeterminedCfg()) { //预置的apn不允许删除
+ errorOverlay("apn_delete_cant_delete_default");
+ return false;
+ }
+ if (getApnSet().profileName == target.profileName()) {
+ errorOverlay("apn_cant_delete_current");
+ return false;
+ }
+
+ showConfirm("apn_delete_confirm", function () {
+ showLoading('deleting');
+ service.deleteApn({
+ index: getApnIndex()
+ }, function (data) {
+ if (data.result) {
+ target.profiles(getProfileOptions(getApnSet().apnConfigs));
+ target.selectedProfile(target.defApn());
+ target.profileChangeHandler();
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }, function (data) {
+ errorOverlay();
+ });
+ });
+ }
+
+ //保存APN设置信息
+ function saveActFunc() {
+ if (!$('#apn_setting_form').valid()) {
+ return false;
+ }
+ if (!target.selectedProfile() && !target.disableProfile()) { //不是增加时的设置需要判断是否选择了Profile
+ showAlert("apn_no_select_alert");
+ return false;
+ }
+ var exist = false;
+ $.each(target.profiles(), function (i, e) {
+ if (e.value == target.profileName()) {
+ exist = true;
+ }
+ });
+
+ if (target.disableProfile() == false) {
+ if (exist && target.selectedProfile() != target.profileName()) {
+ showInfo("apn_save_profile_exist");
+ return false;
+ }
+ if (target.predeterminedCfg()) { //预置的APN不可以修改
+ errorOverlay();
+ return false;
+ }
+ if (target.predeterminedCfg() || target.defaultCfg()) {
+ //showConfirm("apn_alert", function () {
+ editApnSetting(false);
+ //});
+ } else {
+ editApnSetting(false);
+ }
+ } else {
+
+ if ($("#profile option").length >= config.maxApnNumber) {
+ showInfo({
+ msg: "apn_profile_full",
+ params: [config.maxApnNumber]
+ });
+ return false;
+ }
+ if (exist) {
+ showInfo("apn_save_profile_exist");
+ return false;
+ }
+ var info = service.getStatusInfo();
+ if (info.connectStatus != "ppp_connected") {
+ //showConfirm("apn_alert", function () {
+ addNewApnSetting();
+ //});
+
+ } else {
+ showConfirm("apn_diconneted_network_confirm", function () {
+ showLoading('disconnecting');
+ service.disconnect({}, function (data) {
+ if (data.result) {
+ config.connect_flag = true;
+ addNewApnSetting();
+ } else {
+ errorOverlay();
+ }
+ });
+ });
+ }
+ }
+ }
+
+ function getSelectedManualProfileFunc() {
+ var cfg = {};
+ var profileVal = $("#profile").val();
+ if (typeof target.selectedProfile() == 'undefined') {
+ target.selectedProfile(profileVal);
+ }
+ var cfgV4 = apnConfigs[profileVal];
+ var cfgV6 = ipv6ApnConfigs[profileVal];
+ if (cfgV4 && !cfgV6) {
+ $.extend(cfg, cfgV4);
+ } else if (cfgV4 && cfgV6) {
+ if (!!cfgV4.pdpType) {
+ $.extend(cfg, cfgV6);
+ $.extend(cfg, cfgV4);
+ } else {
+ $.extend(cfg, cfgV4);
+ $.extend(cfg, cfgV6);
+ }
+ }
+ return cfg;
+ }
+
+ //APN mode change 事件处理
+ function apnModeChangeHandlerFunc(data, event) {
+ if (target.apnMode() != 'auto') {
+ target.profileChangeHandler();
+ } else {
+ if (target.showAutoApnDetail()) {
+ target.autoProfileChangeHandler();
+ }
+ }
+ return true;
+ }
+
+ //设置为默认apn
+ function setDefaultActFunc() {
+ if (!target.selectedProfile()) {
+ showAlert("apn_no_select_alert");
+ return false;
+ }
+ var connectStatus = service.getConnectionInfo().connectStatus;
+ if (connectStatus == "ppp_connecting") {
+ showAlert({
+ msg: "apn_cant_modify_status",
+ params: [$.i18n.prop("connecting").toLowerCase()]
+ });
+ return false;
+ } else if (connectStatus == "ppp_disconnecting") {
+ showAlert({
+ msg: "apn_cant_modify_status",
+ params: [$.i18n.prop("disconnecting").toLowerCase()]
+ });
+ return false;
+ } else if (connectStatus == "ppp_connected") {
+ showAlert({
+ msg: "apn_cant_modify_status",
+ params: [$.i18n.prop("connected").toLowerCase()]
+ });
+ return false;
+ }
+ if (target.apnMode() == 'auto' || target.predeterminedCfg()) {
+ //showConfirm("apn_alert", function () {
+ showLoading("waiting");
+ doSetDefaultAct();
+ //});
+ } else {
+ if ($('#apn_setting_form').valid() == false) {
+ $(".error:first", "#apn_setting_form").focus();
+ } else {
+ var exist = false;
+ $.each(target.profiles(), function (i, e) {
+ if (e.value == target.profileName()) {
+ exist = true;
+ }
+ });
+ if (exist && target.selectedProfile() != target.profileName()) {
+ showInfo("apn_save_profile_exist");
+ return false;
+ }
+ //showLoading("waiting");
+ //showConfirm("apn_alert", function () {
+ editApnSetting(true);
+ //});
+ }
+ }
+ }
+
+ //切换profile时重置下面的显示项
+ function setUIDataFunc(data) {
+ clearValidateMsg('#apn_setting_form');
+ if (!data) {
+ return;
+ }
+ target.selectedPdpType(data.pdpType || 'IP');
+ target.selectedPdpTypeTmp(data.pdpType || 'IP');
+ target.profileName(data.profileName);
+
+ target.apn(data.wanApn);
+ target.dnsMode(data.dnsMode != 'manual' ? 'auto' : 'manual');
+ target.dns1(data.dns1);
+ target.dns2(data.dns2);
+ target.username(data.username);
+ target.password(data.password);
+ target.selectedAuthentication(data.authMode || 'none');
+
+ target.apnV6(data.wanApnV6);
+ target.dnsModeV6(data.dnsModeV6 != 'manual' ? 'auto' : 'manual');
+ target.dns1V6(data.dns1V6);
+ target.dns2V6(data.dns2V6);
+ target.usernameV6(data.usernameV6);
+ target.passwordV6(data.passwordV6);
+ target.selectedAuthenticationV6(data.authModeV6 || 'none');
+ }
+
+ //profile change 事件处理
+ function profileChangeHandlerFunc(data, event) {
+ target.pdpTypeNote(true);
+ if (target.apnMode() != 'manual') {
+ return true;
+ }
+ var cfg = target.getSelectedManualProfile();
+ target.setUIData(cfg);
+ checkDefaultProfileStatus();
+ return true;
+ }
+
+ //auto apn profile change 事件处理
+ function autoProfileChangeHandlerFunc(data, event) {
+ if (target.apnMode() != 'auto') {
+ return true;
+ }
+ var cfg = autoApnConfigs[target.selectedAutoProfile()];
+ target.setUIData(cfg);
+ checkDefaultProfileStatus();
+ return true;
+ }
+
+ function pdpTypeChangeAlertFunc() {
+ if (target.pdpTypeNote()) {
+ showAlert({
+ msg: "apn_pdptype_change_note",
+ params: [data.lanDomain, data.ipAddress]
+ });
+ }
+ if (target.apnMode() != "auto" && !target.disableProfile()) { //如果是手动非ADD状态,切换PDP类型时,不改变界面显示的各项值
+ if ((config.IPV4_AND_V6_SUPPORT && target.selectedPdpTypeTmp() != 'IPv4v6' && target.selectedPdpType() != 'IPv4v6') || !config.IPV4_AND_V6_SUPPORT) { //
+ if (target.selectedPdpTypeTmp() == 'IPv6') { //V6 -> V4 / V4V6
+ target.apn(target.apnV6());
+ target.dnsMode(target.dnsModeV6());
+ target.dns1(target.dns1V6());
+ target.dns2(target.dns2V6());
+ target.username(target.usernameV6());
+ target.password(target.passwordV6());
+ target.selectedAuthentication(target.selectedAuthenticationV6());
+ } else if (target.selectedPdpType() == 'IPv6') { //V4 / V4V6 -> V6
+ target.apnV6(target.apn());
+ target.dnsModeV6(target.dnsMode());
+ target.dns1V6(target.dns1());
+ target.dns2V6(target.dns2());
+ target.usernameV6(target.username());
+ target.passwordV6(target.password());
+ target.selectedAuthenticationV6(target.selectedAuthentication());
+ }
+ }
+ }
+ target.selectedPdpTypeTmp(target.selectedPdpType());
+ }
+
+
+ }
+
+ //是否已联网
+
+ function isConnectedNetWork() {
+ var info = service.getConnectionInfo();
+ return info.connectStatus == "ppp_connected";
+ }
+
+ function initVar() {
+ apnConfigs = {};
+ ipv6ApnConfigs = {};
+ autoApnConfigs = {};
+ }
+ function bindContainer(vm){
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(vm, container[0]);
+ }
+ //初始化ViewModel
+
+ function initialize(formInit) {
+ initVar();
+
+ var vm = new APNViewModel();
+ bindContainer(vm);
+
+ if (!formInit) {
+ addInterval(function () {
+ vm.setDefaultVisible(!isConnectedNetWork());
+ }, 1000);
+ }
+ $('#apn_setting_form').validate({
+ submitHandler: function () {
+ vm.saveAct();
+ },
+ rules: {
+ profile_name: 'apn_profile_name_check',
+ apn_ipv4_apn: 'apn_check',
+ apn_dns1_ipv4: "ipv4",
+ apn_dns2_ipv4: "ipv4",
+ apn_ipv6_apn: 'apn_check',
+ apn_dns1_ipv6: "ipv6",
+ apn_dns2_ipv6: "ipv6",
+ apn_user_name_ipv4: 'ppp_username_check',
+ apn_secretcode_ipv4: 'ppp_secretcode_check',
+ apn_user_name_ipv6: 'ppp_username_check',
+ apn_secretcode_ipv6: 'ppp_secretcode_check'
+ }
+ });
+ }
+
+ return {
+ init: initialize
+ };
+});
\ No newline at end of file
diff --git a/lynq/R305/ap/app/zte_webui/js/set.js b/lynq/R305/ap/app/zte_webui/js/set.js
new file mode 100755
index 0000000..f2dc0cc
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/js/set.js
@@ -0,0 +1,959 @@
+define(function () {
+ var config = {
+ WEBUI_TITLE: '4G Hostless Modem', //title配置, 具体参考各设备下的配置
+ ALREADY_NOTICE: false, //是否已经提醒,有在线升级信息
+ ALREADY_OTA_NOTICE: false, //是否OTA升级提醒过
+ dbMsgs: [], //数据库中全部的短消息
+ listMsgs: [], //经解析关联后的所有短消息
+ currentChatObject: null, //当前聊天对象的手机号
+ smsMaxId: 0, //短消息最大编号
+ phonebook: [], //电话本记录
+ smsIsReady: false, //缓存短信初始化状态
+ portForwardMax: 10, //端口转发最大规则数
+ urlFilterMax: 10, //URL filter最大规则数
+ defaultApnSize: 1, //出厂设置默认APN的个数
+ maxApnNumber: 10, //最大APN个数
+ RJ45_SUPPORT: false, //是否支持rj45
+ TSW_SUPPORT: false, // 是否支持定时休眠唤醒
+ WIFI_SLEEP_SUPPORT: true, // 是否支持wifi休眠
+ HAS_BATTERY: true, //是否有电池
+ FAST_BOOT_SUPPORT: true, //是否支持快速开机
+ TURN_OFF_SUPPORT: true, //是否支持关机
+ PRODUCT_TYPE: 'UFI', // 产品类型UFI、CPE
+ IS_TEST: false, //配置是否是模拟数据
+ NATIVE_UPDATE_FILE_SIZE: 64, //支持的本地升级文件大小上限,单位为M
+ DDNS_SUPPORT: false, //DDNS
+ MAX_LOGIN_COUNT: 5, //最大登录次数,密码输入错误次数到了以后会账户冻结一定时间
+ LOGIN_SECURITY_SUPPORT: true, //是否支持登录安全
+ LOGIN_THEN_CHECK_PIN: true, //是否先登录后验证PIN,PUK
+ GUEST_HASH: ['#httpshare_guest'],
+ DEVICE: 'ext', //各个型号机配置文件路径
+ connect_flag: false,
+ defaultRoute: '#entry',
+ IPV4_AND_V6_SUPPORT: false, //是否支持IPv4 & v6。 双PDP双栈
+ IPV4V6_SUPPORT: true, //是否支持ipv4v6。 IPV4V6_SUPPORT和IPV4_AND_V6_SUPPORT不可同时为true.单PDP双栈
+ IPV6_SUPPORT: true, //是否支持ipv6
+ EMPTY_APN_SUPPORT: false, //是否支持空apn
+ SHOW_APN_DNS: false, //APN设置页面是否显示DNS,不显示则dnsMode默认设置为auto
+ TRAFFIC_SUPPORT: true, //是否支持流量功能
+ CLEAR_DATA_SUPPORT: false, //是否支持流量和时间清空功能
+ NETWORK_UNLOCK_SUPPORT: false, //是否支持解锁
+ SHOW_MAC_ADDRESS: false, //是否显示mac地址
+ PASSWORD_ENCODE: true, //登录密码和WIFI密码是否加密
+ AP_STATION_SUPPORT: false, //是否支持AP Station功能
+ AP_STATION_LIST_LENGTH: 10,
+ WIFI_WEP_SUPPORT: false, //是否支持wifi WEP加密
+ WIFI_WAP3_SUPPORT: true, //是否支持wifi WAP3加密
+ WIFI_WPA2_WAP3_SUPPORT: true, //是否支持wifi WPA2/WAP3兼容模式
+ WIFI_HAS_5G: false,
+ WIFI_BAND_SUPPORT: false, //是否支持wifi频段设置
+ WIFI_BANDWIDTH_SUPPORT: false, //是否支持频带宽度
+ WIFI_BANDWIDTH_SUPPORT_40MHZ: false, //频带宽度是否支持40MHZ,reltek芯片支持
+ WIFI_SUPPORT_QR_CODE: true, //是否支持wifi二维码显示
+ WIFI_SUPPORT_QR_SWITCH: false, //是否支持wifi二维码显示控制
+ WIFI_SWITCH_SUPPORT: true, //是否支持wifi开关
+ MAX_STATION_NUMBER: 32, //CPE WIFI最大连接数为32
+ SHOW_WIFI_AP_ISOLATED: false, // 是否显示AP隔离
+ STATION_BLOCK_SUPPORT: false, // 已连接设备是否支持Block功能
+ UPGRADE_TYPE: "FOTA", //取值有"NONE","OTA","FOTA","TWO_PORTION"
+ SMS_UNREAD_NUM_INCLUDE_SIM: false, //未读短息数量是否包含SIM侧
+ SMS_DATABASE_SORT_SUPPORT: true, //短信是否支持DB排序
+ SMS_MATCH_LENGTH: 11, //短信联系人号码匹配位数,11国内项目,8国际项目
+ SHOW_UN_COMPLETE_CONCAT_SMS: true, //级联短信未接收完是否显示相关级联短信
+ SMS_SET_READ_WHEN_COMPLETE: false, //聊天过程中,级联短信只有接受完成后才能自动设置为已读
+ SD_CARD_SUPPORT: false, //是否支持SD卡
+ SD_BASE_PATH: '/mmc2', //SD 卡根目录
+ //modem_main_state的临时状态,一般需要界面轮询等待
+ TEMPORARY_MODEM_MAIN_STATE: ["modem_undetected", "modem_detected", "modem_sim_state", "modem_handover", "modem_imsi_lock", "modem_online", "modem_offline"],
+ ISNOW_NOTICE: false, //FOTA是否正在提示有新版本
+ INCLUDE_MOBILE: true,
+ HAS_USSD: false, // 是否支持USSD功能,
+ HAS_URL: false, // 是否支持URL过滤,
+ HAS_CASCADE_SMS: true, //是否支持级联短信
+ HAS_FOTA: true, //是否支持FOTA
+ HAS_UPDATE_CHECK: true, //是否支持升级检测设置
+ HAS_PHONEBOOK: true, //是否有电话本功能
+ HAS_SMS: true, //是否有短信功能
+ HAS_PARENTAL_CONTROL: false, // 是否支持家长控制功能
+ HAS_MULTI_SSID: false, //多ssid功能
+ HAS_WIFI: true, //是否包含wifi功能
+ HAS_QUICK_SETTING: true, //是否支持快速设置
+ HAS_SNTP: true, //是否支持时间管理
+ HAS_BLACK_AND_WHITE_FILTER: false, //是否支持黑白名单
+ HAS_LOGIN: true, //是否有登录页面
+ HAS_UPNP: true, //是否支持UPNP
+ BAUD_RATES: [{
+ name: '9600',
+ value: '9600'
+ }, {
+ name: '19200',
+ value: '19200'
+ }, {
+ name: '38400',
+ value: '38400'
+ }, {
+ name: '57600',
+ value: '57600'
+ }, {
+ name: '115200',
+ value: '115200'
+ }, {
+ name: '230400',
+ value: '230400'
+ }, {
+ name: '460800',
+ value: '460800'
+ }, {
+ name: '921600',
+ value: '921600'
+ }
+ ],
+ FORWARDING_MODES: [{
+ name: 'Unconditional forwarding',
+ value: '1'
+ }, {
+ name: 'When busy',
+ value: '2'
+ }, {
+ name: 'When no answer',
+ value: '3'
+ }, {
+ name: 'Cancel all forwarding',
+ value: '0'
+ }
+ ],
+ wdsModes: [{
+ name: "Disable",
+ value: "0"
+ }, {
+ name: "RootAP Mode",
+ value: "1"
+ }, {
+ name: "Bridge Mode",
+ value: "2"
+ }, {
+ name: "Repeater Mode",
+ value: "3"
+ }
+ ],
+ daylightSave: [{
+ name: "Disable",
+ value: "0"
+ }, {
+ name: "Enable",
+ value: "1"
+ }
+ ],
+ sntpTimeSetMode: [{
+ name: 'manual',
+ value: 'manual'
+ }, {
+ name: 'auto',
+ value: 'auto'
+ }
+ ],
+ //时区
+ timeZone: [{
+ name: "(GMT-12:00) Dateline West",
+ value: "<-12>12_0"
+ }, {
+ name: "(GMT-11:00) Midway Islands, Samoa",
+ value: "SST11_0"
+ }, {
+ name: "(GMT-10:00) Hawaii",
+ value: "<-10>10_0"
+ }, {
+ name: "(GMT-09:00) Alaska",
+ value: "<-09>9_0"
+ }, {
+ name: "(GMT-08:00) Pacific time (USA and Canada), Tijuana",
+ value: "PST8PDT,M3.2.0,M11.1.0_0"
+ }, {
+ name: "(GMT-07:00) Mountain time (USA and Canada)",
+ value: "<-07>7_0"
+ }, {
+ name: "(GMT-07:00) Arizona",
+ value: "<-07>7_1"
+ }, {
+ name: "(GMT-07:00) Chihuahua, La Paz, Mazza Tran",
+ value: "MST7MDT,M4.1.0,M10.5.0_2"
+ }, {
+ name: "(GMT-06:00) Saskatchewan",
+ value: "<-06>6_0"
+ }, {
+ name: "(GMT-06:00) Central time (USA and Canada)",
+ value: "<-06>6_1"
+ }, {
+ name: "(GMT-06:00) Central America",
+ value: "<-06>6_2"
+ }, {
+ name: "(GMT-06:00) Guadalajara City, Mexico City, Monterey",
+ value: "<-06>6_3"
+ }, {
+ name: "(GMT-05:00) Bogota, Lima, Quito",
+ value: "<-05>5_0"
+ }, {
+ name: "(GMT-05:00) Eastern time (USA and Canada)",
+ value: "<-05>5_1"
+ }, {
+ name: "(GMT-05:00) Indiana (East)",
+ value: "EST5EDT,M3.2.0,M11.1.0_2"
+ }, {
+ name: "(GMT-04:00) Atlantic time (Canada)",
+ value: "AST4ADT,M3.2.0,M11.1.0_0"
+ }, {
+ name: "(GMT-04:00) Caracas, La Paz",
+ value: "<-04>4_1"
+ }, {
+ name: "(GMT-04:00) Santiago",
+ value: "<-04>4<-03>,M8.2.6/24,M5.2.6/24_2"
+ }, {
+ name: "(GMT-03:30) Newfoundland",
+ value: "NST3:30NDT,M3.2.0,M11.1.0_0"
+ }, {
+ name: "(GMT-03:00) Brasilia",
+ value: "<-03>3_0"
+ }, {
+ name: "(GMT-03:00) Buenos Aires, Georgetown",
+ value: "<-03>3_1"
+ }, {
+ name: "(GMT-03:00) Greenland",
+ value: "<-03>3_2"
+ }, {
+ name: "(GMT-02:00) Mid-Atlantic",
+ value: "<-02>2_0"
+ }, {
+ name: "(GMT-01:00) Cape Verde Islands",
+ value: "<-01>1_0"
+ }, {
+ name: "(GMT-01:00) Azores",
+ value: "<-01>1<+00>,M3.5.0/0,M10.5.0/1_1"
+ }, {
+ name: "(GMT) GMT: Dublin, Edinburgh, London, Lisbon",
+ value: "GMT0IST,M3.5.0/1,M10.5.0_0"
+ }, {
+ name: "(GMT) Casablanca, Monrovia",
+ value: "WET0WEST,M3.5.0,M10.5.0/3_1"
+ }, {
+ name: "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
+ value: "CET-1CEST,M3.5.0,M10.5.0/3_0"
+ }, {
+ name: "(GMT+01:00) Belgrad, Bratislava, Budapest, Ljubljana, Prague",
+ value: "CET-1CEST,M3.5.0,M10.5.0/3_1"
+ }, {
+ name: "(GMT+01:00) Brussels, Copenhagen, Madrid, Paris",
+ value: "CET-1CEST,M3.5.0,M10.5.0/3_2"
+ }, {
+ name: "(GMT+01:00) Sarajevo, Skopje,Warsaw, Zagreb",
+ value: "CET-1CEST,M3.5.0,M10.5.0/3_3"
+ }, {
+ name: "(GMT+01:00) Western Central African",
+ value: "<+01>-1_4"
+ }, {
+ name: "(GMT+02:00) Bucharest",
+ value: "EET-2EEST,M3.5.0/3,M10.5.0/4_0"
+ }, {
+ name: "(GMT+02:00) Pretoria, Harare",
+ value: "CAT-2_1"
+ }, {
+ name: "(GMT+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius",
+ value: "EET-2EEST,M3.5.0/3,M10.5.0/4_2"
+ }, {
+ name: "(GMT+02:00) Cairo",
+ value: "EET-2_3"
+ }, {
+ name: "(GMT+02:00) Athens, Beirut, Istanbul, Minsk",
+ value: "EET-2EEST,M3.5.0/3,M10.5.0/4_4"
+ }, {
+ name: "(GMT+02:00) Jerusalem",
+ value: "IST-2IDT,M3.4.5/02:00:00,M10.5.0/02:00:00_5"
+ }, {
+ name: "(GMT+03:00) Baghdad",
+ value: "<+03>-3_0"
+ }, {
+ name: "(GMT+03:00) Riyadh, Kuwait",
+ value: "<+03>-3_1"
+ }, {
+ name: "(GMT+03:00) Moscow, St Petersburg, Volgograd",
+ value: "<+03>-3_2"
+ }, {
+ name: "(GMT+03:00) Nairobi",
+ value: "EAT-3_3"
+ }, {
+ name: "(GMT+03:30) Teheran",
+ value: "<+0330>-3:30<+0430>,J80/0,J264/0_0"
+ }, {
+ name: "(GMT+04:00) Abu Zabi, Muscat",
+ value: "<+04>-4_0"
+ }, {
+ name: "(GMT+04:00) Baku, Tbilisi, Yerevan",
+ value: "<+04>-4_1"
+ }, {
+ name: "(GMT+04:30) Kabul",
+ value: "<+0430>-4:30_0"
+ }, {
+ name: "(GMT+05:00) Yekaterinburg",
+ value: "<+05>-5_0"
+ }, {
+ name: "(GMT+05:00) Islamabad, Karachi, Tashkent",
+ value: "PKT-5_1"
+ }, {
+ name: "(GMT+05:30) Madras, Calcutta, Mumbai, New Delhi",
+ value: "<+0530>-5:30_0"
+ }, {
+ name: "(GMT+05:45) Kathmandu",
+ value: "<+0545>-5:45_0"
+ }, {
+ name: "(GMT+06:00) Ala Mutu, Novosibirsk",
+ value: "<+06>-6_0"
+ }, {
+ name: "(GMT+06:00) Dhaka, Astana",
+ value: "<+06>-6_1"
+ }, {
+ name: "(GMT+06:00) Sri Haya Ed Denny Pla",
+ value: "<+06>-6_2"
+ }, {
+ name: "(GMT+06:30) Yangon",
+ value: "<+0630>-6:30_0"
+ }, {
+ name: "(GMT+07:00) Krasnoyarsk",
+ value: "<+07>-7_0"
+ }, {
+ name: "(GMT+07:00) Bangkok, Hanoi, Jakarta",
+ value: "<+07>-7_1"
+ }, {
+ name: "(GMT+08:00) Beijing, Chongqing, Hongkong Special Administrative Region, Urumqi",
+ value: "CST-8_0"
+ }, {
+ name: "(GMT+08:00) Kuala Lumpur, Singapore",
+ value: "<+08>-8_1"
+ }, {
+ name: "(GMT+08:00) Perth",
+ value: "AWST-8_2"
+ }, {
+ name: "(GMT+08:00) Taipei",
+ value: "CST-8_3"
+ }, {
+ name: "(GMT+08:00) Irkutsk, Ulam Batu",
+ value: "<+08>-8_4"
+ }, {
+ name: "(GMT+09:00) Osaka, Sapporo, Tokyo",
+ value: "JST-9_0"
+ }, {
+ name: "(GMT+09:00) Seoul",
+ value: "KST-9_1"
+ }, {
+ name: "(GMT+09:00) Yakutsk",
+ value: "<+09>-9_2"
+ }, {
+ name: "(GMT+09:30) Adelaide",
+ value: "ACST-9:30ACDT,M10.1.0,M4.1.0/3_0"
+ }, {
+ name: "(GMT+09:30) Darwin",
+ value: "ACST-9:30_1"
+ }, {
+ name: "(GMT+10:00) Brisbane",
+ value: "AEST-10_0"
+ }, {
+ name: "(GMT+10:00) Vladivostok",
+ value: "<+10>-10_1"
+ }, {
+ name: "(GMT+10:00) Guam, Port Moresby",
+ value: "<+10>-10_2"
+ }, {
+ name: "(GMT+10:00) Hobart",
+ value: "AEST-10AEDT,M10.1.0,M4.1.0/3_3"
+ }, {
+ name: "(GMT+10:00) Canberra, Melbourne, Sydney",
+ value: "AEST-10AEDT,M10.1.0,M4.1.0/3_4"
+ }, {
+ name: "(GMT+11:00) Magadan, Solomon islands, New Caledonia",
+ value: "<+11>-11_0"
+ }, {
+ name: "(GMT+12:00) Wellington, Oakland",
+ value: "<+12>-12_0"
+ }, {
+ name: "(GMT+12:00) Fiji, Kamchatka, Marshall Islands",
+ value: "<+12>-12_1"
+ }, {
+ name: "(GMT+13:00) Nukualofa",
+ value: "<+13>-13_0"
+ }
+ ],
+
+ //短信保存时间
+ SMS_VALIDITY: [{
+ name: '12 hours',
+ value: 'twelve_hours'
+ }, {
+ name: 'A day',
+ value: 'one_day'
+ }, {
+ name: 'A week',
+ value: 'one_week'
+ }, {
+ name: 'The longest period',
+ value: 'largest'
+ }
+ ],
+ MAP_PROTOCOL_MODES: [{
+ name: "TCP+UDP",
+ value: "TCP&UDP"
+ }, {
+ name: "TCP",
+ value: "TCP"
+ }, {
+ name: "UDP",
+ value: "UDP"
+ }
+ ],
+ //端口转发协议
+ FORWARD_PROTOCOL_MODES: [{
+ name: "TCP+UDP",
+ value: "TCP&UDP"
+ }, {
+ name: "TCP",
+ value: "TCP"
+ }, {
+ name: "UDP",
+ value: "UDP"
+ }
+ ],
+ FILTER_PROTOCOL_MODES: [{
+ name: "NONE",
+ value: "None"
+ }, {
+ name: "TCP",
+ value: "TCP"
+ }, {
+ name: "UDP",
+ value: "UDP"
+ }, {
+ name: "ICMP",
+ value: "ICMP"
+ }
+ ],
+
+ //HTTPSHARE模式
+ SD_SHARE_ENABLE: [{
+ name: "Enable",
+ value: "1"
+ }, {
+ name: "Disable",
+ value: "0"
+ }
+ ],
+
+ SD_ACCESS_TYPE: [{
+ name: "entire_sd_card",
+ value: "1"
+ }, {
+ name: "custom_setting",
+ value: "0"
+ }
+ ],
+
+ SD_FILE_TO_SHARE: [{
+ name: "entire_sd_card",
+ value: "1"
+ }, {
+ name: "custom_setting",
+ value: "0"
+ }
+ ],
+
+ //国家码所述类型
+ countryCodeType: {
+ world: 3,
+ mkkc: 3,
+ apld: 7,
+ etsic: 3,
+ fcca: 1
+ },
+
+ countries_5g: {
+ NONE: "NONE",
+ AR: "ARGENTIA",
+ AM: "ՀԱՅԱՍՏԱՆ",
+ AU: "AUSTRILIA",
+ AT: "ÖSTERREICH",
+ AZ: "AZƏRBAYCAN",
+ BH: "البحرين",
+ BY: "БЕЛАРУСЬ",
+ BE: "BELGIË",
+ BA: "БОСНА И ХЕРЦЕГОВИНА",
+ BR: "BRASIL",
+ BN: "BRUNEI DARUSSALAM",
+ BG: "БЪЛГАРИЯ",
+ CL: "CHILE",
+ CN: "中国",
+ CR: "COSTA RICA",
+ HR: "HRVATSKA",
+ CY: "ΚΎΠΡΟΣ",
+ CZ: "ČESKÁ REPUBLIKA",
+ DK: "DANMARK",
+ EC: "ECUADOR",
+ EG: "مصر",
+ SV: "EL SALVADOR",
+ EE: "EESTI",
+ FI: "SUOMI",
+ FR: "FRANCE",
+ GE: "საქართველო",
+ DE: "DEUTSCHLAND",
+ GR: "ΕΛΛΆΔΑ",
+ HK: "香港",
+ HU: "MAGYARORSZÁG",
+ IS: "ÍSLAND",
+ IN: "INDIA",
+ ID: "INDONESIA",
+ IR: "ایران",
+ IE: "ÉIRE",
+ IL: "إسرائيل",
+ IT: "ITALIA",
+ JM: "JAMAICA",
+ JO: "الأردن",
+ KP: "조선민주주의인민공화국",
+ KR: "한국 ROK",
+ LV: "LATVIJA",
+ LI: "LIECHTENSTEIN",
+ LT: "LIETUVA",
+ LU: "LUXEMBOURG",
+ MO: "澳門",
+ MY: "MALAYSIA",
+ MT: "MALTA",
+ MC: "MONACO",
+ NL: "NEDERLAND",
+ AN: "Netherlands Antilles",
+ NO: "NORGE",
+ OM: "سلطنة عمان",
+ PE: "PERÚ",
+ PH: "PHILIPPINES",
+ PL: "POLSKA",
+ PT: "PORTUGAL",
+ SA: "السعودية",
+ SG: "SINGAPORE",
+ SK: "SLOVENSKÁ REPUBLIKA",
+ SI: "SLOVENIJA",
+ ZA: "SOUTH AFRICA",
+ ES: "ESPAÑA",
+ LK: "SRILANKA",
+ SE: "SVERIGE",
+ CH: "SCHWEIZ",
+ TT: "TRINIDAD AND TOBAGO",
+ TN: "تونس",
+ TR: "TÜRKİYE",
+ GB: "UNITED KINGDOM",
+ UY: "URUGUAY",
+ JP: "日本",
+ BZ: "BELIZE",
+ BO: "BOLIVIA",
+ NZ: "NEW ZEALAND",
+ VE: "VENEZUELA",
+ CA: "CANADA",
+ CO: "COLOMBIA",
+ DO: "REPÚBLICA DOMINICANA",
+ GT: "GUATEMALA",
+ MX: "MEXICO",
+ PA: "PANAMÁ",
+ PR: "PUERTO RICO",
+ TW: "台灣",
+ US: "UNITED STATES",
+ UZ: "O’zbekiston"
+ },
+
+ //国家码与语言匹配表
+ countries: {
+ NONE: "NONE",
+ AL: "SHQIPERI",
+ DZ: "الجزائر",
+ AR: "ARGENTIA",
+ AM: "ՀԱՅԱՍՏԱՆ",
+ AU: "AUSTRALIA",
+ AT: "ÖSTERREICH",
+ AZ: "AZƏRBAYCAN",
+ BD: "বাংলাদেশ",
+ BH: "البحرين",
+ BY: "БЕЛАРУСЬ",
+ BE: "BELGIË",
+ BA: "БОСНА И ХЕРЦЕГОВИНА",
+ BR: "BRASIL",
+ BN: "BRUNEI DARUSSALAM",
+ BG: "БЪЛГАРИЯ",
+ CL: "CHILE",
+ CN: "中国",
+ CR: "COSTA RICA",
+ HR: "HRVATSKA",
+ CY: "ΚΎΠΡΟΣ",
+ CZ: "ČESKÁ REPUBLIKA",
+ DK: "DANMARK",
+ EC: "ECUADOR",
+ EG: "مصر",
+ SV: "EL SALVADOR",
+ EE: "EESTI",
+ FI: "SUOMI",
+ FR: "FRANCE",
+ GE: "საქართველო",
+ DE: "DEUTSCHLAND",
+ GR: "ΕΛΛΆΔΑ",
+ HN: "HONDURAS",
+ HK: "香港",
+ HU: "MAGYARORSZÁG",
+ IS: "ÍSLAND",
+ IN: "INDIA",
+ ID: "INDONESIA",
+ IR: "ایران، جمهوری اسلامی",
+ IE: "ÉIRE",
+ IL: "إسرائيل",
+ IT: "ITALIA",
+ JM: "JAMAICA",
+ JO: "الأردن",
+ KZ: "КАЗАХСТАН",
+ KE: "KENYA",
+ KP: "조선민주주의인민공화국",
+ KR: "한국 ROK",
+ KW: "الكويت",
+ LV: "LATVIJA",
+ LB: "لبنان",
+ LI: "LIECHTENSTEIN",
+ LT: "LIETUVA",
+ LU: "LUXEMBOURG",
+ MO: "澳門",
+ MK: "МАКЕДОНИЈА",
+ MY: "MALAYSIA",
+ MT: "MALTA",
+ MC: "MONACO",
+ MA: "المغرب",
+ NL: "NEDERLAND",
+ AN: "NETHERLANDS ANTILLES",
+ NO: "NORGE",
+ OM: "سلطنة عمان",
+ PK: "PAKISTAN",
+ PE: "PERÚ",
+ PH: "PHILIPPINES",
+ PL: "POLSKA",
+ PT: "PORTUGAL",
+ QA: "قطر",
+ RO: "ROMÂNIA",
+ RU: "Российская Федерация",
+ SA: "السعودية",
+ SG: "SINGAPORE",
+ SK: "SLOVENSKÁ REPUBLIKA",
+ SI: "SLOVENIJA",
+ ZA: "SOUTH AFRICA",
+ ES: "ESPAÑA",
+ LK: "SRILANKA",
+ SE: "SVERIGE",
+ CH: "SCHWEIZ",
+ SY: "الجمهورية العربية السورية",
+ TH: "ประเทศไทย",
+ TT: "TRINIDAD AND TOBAGO",
+ TN: "تونس",
+ TR: "TÜRKİYE",
+ UA: "Україна",
+ AE: "الإمارات العربية المتحدة",
+ GB: "UNITED KINGDOM",
+ UY: "URUGUAY",
+ VN: "VIỆT NAM",
+ YE: "اليمن",
+ ZW: "ZIMBABWE",
+ JP: "日本",
+ BZ: "BELIZE",
+ BO: "BOLIVIA",
+ NZ: "NEW ZEALAND",
+ VE: "REPÚBLICA BOLIVARIANA DE VENEZUELA",
+ CA: "CANADA",
+ CO: "COLOMBIA",
+ DO: "REPÚBLICA DOMINICANA",
+ GT: "GUATEMALA",
+ MX: "MEXICO",
+ PA: "PANAMÁ",
+ PR: "PUERTO RICO",
+ TW: "台灣",
+ US: "UNITED STATES",
+ UZ: "O’zbekiston"
+ },
+ //国家码与类型匹配表
+ countryCode_5g: {
+ //88 countries of world【36 40 44 48】
+ one: {
+ codes: ["AL", "AI", "AW", "AT", "BY", "BM", "BA", "BW", "IO", "BG",
+ "CV", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "GF", "PF",
+ "TF", "GI", "DE", "GR", "GP", "GG", "HU", "IS", "IE", "IT",
+ "KE", "LA", "LV", "LS", "LI", "LT", "LU", "MK", "MT", "IM",
+ "MQ", "MR", "MU", "YT", "MC", "MS", "NL", "AN", "NO",
+ "OM", "PL", "PT", "RE", "RO", "SM", "SN", "RS", "SK", "SI",
+ "ZA", "ES", "SE", "CH", "TC", "UG", "GB", "VG", "WF", "ZM",
+ "AF", "JO", "MA", "EH", "EU", "DZ", "IL", "MX", "PM", "TN",
+ "TR", "JP"],
+ channels: [36, 40, 44, 48]
+ },
+ //60 countrys of world【36 40 44 48 149 153 157 161 165】
+ two: {
+ codes: ["AS", "AG", "AZ", "BR", "KH", "KY", "CO", "CR", "DM", "DO",
+ "EC", "GH", "GD", "HK", "KZ", "KI", "FM", "MZ", "NA", "NZ",
+ "NI", "NE", "PW", "PE", "PH", "PR", "VC", "TH", "TT", "UY",
+ "ZW", "AU", "BH", "BB", "CA", "CL", "CX", "EG", "SV", "GT",
+ "HT", "IN", "MY", "NF", "PA", "PG", "SG", "US", "VN"],
+ channels: [36, 40, 44, 48, 149, 153, 157, 161, 165]
+ },
+ //9 countrys of world【149 153 157 161】
+ three: {
+ codes: ["CU", "IR", "KR", "SY", "LB", "MW", "MO", "QA"],
+ channels: [149, 153, 157, 161]
+ },
+ //12 countrys of world【149 153 157 161 165】
+ four: {
+ codes: ["BD", "BF", "CN", "HN", "JM", "PK", "PY", "KN", "AR", "TW", "NG"],
+ channels: [149, 153, 157, 161, 165]
+ },
+ //1 country of world【36 40 44 48 149 153 157 161】
+ five: {
+ codes: ["SA"],
+ channels: [36, 40, 44, 48, 149, 153, 157, 161]
+ }
+ },
+ countryCode: {
+ world: ["AL", "DZ", "AR", "AM", "AU", "AT", "AZ", "BH", "BY",
+ "BE", "BA", "BR", "BN", "BG", "CL", "CN", "CR", "HR", "CY",
+ "CZ", "DK", "EC", "EG", "SV", "EE", "FI", "FR", "GE",
+ "DE", "GR", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IE",
+ "IL", "IT", "JM", "JO", "KZ", "KE", "KP", "KR", "KW", "LV",
+ "LB", "LI", "LT", "LU", "MO", "MK", "MY", "MT", "MC", "MA",
+ "NL", "AN", "NO", "OM", "PK", "PE", "PH", "PL", "PT", "QA",
+ "RO", "RU", "SA", "SG", "SK", "SI", "ZA", "ES", "LK",
+ "SE", "CH", "SY", "TH", "TT", "TN", "TR", "UA", "AE", "GB",
+ "UY", "VN", "YE", "ZW", "BD"],
+ mkkc: ["JP"],
+ apld: [],
+ etsic: ["BZ", "BO", "NZ", "VE"],
+ fcca: ["CA", "CO", "DO", "GT", "MX", "PA", "PR", "TW", "US", "UZ"]
+ },
+ //休眠时间
+ SLEEP_MODES: [{
+ name: "Always on",
+ value: "-1"
+ }, {
+ name: "5 minutes",
+ value: "5"
+ }, {
+ name: "10 minutes",
+ value: "10"
+ }, {
+ name: "20 minutes",
+ value: "20"
+ }, {
+ name: "30 minutes",
+ value: "30"
+ }, {
+ name: "1 hour",
+ value: "60"
+ }, {
+ name: "2 hours",
+ value: "120"
+ }
+ ],
+ DDNSSetMode: [{
+ name: 'Enable',
+ value: '1'
+ }, {
+ name: 'Disable',
+ value: '0'
+ }
+ ],
+ ddns_Modeselect: [{
+ name: 'manual',
+ value: 'manual'
+ }, {
+ name: 'auto',
+ value: 'auto'
+ }
+ ],
+ DDNSDDP: [{
+ name: 'dyndns.org',
+ value: 'dyndns.org'
+ }, {
+ name: 'freedns.afraid.org',
+ value: 'freedns.afraid.org'
+ }, {
+ name: 'zoneedit.com',
+ value: 'zoneedit.com'
+ }, {
+ name: 'no-ip.com',
+ value: 'no-ip.com'
+ }, {
+ name: 'None',
+ value: 'none'
+ }
+ ],
+ //RJ45连接模式
+ pppoeModes: [{
+ name: "PPPoE",
+ value: "PPPOE"
+ }, {
+ name: "Static",
+ value: "STATIC"
+ }, {
+ name: "DHCP",
+ value: "DHCP"
+ }, {
+ name: "AUTO",
+ value: "AUTO"
+ }
+ ],
+ //联网模式
+ AUTO_MODES: [{
+ name: 'Automatic',
+ value: 'NETWORK_auto'
+ }, {
+ name: '4G Only',
+ value: 'Only_LTE'
+ }, {
+ name: '3G Only',
+ value: 'Only_WCDMA'
+ }, {
+ name: '2G Only',
+ value: 'Only_GSM'
+ }
+ ],
+ //APN鉴权模式
+ APN_AUTH_MODES: [{
+ name: "NONE",
+ value: "none"
+ }, {
+ name: "CHAP",
+ value: "chap"
+ }, {
+ name: "PAP",
+ value: "pap"
+ }
+ ],
+ //语言
+ LANGUAGES: [{
+ name: 'English',
+ value: 'en'
+ }, {
+ name: '中文',
+ value: 'zh-cn'
+ }
+ ],
+ //wifi加密模式
+ AUTH_MODES: [{
+ name: 'NO ENCRYPTION',
+ value: 'OPEN'
+ }, {
+ name: 'WPA2(AES)-PSK',
+ value: 'WPA2PSK'
+ }, {
+ name: 'WPA-PSK/WPA2-PSK',
+ value: 'WPAPSKWPA2PSK'
+ }, {
+ name: 'WPA3-Personal',
+ value: 'WPA3Personal'
+ }, {
+ name: 'WPA2(AES)/WPA3-Personal',
+ value: 'WPA2WPA3'
+ }
+ ],
+ AUTH_MODES_WEP: [{
+ name: 'NO ENCRYPTION',
+ value: 'OPEN'
+ }, {
+ name: 'SHARED',
+ value: 'SHARED'
+ }, {
+ name: 'WPA2(AES)-PSK',
+ value: 'WPA2PSK'
+ }, {
+ name: 'WPA-PSK/WPA2-PSK',
+ value: 'WPAPSKWPA2PSK'
+ }, {
+ name: 'WPA3-Personal',
+ value: 'WPA3Personal'
+ }, {
+ name: 'WPA2(AES)/WPA3-Personal',
+ value: 'WPA2WPA3'
+ }
+ ],
+ AUTH_MODES_ALL: [{
+ name: 'NO ENCRYPTION',
+ value: 'OPEN'
+ }, {
+ name: 'SHARED',
+ value: 'SHARED'
+ }, {
+ name: 'WPA-PSK',
+ value: 'WPAPSK'
+ }, {
+ name: 'WPA2-PSK',
+ value: 'WPA2PSK'
+ }, {
+ name: 'WPA-PSK/WPA2-PSK',
+ value: 'WPAPSKWPA2PSK'
+ }, /*{
+ name: 'WPA3-Personal',
+ value: 'WPA3Personal'
+ }, {
+ name: 'WPA2(AES)/WPA3-Personal',
+ value: 'WPA2WPA3'
+ }, */{
+ name: 'EAP-SIM/AKA',
+ value: 'EAP-SIM/AKA'
+ }
+ ],
+
+ NETWORK_MODES: [{
+ name: '802.11 b/g/n',
+ value: '4'
+ }, {
+ name: '802.11 n only',
+ value: '2'
+ }
+ ],
+ NETWORK_MODES_BAND: [{
+ name: '802.11 a only',
+ value: '5'
+ }, {
+ name: '802.11 n only',
+ value: '2'
+ }, {
+ name: '802.11 a/n',
+ value: '4'
+ }
+ ],
+ resetContentModifyValue: function () {
+ this.CONTENT_MODIFIED.checkChangMethod = function () {
+ return false;
+ };
+ this.CONTENT_MODIFIED.modified = false;
+ this.CONTENT_MODIFIED.message = 'leave_page_info';
+ this.CONTENT_MODIFIED.callback = {
+ ok: $.noop,
+ no: function () {
+ return true;
+ }
+ }; //如果no返回true,页面则保持原状
+ this.CONTENT_MODIFIED.data = {};
+ },
+ CONTENT_MODIFIED: {
+ modified: false,
+ message: 'leave_page_info',
+ data: {},
+ checkChangMethod: function () {
+ return false;
+ },
+ callback: {
+ ok: $.noop,
+ no: function () {
+ return true;
+ }
+ } //如果no返回true,页面则保持原状
+ }, //当前页面内容是否已经修改
+
+ };
+
+ require([config.DEVICE + '/set'], function (otherConf) {
+ $.extend(config, otherConf);
+ });
+
+ return config;
+});
diff --git a/lynq/R305/ap/app/zte_webui/js/sim_device.js b/lynq/R305/ap/app/zte_webui/js/sim_device.js
new file mode 100755
index 0000000..97e3e9f
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/js/sim_device.js
@@ -0,0 +1,5009 @@
+define("sim_abnormal","jquery knockout service set main opmode".split(" "),
+ function ($, ko, service, config, home, opmode) {
+
+ function init() {
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ var vm = new simViewMode();
+ ko.applyBindings(vm, container);
+
+ $('#frmPUK').validate({
+ submitHandler: function () {
+ vm.enterPUK();
+ },
+ rules: {
+ txtNewPIN: "pin_check",
+ txtConfirmPIN: {
+ equalToPin: "#txtNewPIN"
+ },
+ txtPUK: "puk_check"
+ }
+ });
+
+ $('#frmPIN').validate({
+ submitHandler: function () {
+ vm.enterPIN();
+ },
+ rules: {
+ txtPIN: "pin_check"
+ }
+ });
+ }
+
+ function simViewMode() {
+ var target = this;
+ var staInfo = service.getStatusInfo();
+ var curCableMode = "PPPOE" == staInfo.blc_wan_mode || "AUTO_PPPOE" == staInfo.blc_wan_mode;
+ target.hasRj45 = config.RJ45_SUPPORT;
+ target.hasSms = config.HAS_SMS;
+ target.hasPhonebook = config.HAS_PHONEBOOK;
+ target.isSupportSD = config.SD_CARD_SUPPORT;
+ if (config.WIFI_SUPPORT_QR_SWITCH) {
+ var wifiInfo = service.getWifiBasic();
+ target.showQRCode = config.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
+ } else {
+ target.showQRCode = config.WIFI_SUPPORT_QR_CODE;
+ }
+ if(config.WIFI_SUPPORT_QR_CODE){
+ target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + $.now();
+ } else {
+ target.qrcodeSrc = './pic/res_blacktrans.png';
+ }
+ target.hasParentalControl = ko.observable(config.HAS_PARENTAL_CONTROL && curCableMode);
+ target.pageState = {
+ NO_SIM: 0,
+ WAIT_PIN: 1,
+ WAIT_PUK: 2,
+ PUK_LOCKED: 3,
+ LOADING: 4
+ };
+ target.isHomePage = ko.observable(false);
+ if (window.location.hash == "#main") {
+ target.isHomePage(true);
+ }
+
+ var info = service.getLoginData();
+ target.PIN = ko.observable();
+ target.newPIN = ko.observable();
+ target.confirmPIN = ko.observable();
+ target.PUK = ko.observable();
+ target.pinNumber = ko.observable(info.pinnumber);
+ target.pukNumber = ko.observable(info.puknumber);
+
+ var state = computePageState(info);
+ target.page = ko.observable(state);
+ if (state == target.pageState.LOADING) {
+ addTimeout(refreshPage, 500);
+ }
+ target.showOpModeWindow = function () {
+ showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
+ };
+ target.isLoggedIn = ko.observable(false);
+ target.enableFlag = ko.observable(false);
+ //更新当前工作模式状态信息
+ target.refreshOpmodeInfo = function () {
+ var staInfo = service.getStatusInfo();
+ target.isLoggedIn(staInfo.isLoggedIn);
+
+ if (!curCableMode && checkCableMode(staInfo.blc_wan_mode)) { //如果有线,则重新加载
+ if (target.page() == target.pageState.NO_SIM || target.page() == target.pageState.WAIT_PIN || target.page() == target.pageState.WAIT_PUK || target.page() == target.pageState.PUK_LOCKED) {
+ window.location.reload();
+ }
+ }
+
+ curCableMode = checkCableMode(staInfo.blc_wan_mode);
+ target.hasParentalControl(config.HAS_PARENTAL_CONTROL && curCableMode);
+ if (curCableMode && staInfo.ethWanMode.toUpperCase() == "DHCP") {
+ target.enableFlag(true);
+ } else if ((!curCableMode && staInfo.connectStatus != "ppp_disconnected") || (curCableMode && staInfo.rj45ConnectStatus != "idle" && staInfo.rj45ConnectStatus != "dead")) {
+ target.enableFlag(false);
+ } else {
+ target.enableFlag(true);
+ }
+ var mode = (staInfo.blc_wan_mode == "AUTO_PPP" || staInfo.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : staInfo.blc_wan_mode;
+ var currentOpMode = "";
+ switch (mode) {
+ case "PPP":
+ currentOpMode = "opmode_gateway";
+ break;
+ case "PPPOE":
+ currentOpMode = "opmode_cable";
+ break;
+ case "AUTO":
+ currentOpMode = "opmode_auto";
+ break;
+ default:
+ break;
+ }
+ $("#opmode").attr("data-trans", currentOpMode).text($.i18n.prop(currentOpMode));
+ }
+ //刷新页面状态
+ function refreshPage() {
+ var data = service.getLoginData();
+ var state = computePageState(data);
+ if (state == target.pageState.LOADING) {
+ addTimeout(refreshPage, 500);
+ } else {
+ target.page(state);
+ target.pinNumber(data.pinnumber);
+ target.pukNumber(data.puknumber);
+ }
+ }
+ //输入PUK设置新PIN事件处理
+ target.enterPUK = function () {
+ showLoading();
+ target.page(target.pageState.LOADING);
+ var newPIN = target.newPIN();
+ var confirmPIN = target.confirmPIN();
+ var params = {};
+ params.PinNumber = newPIN;
+ params.PUKNumber = target.PUK();
+ service.enterPUK(params, function (data) {
+ if (!data.result) {
+ hideLoading();
+ if (target.pukNumber() == 2) {
+ showAlert("last_enter_puk", function () {
+ refreshPage();
+ });
+ } else {
+ showAlert("puk_error", function () {
+ refreshPage();
+ if (target.page() == target.pageState.PUK_LOCKED) {
+ hideLoading();
+ }
+ });
+ }
+ target.PUK('');
+ target.newPIN('');
+ target.confirmPIN('');
+ } else {
+ refreshPage();
+ if (target.page() == target.pageState.PUK_LOCKED) {
+ hideLoading();
+ }
+ }
+ });
+ };
+ //验证输入PIN事件处理
+ target.enterPIN = function () {
+ showLoading();
+ target.page(target.pageState.LOADING);
+ var pin = target.PIN();
+ service.enterPIN({
+ PinNumber: pin
+ }, function (data) {
+ if (!data.result) {
+ hideLoading();
+ if (target.pinNumber() == 2) {
+ showAlert("last_enter_pin", function () {
+ refreshPage();
+ });
+ } else {
+ showAlert("pin_error", function () {
+ refreshPage();
+ });
+ }
+ target.PIN('');
+ }
+ refreshPage();
+ if (target.page() == target.pageState.WAIT_PUK) {
+ hideLoading();
+ }
+ });
+ };
+
+ if (target.hasRj45) {
+ target.refreshOpmodeInfo();
+ addInterval(function () {
+ target.refreshOpmodeInfo();
+ }, 1000);
+ }
+ //根据登录状态和SIM卡状态设置页面状态
+ function computePageState(data) {
+ var state = data.modem_main_state;
+ if (state == "modem_undetected" || state == "modem_sim_undetected" || state == "modem_sim_destroy") {
+ return target.pageState.NO_SIM;
+ } else if (state == "modem_waitpin") {
+ return target.pageState.WAIT_PIN;
+ } else if ((state == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {
+ return target.pageState.WAIT_PUK;
+ } else if ((data.puknumber == 0 || state == "modem_sim_destroy") && state != "modem_sim_undetected" && state != "modem_undetected") {
+ return target.pageState.PUK_LOCKED;
+ } else if ($.inArray(state, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
+ return target.pageState.LOADING;
+ } else {
+ location.reload();
+ }
+ }
+
+ }
+
+ return {
+ init: init
+ };
+});
+
+define("ota_update", "jquery jq_fileinput service knockout set statusBar".split(" "),
+
+ function ($, fileinput, service, ko, config, status) {
+
+ function FotaUpdateViewModel() {
+ var target = this;
+ var setting = service.getOTAUpdateSetting();
+
+ target.allowRoamingUpdate = ko.observable(setting.allowRoamingUpdate);
+ target.hasDdns = config.DDNS_SUPPORT;
+ target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
+ target.hasUssd = config.HAS_USSD;
+ target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';
+ target.lastCheckTime = ko.observable('');
+ target.updateIntervalDay = ko.observable(setting.updateIntervalDay);
+ target.updateMode = ko.observable(setting.updateMode);
+ target.updateType = ko.observable(service.getUpdateType().update_type);
+
+
+ // 自动检测设置按钮事件
+ target.apply = function () {
+ var updateSettingInfo = {
+ updateMode: target.updateMode(),
+ updateIntervalDay: target.updateIntervalDay(),
+ allowRoamingUpdate: target.allowRoamingUpdate()
+ };
+ showLoading();
+ service.setOTAUpdateSetting(updateSettingInfo, function (settingInfo) {
+ if (settingInfo && settingInfo.result == "success") {
+ setting.allowRoamingUpdate = target.allowRoamingUpdate();
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+
+ // 按钮【检测】点击事件处理接口
+ target.checkNewVersion = function () {
+ var newVersionState = service.getNewVersionState();
+ if(newVersionState.fota_package_already_download == "yes"){
+ showAlert("fota_package_already_download");
+ return;
+ }
+
+ if(config.UPGRADE_TYPE=="FOTA"){
+ var checkingState = ["checking"];
+ if ($.inArray(newVersionState.fota_current_upgrade_state, checkingState) != -1) {
+ showAlert("ota_update_running");
+ return;
+ }
+ }
+
+ // FOTA开始下载前,判断当前是否已经在下载过程中,防止错误清空fota_new_version_state状态
+ var statusInfo = service.getStatusInfo();
+ if (newVersionState.fota_current_upgrade_state == "prepare_install") {
+ showInfo('ota_download_success');
+ return;
+ }
+
+ var upgradingState = ["downloading", "confirm_dowmload"];
+ if ($.inArray(newVersionState.fota_current_upgrade_state, upgradingState) != -1) {
+ status.showOTAAlert();
+ return;
+ }
+
+ if (statusInfo.roamingStatus) {
+ showConfirm("ota_check_roaming_confirm", function () {
+ checkNewVersion();
+ });
+ } else {
+ checkNewVersion();
+ }
+ // 检测是否有新版本
+ function checkNewVersion() {
+ showLoading("ota_new_version_checking");
+ function checkNewVersionResult() {
+ var result = service.getNewVersionState();
+ if (result.hasNewVersion) {
+ if(result.fota_new_version_state == "already_has_pkg"&&result.fota_current_upgrade_state !="prepare_install"&&result.fota_current_upgrade_state !="low_battery")
+ {
+ addTimeout(checkNewVersionResult, 1000);
+ }
+ else
+ {
+ status.showOTAAlert();
+ }
+ } else if (result.fota_new_version_state == "no_new_version") {
+ showAlert("ota_no_new_version");
+ }else if (result.fota_new_version_state == "check_failed" ) {
+ errorOverlay("ota_check_fail");
+ } else if ( result.fota_new_version_state == "bad_network"){
+ errorOverlay("ota_connect_server_failed");
+ }else {
+ addTimeout(checkNewVersionResult, 1000);
+ }
+ }
+
+ service.setUpgradeSelectOp({selectOp: 'check'}, function (result) {
+ if (result.result == "success") {
+ checkNewVersionResult();
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+ };
+
+
+
+ // 确认按钮状态:可用/灰化
+ target.fixPageEnable = function () {
+ var connectStatusInfo = service.getStatusInfo();
+ var opModeData = service.getOpMode();
+ if (checkConnectedStatus(connectStatusInfo.connectStatus, opModeData.rj45_state, connectStatusInfo.connectWifiStatus)) {
+ enableBtn($("#btnCheckNewVersion"));
+ } else {
+ disableBtn($("#btnCheckNewVersion"));
+ }
+ };
+
+ target.clickAllowRoamingUpdate = function () {
+ var checkedbox = $("#chkUpdateRoamPermission:checked");
+ if (checkedbox && checkedbox.length == 0) {
+ target.allowRoamingUpdate("1");
+ } else {
+ target.allowRoamingUpdate("0");
+ }
+ };
+
+ service.getOTAlastCheckTime({}, function(info){
+ target.lastCheckTime(info.dm_last_check_time);
+ });
+
+ }
+ // 获取升级文件大小
+ function getFileSize(object){
+ var fileLenth = 0;
+ var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
+ if (isIE) { //如果是ie
+ var objectValue = object.value;
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ fileLenth = parseInt(fso.GetFile(objectValue).size);
+ } catch (e) {
+ fileLenth = 1;
+ }
+ }else{ //对于非IE获得要上传文件的大小
+ try{
+ fileLenth = parseInt(object.files[0].size);
+ }catch (e) {
+ fileLenth = 1; //获取不到取-1
+ }
+ }
+ return fileLenth/1024/1024;
+ }
+
+ function init() {
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ var fwVm = new FotaUpdateViewModel();
+ ko.applyBindings(fwVm, container);
+
+ if(fwVm.updateType() == "mifi_fota"){
+ fwVm.fixPageEnable();
+ addInterval(function () {
+ fwVm.fixPageEnable();
+ }, 1000);
+ }else{
+ if ($(".customfile").length == 0) {
+ $("#fileField").customFileInput();
+ }
+ }
+
+ $('#frmOTAUpdate').validate({
+ submitHandler: function () {
+ fwVm.apply();
+ }
+ });
+ }
+
+ return {
+ init: init
+ };
+});
+
+// SD卡 模块
+
+define("sd", "jquery set service knockout".split(" ") , function($, config, service, ko) {
+
+ // 基目录。感觉此根目录不显示给用户会更友好
+ var basePath = config.SD_BASE_PATH;
+
+ function SDCardViewModel() {
+ var target = this;
+ var SDConfiguration = service.getSDConfiguration();
+
+ target.selectedMode = ko.observable(SDConfiguration.sd_mode);
+ target.orignalMode = ko.observable(SDConfiguration.sd_mode);
+ target.sdStatus = ko.observable(SDConfiguration.sd_status);
+ target.orignalSdStatus = ko.observable(SDConfiguration.sd_status);
+ target.sdStatusInfo = ko.observable("sd_card_status_info_" + SDConfiguration.sd_status);
+ target.selectedShareEnable = ko.observable(SDConfiguration.share_status);
+ target.selectedFileToShare = ko.observable(SDConfiguration.file_to_share);
+ target.selectedAccessType = ko.observable(SDConfiguration.share_auth);
+
+ var path = SDConfiguration.share_file.substring(basePath.length);
+
+ target.pathToShare = ko.observable(path);
+ target.isInvalidPath = ko.observable(false);
+ target.checkEnable = ko.observable(true);
+
+
+ addInterval(function(){
+ target.refreshSimStatus();
+ }, 3000);
+
+ // 检查共享路径是否有效
+ target.checkPathIsValid = ko.computed(function () {
+ if (target.orignalMode() == 0 && target.selectedShareEnable() == '1' && target.selectedFileToShare() == '0'
+ && target.pathToShare() != '' && target.pathToShare() != '/') {
+ service.checkFileExists({
+ "path": basePath + target.pathToShare()
+ }, function (info) {
+ if (info.status != "exist") {
+ target.isInvalidPath(true);
+ } else {
+ target.isInvalidPath(false);
+ }
+ });
+ } else {
+ target.isInvalidPath(false);
+ }
+ });
+
+
+ target.disableApplyBtn = ko.computed(function(){
+ return target.selectedMode() == target.orignalMode() && target.selectedMode() == '1';
+ });
+
+ // 文件共享方式radio点击事件
+ target.fileToShareClickHandle = function(){
+ if(target.selectedFileToShare() == "1"){
+ target.pathToShare("/");
+ }
+ return true;
+ };
+
+ // T卡热插拔时状态监控,拔插卡重刷界面
+ target.refreshSimStatus = function(){
+ if(target.checkEnable()){
+ var SDConfiguration = service.getSDConfiguration();
+ if(SDConfiguration.sd_status && (SDConfiguration.sd_status != target.orignalSdStatus())){
+ if(SDConfiguration.sd_status != '1'){
+ target.sdStatusInfo("sd_card_status_info_" + SDConfiguration.sd_status);
+ target.sdStatus(SDConfiguration.sd_status);
+ target.orignalSdStatus(SDConfiguration.sd_status);
+ $("#sd_card_status_info").translate();
+ }else{
+ clearTimer();
+ clearValidateMsg();
+ init();
+ }
+ }
+ }
+ }
+
+
+
+
+
+ // 表单submit事件处理
+ target.save = function(){
+ showLoading('waiting');
+ target.checkEnable(false);
+ if(target.orignalMode() == target.selectedMode()){
+ showAlert("setting_no_change");
+ } else {
+ service.setSdCardMode({
+ mode : target.selectedMode()
+ }, function(info) {
+ if(info.result){
+ target.orignalMode(target.selectedMode());
+ if(info.result == "processing"){
+ errorOverlay("sd_usb_forbidden");
+ }else{
+ successOverlay();
+ }
+ } else {
+ if (target.selectedMode() == "0") {
+ errorOverlay("sd_not_support");
+ } else {
+ errorOverlay();
+ }
+ }
+ }, function(error) {
+ if (target.selectedMode() == "0") {
+ errorOverlay("sd_not_support");
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+ target.checkEnable(true);
+ return true;
+ };
+
+
+
+ // 保存详细配置信息
+ target.saveShareDetailConfig = function() {
+ showLoading('waiting');
+ target.checkEnable(false);
+ var param = {
+ share_status : target.selectedShareEnable(),
+ share_auth : target.selectedAccessType(),
+ share_file : basePath + target.pathToShare()
+ };
+
+ if (target.selectedShareEnable() == "0") {
+ setSdCardSharing(param);
+ } else {
+ service.checkFileExists({
+ "path" : param.share_file
+ }, function(info) {
+ if (info.status != "exist" && info.status != "processing") {
+ errorOverlay("sd_card_share_setting_" + info.status);
+ } else {
+ setSdCardSharing(param);
+ }
+ }, function(){
+ errorOverlay();
+ });
+ }
+
+ target.checkEnable(true);
+ return true;
+ }
+
+ // 设置SD卡共享信息
+ function setSdCardSharing(param){
+ service.setSdCardSharing(param, function(result) {
+ if (isErrorObject(result)) {
+ if (result.errorType == "no_sdcard") {
+ errorOverlay("sd_card_share_setting_no_sdcard");
+ } else {
+ errorOverlay();
+ }
+ } else {
+ successOverlay();
+ }
+ });
+ }
+ }
+
+ // 将配置的option项转换成Option数组
+ // {Array} configItem [{name: "name1", value: "val1"},{name: "name2", value: "val2"}]
+ function getOptionArray(configItem) {
+ var arr = [];
+ for ( var i = 0; i < configItem.length; i++) {
+ arr.push(new Option(configItem.name, configItem.value));
+ }
+ return arr;
+ }
+
+ function init() {
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ var fwVm = new SDCardViewModel();
+ ko.applyBindings(fwVm, container);
+ $("#sd_card_status_info").translate();
+ $('#sdmode_form').validate({
+ submitHandler : function() {
+ fwVm.save();
+ }
+ });
+ $('#httpshare_form').validate({
+ submitHandler : function() {
+ fwVm.saveShareDetailConfig();
+ },
+ rules : {
+ path_to_share : "check_file_path"
+ }
+ });
+ }
+
+ return {
+ init : init
+ };
+});
+
+// SD卡 HttpShare模块
+
+define("sd_httpshare","jquery underscore jq_fileinput set service knockout".split(" ") ,
+
+ function($, _, fileinput, config, service, ko) {
+
+ // 每页记录条数
+ // 不能够设置每页数据个数,默认:10
+ // 默认值不可修改
+ var perPage = 10;
+
+ // 当前页
+ var activePage = 1;
+
+ // 当前目录,默认根目录""
+ var currentPath = "";
+
+ // 基目录。是否需要显示给用户?用户友好度
+ var basePath = config.SD_BASE_PATH;
+
+ // 前置路径,发现有的设备会将sd卡数据显示在web目录
+ // prePath = "/usr/conf/web";
+ var prePath = "";
+
+ // 是否隐藏重命名按钮
+ var readwrite = true;
+
+ // 文件列表模板
+ var sdFileItemTmpl = null;
+
+ // 分页模板
+ var pagerTmpl = null;
+ // 配置信息原始状态
+ var originalStatus = null;
+
+ var zoneOffsetSeconds = new Date().getTimezoneOffset() * 60;
+
+ var shareFilePath = '';
+
+ var sdIsUploading = false;//SD卡是否正在上传文件
+
+ // 生成分页数据数组
+ // @method generatePager
+ // @param {Integer} totalSize 总记录数
+ // @param {Integer} perPageNum 每页记录条数
+ // @param {Integer} currentPage 当前页
+ // @return {Array} 分页数据数组
+ function generatePager(totalSize, perPageNum, currentPage) {
+ if (totalSize == 0) {
+ return [];
+ }
+ var pagersArr = [];
+ var totalPages = getTotalPages(totalSize, perPageNum);
+ pagersArr.push({
+ pageNum: currentPage - 1,
+ isActive: false,
+ isPrev: true,
+ isNext: false,
+ isDot: false
+ });
+ if (currentPage == 6) {
+ pagersArr.push({
+ pageNum: 1,
+ isActive: false,
+ isPrev: false,
+ isNext: false,
+ isDot: false
+ });
+ } else if (currentPage > 5) {
+ pagersArr.push({
+ pageNum: 1,
+ isActive: false,
+ isPrev: false,
+ isNext: false,
+ isDot: false
+ });
+ pagersArr.push({
+ pageNum: 0,
+ isPrev: false,
+ isNext: false,
+ isActive: false,
+ isDot: true
+ });
+ }
+ var i;
+ var startPage = currentPage - 4 > 0 ? currentPage - 4 : 1;
+ var endPage = currentPage + 4;
+ for (i = startPage; i <= endPage && i <= totalPages; i++) {
+ pagersArr.push({
+ pageNum: i,
+ isActive: i == currentPage,
+ isPrev: false,
+ isNext: false,
+ isDot: false
+ });
+ }
+ if (currentPage + 5 == totalPages) {
+ pagersArr.push({
+ pageNum: totalPages,
+ isPrev: false,
+ isNext: false,
+ isActive: false,
+ isDot: false
+ });
+ } else if (currentPage + 3 <= totalPages && i - 1 != totalPages) {
+ pagersArr.push({
+ pageNum: 0,
+ isPrev: false,
+ isNext: false,
+ isActive: false,
+ isDot: true
+ });
+ pagersArr.push({
+ pageNum: totalPages,
+ isPrev: false,
+ isNext: false,
+ isActive: false,
+ isDot: false
+ });
+ }
+ pagersArr.push({
+ pageNum: parseInt(currentPage, 10) + 1,
+ isPrev: false,
+ isNext: true,
+ isActive: false,
+ isDot: false
+ });
+ return pagersArr;
+ }
+
+ function getTotalPages(total, perPage){
+ var totalPages = Math.floor(total / perPage);
+ if (total % perPage != 0) {
+ totalPages++;
+ }
+ return totalPages;
+ }
+
+ // 整理文件列表数据,并用模板显示
+ function showFileSet(files) {
+ var i = 0;
+ var shownFiles = $.map(files, function(n) {
+ var obj = {
+ fileName : HTMLEncode(n.fileName),
+ fileType : n.attribute == 'document' ? 'folder' : getFileType(n.fileName),
+ fileSize : getDisplayVolume(n.size, false),
+ filePath : basePath + getCurrentPath() + "/" + n.fileName,
+ lastUpdateTime : transUnixTime((parseInt(n.lastUpdateTime, 10) + zoneOffsetSeconds) * 1000),
+ trClass : i % 2 == 0 ? "even" : "",
+ readwrite : readwrite
+ };
+ i++;
+ return obj;
+ });
+
+ if(sdFileItemTmpl == null){
+ sdFileItemTmpl = $.template("sdFileItemTmpl", $("#sdFileItemTmpl"));
+ }
+ $("#fileList_container").html($.tmpl("sdFileItemTmpl", {data: shownFiles}));
+ }
+
+ // HttpShareViewModel
+ function HttpShareViewModel() {
+ var isGuest = false;
+ if(window.location.hash == "#httpshare_guest"){
+ isGuest = true;
+ }
+ readwrite = true;
+ activePage = 1;
+ setCurrentPath('');
+ basePath = config.SD_BASE_PATH;
+ showLoading('waiting');
+ service.getSDConfiguration({}, function(data){
+ originalStatus = data;
+ shareFilePath = data.share_file;
+ if(shareFilePath.charAt(shareFilePath.length - 1) == '/'){//如果路径中有/,则去掉
+ shareFilePath = shareFilePath.substring(0, shareFilePath.length - 1);
+ }
+
+ if(data.sd_status == '1' && data.sd_mode == '0'){ //共享
+ if(isGuest && data.share_status == '1'){// guest and share
+ basePath = shareFilePath;
+ if(data.share_auth == '0'){ // readonly
+ readwrite = false;
+ $("#uploadSection, #delete_file_button, .sd_guest_hide_th", "#httpshare_form").hide();
+ }else{
+ $("#uploadSection, #delete_file_button, .sd_guest_hide_th", "#httpshare_form").show();
+ }
+ $("#go_to_login_button").removeClass("hide");
+ $('#sd_menu').hide();
+ $('.form-note').hide();
+ if ($(".customfile").length == 0) {
+ $("#fileField").customFileInput();
+ }
+ pagerItemClickHandler(1);
+ } else if(isGuest && data.share_status == '0'){ // guest not share
+ $(".form-body .content", "#httpshare_form").hide().remove();
+ $(".form-title", "#httpshare_form").attr("data-trans", "httpshare").html($.i18n.prop("httpshare"));
+ $(".form-note", "#httpshare_form").attr("data-trans", "note_http_share_cannot_access").html($.i18n.prop("note_http_share_cannot_access"));
+ hideLoading();
+ } else {
+ if ($(".customfile").length == 0) {
+ $("#fileField").customFileInput();
+ }
+ pagerItemClickHandler(1);
+ }
+ } else { // usb
+ $(".form-body .content", "#httpshare_form").hide().remove();
+ $(".form-title", "#httpshare_form").attr("data-trans", "httpshare").html($.i18n.prop("httpshare"));
+ $(".form-note", "#httpshare_form").attr("data-trans", "note_http_share_usb_access").html($.i18n.prop("note_http_share_usb_access"));
+ $(".form-note", "#httpshare_form").addClass("margintop10");
+ hideLoading();
+ }
+ }, function(){
+ errorOverlay();
+ $(".form-body .content", "#httpshare_form").hide().remove();
+ $(".form-title", "#httpshare_form").attr("data-trans", "httpshare").html($.i18n.prop("httpshare"));
+ $(".form-note", "#httpshare_form").attr("data-trans", "note_http_share_cannot_access").html($.i18n.prop("note_http_share_cannot_access"));
+ });
+
+ addInterval(function(){
+ !sdIsUploading && self.checkSdStatus();
+ }, 3000);
+
+ // T卡热插拔时状态监控,拔插卡重刷界面
+ self.checkSdStatus = function(){
+ var data = service.getSDConfiguration();
+ if(data.sd_status && (data.sd_status != originalStatus.sd_status)){
+ if(data.sd_status == '1'){
+ window.location.reload();
+ }else{
+ clearTimer();
+ clearValidateMsg();
+ init();
+ }
+ }
+ }
+ }
+
+ // 页码点击事件处理
+ pagerItemClickHandler = function(num) {
+ activePage = num;
+ refreshFileList(getCurrentPath(), activePage);
+ };
+
+ function checkConfiguration(){
+ var data = service.getSDConfiguration();
+ if(!_.isEqual(originalStatus, data)){
+ showAlert('sd_config_changed_reload', function(){
+ init();
+ });
+ return false;
+ }
+ return true;
+ }
+
+ //检查操作路径是否为共享路径,如果是共享路径,给用户提示
+ function inSharePath(path, wording) {
+ var tmpShareFilePath = shareFilePath + '/';
+ var tmpPath = path + '/';
+ if (originalStatus.share_status == '1' && shareFilePath != '' && shareFilePath != '/' && tmpShareFilePath.indexOf(tmpPath) != -1) {
+ showAlert(wording);
+ return true;
+ }
+ return false;
+ }
+
+ // 进入文件夹
+ enterFolder = function(name) {
+ if(!checkConfiguration()){
+ return false;
+ }
+ var path;
+ if (name == "") {
+ path = "";
+ } else {
+ path = getCurrentPath() + '/' + name;
+ }
+ refreshFileList(path, 1);
+ return true;
+ };
+
+ // 回到上一级目录
+ backFolder = function() {
+ if(!checkConfiguration()){
+ return false;
+ }
+ var path = getCurrentPath().substring(0, getCurrentPath().lastIndexOf("/"));
+ refreshFileList(path, 1);
+ return true;
+ };
+
+ // 更新按钮状态
+ refreshBtnsStatus = function() {
+ if (getCurrentPath() == "") {
+ $("#rootBtnLi, #backBtnLi").hide();
+ } else {
+ $("#rootBtnLi, #backBtnLi").show();
+ }
+ if (readwrite) {
+ $("#createNewFolderLi").hide();
+ $("#createNewFolderLi").find(".error").hide();
+ $("#newFolderBtnLi").show();
+ $("#newFolderName").val('');
+ $("#createNewFolderErrorLabel").removeAttr('data-trans').text('');
+ } else {
+ $("#newFolderBtnLi, #createNewFolderLi").hide().remove();
+ }
+ checkDeleteBtnStatus();
+ };
+
+
+ // 刷新文件列表
+ refreshFileList = function(path, index, alertShown) {
+ if(!alertShown){
+ showLoading('waiting');
+ }
+ service.getFileList({
+ path : prePath + basePath + path,
+ index : index
+ }, function(data) {
+ if (isErrorObject(data)) {
+ showAlert(data.errorType);
+ return;
+ }
+ setCurrentPath(path);
+ $("#sd_path").val(path);
+ activePage = index;
+ totalSize = data.totalRecord;
+ showFileSet(data.details);
+ pagination(totalSize); //测试分页时可以将此处totalSize调大
+ refreshBtnsStatus();
+ updateSdMemorySizes();
+ if(!alertShown){
+ hideLoading();
+ }
+ });
+ };
+
+
+ // 显示新建文件夹按钮点击事件
+ openCreateNewFolderClickHandler = function() {
+ $("#newFolderBtnLi").hide();
+ $("#newFolderName").show();
+ $("#createNewFolderLi").show();
+ };
+
+ // 取消显示新建文件夹按钮点击事件
+ cancelCreateNewFolderClickHandler = function() {
+ $("#createNewFolderLi").hide();
+ $("#newFolderName").val('');
+ $("#newFolderBtnLi").show();
+ $("#createNewFolderLi").find(".error").hide();
+ };
+
+ // 新建文件夹按钮点击事件
+ createNewFolderClickHandler = function() {
+ if(!checkConfiguration()){
+ return false;
+ }
+ var newFolderName = $.trim($("#newFolderName").val());
+ var newPath = prePath + basePath + getCurrentPath() + "/" + newFolderName;
+ showLoading('creating');
+ service.checkFileExists({
+ path : newPath
+ }, function(data1) {
+ if (data1.status == "noexist" || data1.status == "processing") {
+ service.createFolder({
+ path : newPath
+ }, function(data) {
+ if (isErrorObject(data)) {
+ showAlert(data.errorType);
+ return false;
+ } else {
+ successOverlay();
+ refreshFileList(getCurrentPath(), 1);
+ }
+ });
+ } else if (data1.status == "no_sdcard") {
+ showAlert("no_sdcard", function(){
+ window.location.reload();
+ });
+ } else if (data1.status == "exist") {
+ $("#createNewFolderErrorLabel").attr('data-trans', 'sd_card_share_setting_exist').text($.i18n.prop("sd_card_share_setting_exist"));
+ hideLoading();
+ }
+ }, function(){
+ errorOverlay();
+ });
+ return true;
+ };
+
+ // 重命名按钮点击事件
+ renameBtnClickHandler = function(oldName) {
+ var oldPath = prePath + basePath + getCurrentPath() + "/" + oldName;
+ if(inSharePath(oldPath, 'sd_share_path_cant_rename')){
+ return false;
+ }
+ showPrompt("sd_card_folder_name_is_null", function() {
+ renamePromptCallback(oldName);
+ }, 160, oldName, checkPromptInput);
+ };
+
+ function renamePromptCallback(oldName){
+ if(!checkConfiguration()){
+ return false;
+ }
+ var promptInput = $("div#confirm div.promptDiv input#promptInput");
+ var newFolderName = $.trim(promptInput.val());
+ var newPath = prePath + basePath + getCurrentPath() + "/" + newFolderName;
+ service.checkFileExists({
+ path : newPath
+ }, function(data1) {
+ if (data1.status == "noexist" || data1.status == "processing") {
+ hideLoadingButtons();
+ var oldPath = prePath + basePath + getCurrentPath() + "/" + oldName;
+ service.fileRename({
+ oldPath : oldPath,
+ newPath : newPath,
+ path : prePath + basePath + getCurrentPath()
+ }, function(data) {
+ if (isErrorObject(data)) {
+ showAlert($.i18n.prop(data.errorType));
+ if(data.errorType == "no_exist"){
+ var alertShown = true;
+ refreshFileList(getCurrentPath(), 1, alertShown);
+ } else if(data.errorType == "processing"){
+ //
+ }
+ } else {
+ refreshFileList(getCurrentPath(), 1);
+ successOverlay();
+ }
+ showLoadingButtons();
+ return true;
+ });
+ } else if (data1.status == "no_sdcard") {
+ showAlert("no_sdcard", function(){
+ window.location.reload();
+ });
+ return false;
+ } else if (data1.status == "exist") {
+ $(".promptErrorLabel").text($.i18n.prop("sd_card_share_setting_exist"));
+ return false;
+ }
+ return true;
+ }, function(){
+ errorOverlay();
+ });
+ return false;
+ }
+
+ // Prompt弹出框INPUT校验函数
+ function checkPromptInput(){
+ var promptInput = $("div#confirm div.promptDiv input#promptInput");
+ var newFileName = $.trim(promptInput.val());
+ var newPath = (prePath + basePath + getCurrentPath() + "/" + newFileName).replace("//", "/");
+ var checkResult = checkFileNameAndPath(newFileName, newPath);
+ if (1 == checkResult) {
+ $(".promptErrorLabel").text($.i18n.prop("sd_upload_rename_null"));//tip filena is null
+ return false;
+ }else if (2 == checkResult) {
+ $(".promptErrorLabel").text($.i18n.prop("sd_card_path_too_long"));
+ return false;
+ }else if (3 == checkResult) {
+ $(".promptErrorLabel").text($.i18n.prop("check_file_path"));
+ return false;
+ }else{
+ $(".promptErrorLabel").text("");
+ return true;
+ }
+ return true;;
+ }
+
+ hideLoadingButtons = function () {
+ $(".buttons", "#confirm").hide();
+ };
+
+ showLoadingButtons = function () {
+ $(".buttons", "#confirm").show();
+ };
+
+ // 删除按钮点击事件
+ deleteBtnClickHandler = function() {
+ if(!checkConfiguration()){
+ return false;
+ }
+ var files = $("input:checkbox:checked", "#fileList_container");
+ var fileNames = "";
+ if (!files || files.length == 0) {
+ return false;
+ }
+ var hasSharePath = false;
+ $.each(files, function (i, n) {
+ var theFile = $(n).val();
+ if (inSharePath(prePath + basePath + getCurrentPath() + "/" + theFile, {msg: 'sd_share_path_cant_delete', params: [theFile]})) {
+ hasSharePath = true;
+ return false;
+ }
+ return true;
+ });
+ if (hasSharePath) {
+ return false;
+ }
+ showConfirm("confirm_data_delete", function(){
+ $.each(files, function(i, n) {
+ fileNames += $(n).val() + "*";
+ });
+ var thePath = prePath + basePath + getCurrentPath();
+ service.deleteFilesAndFolders({
+ path : thePath,
+ names : fileNames
+ }, function(data) {
+ if (data.status == "failure") {
+ showAlert("delete_folder_failure");
+ }
+ else if(data.status == "no_sdcard"){
+ showAlert("no_sdcard");
+ }
+ else if(data.status == "processing"){
+ showAlert("sd_file_processing_cant_delete");
+ }
+ else if(data.status == "success"){
+ successOverlay();
+ }
+ refreshFileList(getCurrentPath(), 1);
+ }, function(){
+ errorOverlay();
+ });
+ });
+ return true;
+ };
+
+ // 文件上传按钮点击事件
+ fileUploadSubmitClickHandler = function(ifReName) {
+ if(ifReName){
+ var fileName = $.trim($("div#confirm div.promptDiv input#promptInput").val());
+ }else{
+ var fileName = $(".customfile").attr('title');
+ }
+ var newPath = (basePath + getCurrentPath() + "/" + fileName).replace("//", "/");
+ var fileSize = getFileSize($("#fileField")[0]);
+ if(!checkuploadFileNameAndPath(fileName, newPath, fileSize)){
+ return false;
+ }
+ doCheckAndUpload(fileName, newPath, fileSize);
+ };
+
+ function doCheckAndUpload(fileName, newPath, fileSize){
+ service.getSdMemorySizes({}, function(data) {
+ if (isErrorObject(data)) {
+ showAlert(data.errorType);
+ return false;
+ }
+ if (data.availableMemorySize < fileSize) {
+ showAlert("sd_upload_space_not_enough");
+ return false;
+ }
+ $.modal.close();
+ showLoading('uploading', '<span data-trans="note_uploading_not_refresh">' + $.i18n.prop('note_uploading_not_refresh') + '</span>');
+ service.checkFileExists({
+ path : newPath
+ }, function(data1) {
+ if (data1.status == "noexist") {
+ $("#fileUploadForm").attr("action", "/cgi-bin/httpshare/" + URLEncodeComponent(fileName));
+ var currentTime = new Date().getTime();
+ $("#path_SD_CARD_time").val(transUnixTime(currentTime));
+ $("#path_SD_CARD_time_unix").val(Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3));
+ if(!iframeLoadBinded){
+ bindIframeLoad();
+ }
+ sdIsUploading = true;
+ $("#fileUploadForm").submit();
+ } else if (data1.status == "no_sdcard") {
+ showAlert("no_sdcard", function(){
+ window.location.reload();
+ });
+ } else if (data1.status == "processing") {
+ showAlert("sd_upload_file_is_downloading");//("system is downloading,try later!");
+ }else if (data1.status == "exist") {
+ showPrompt("sd_upload_rename",function(){
+ fileUploadSubmitClickHandler(true);
+ },160, fileName, checkPromptInput, clearUploadInput);
+ }
+ }, function(){
+ errorOverlay();
+ });
+ return true;
+ });
+ }
+
+ var iframeLoadBinded = false;
+ function bindIframeLoad(){
+ iframeLoadBinded = true;
+ $('#fileUploadIframe').load(function() {
+ sdIsUploading = false;
+ var txt = $('#fileUploadIframe').contents().find("body").html().toLowerCase();
+ var alertShown = false;
+ if (txt.indexOf('success') != -1) {
+ successOverlay();
+ } else if (txt.indexOf('space_not_enough') != -1) {
+ alertShown = true;
+ showAlert('sd_upload_space_not_enough');
+ } else if (txt.indexOf('data_lost') != -1) {
+ alertShown = true;
+ showAlert('sd_upload_data_lost');
+ } else {
+ errorOverlay();
+ }
+
+ clearUploadInput();
+ refreshFileList(getCurrentPath(), 1, alertShown);
+ });
+ }
+
+ // 更新SD卡容量显示数据
+ updateSdMemorySizes = function() {
+ service.getSdMemorySizes({}, function(data) {
+ if (isErrorObject(data)) {
+ showAlert(data.errorType);
+ return false;
+ }
+ var total = getDisplayVolume(data.totalMemorySize, false);
+ var used = getDisplayVolume(data.totalMemorySize - data.availableMemorySize, false);
+ $("#sd_volumn_used").text(used);
+ $("#sd_volumn_total").text(total);
+ return true;
+ });
+ };
+
+ // 翻页
+ pagination = function(fileTotalSize) {
+ var pagers = generatePager(fileTotalSize, perPage, parseInt(activePage, 10));
+ if(pagerTmpl == null){
+ pagerTmpl = $.template("pagerTmpl", $("#pagerTmpl"));
+ }
+ $(".pager", "#fileListButtonSection").html($.tmpl("pagerTmpl", {data: {pagers : pagers, total : getTotalPages(fileTotalSize, perPage)}}));
+ renderCheckbox();
+ $(".content", "#httpshare_form").translate();
+ };
+
+ // 下载文件是检查文件路径是否包含特殊字符
+ checkFilePathForDownload = function(path){
+ if(!checkConfiguration()){
+ return false;
+ }
+ var idx = path.lastIndexOf('/');
+ var prePath = path.substring(0, idx+1);
+ var name = path.substring(idx+1, path.length);
+ if(checkFileNameChars(prePath, true) && checkFileNameChars(name, false)){
+ return true;
+ }
+ showAlert('sd_card_invalid_chars_cant_download');
+ return false;
+ };
+
+ gotoLogin = function(){
+ window.location.href="#entry";
+ };
+
+ // 事件绑定
+ function bindEvent(){
+ $('#createNewFolderForm').validate({
+ submitHandler : function() {
+ createNewFolderClickHandler();
+ },
+ rules : {
+ newFolderName : {sd_card_path_too_long:true,check_filefold_name: true}
+ }
+ });
+ $("p.checkbox", "#httpshare_form").die().live('click', function () {
+ addTimeout(function () {
+ checkDeleteBtnStatus();
+ }, 100);
+ });
+ $(".icon-download", "#httpshare_form").die().live("click", function () {
+ return checkFilePathForDownload($(this).attr("filelocal"));
+ });
+ $(".folderTd", "#httpshare_form").die().live("click", function () {
+ return enterFolder($(this).attr("filename"));
+ });
+ $(".fileRename", "#httpshare_form").die().live("click", function () {
+ return renameBtnClickHandler($(this).attr("filename"));
+ });
+ iframeLoadBinded = false;
+ }
+
+
+ // 刷新删除按钮状态
+ function checkDeleteBtnStatus(){
+ var checkedItem = $("p.checkbox.checkbox_selected", '#fileListSection');
+ if(checkedItem.length > 0){
+ enableBtn($('#delete_file_button'));
+ } else {
+ disableBtn($('#delete_file_button'));
+ }
+ }
+
+
+ // 文件名和路径检查
+ function checkFileNameAndPath(filename, path) {
+ if (filename == "" || filename.length > 25) {
+ return 1;
+ }
+ if (path.length >= 200) {
+ return 2;
+ }
+ if (!checkFileNameChars(filename, false)) {
+ return 3;
+ }
+ }
+
+ // 文件名特殊字符检查
+ function checkFileNameChars(filename, isIncludePath) {
+ var ASCStringInvalid = '+/:*?<>\"\'\\|#&`~';
+ if(isIncludePath){
+ ASCStringInvalid = '+:*?<>\"\'\\|#&`~';
+ }
+ var flag = false;
+ var dotFlag = false;
+ var reg = /^\.+$/;
+ for ( var filenamelen = 0; filenamelen < filename.length; filenamelen++) {
+ for ( var ACSlen = 0; ACSlen < ASCStringInvalid.length; ACSlen++) {
+ if (filename.charAt(filenamelen) == ASCStringInvalid.charAt(ACSlen)) {
+ flag = true;
+ break;
+ }
+ }
+ if (reg.test(filename)) {
+ dotFlag = true;
+ }
+ if (flag || dotFlag) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ function checkuploadFileNameAndPath(fileName, newPath, fileSize){
+ if(!checkConfiguration()){
+ return false;
+ }
+
+ if (typeof fileName == "undefined" || fileName == '' || fileName == $.i18n.prop("no_file_selected")) {
+ showAlert("sd_no_file_selected");
+ return false;
+ }
+ if (newPath.length >= 200) {
+ showAlert("sd_card_path_too_long");
+ return false;
+ }
+
+ if (fileSize/1024/1024/1024 > 2){ //no more than 2G
+ showAlert("sd_file_size_too_big");
+ return false;
+ }
+
+ if (fileName.indexOf('*') >= 0){ //no *
+ showAlert("sd_file_name_invalid");
+ return false;
+ }
+ return true;
+ }
+
+
+ //清空上传控件
+ function clearUploadInput(){
+ $("#fileField").closest('.customfile').before('<input id="fileField" name="filename" maxlength="200" type="file" dir="ltr"/>').remove();
+ addTimeout(function(){
+ $("#fileField").customFileInput();
+ }, 0);
+ $("#uploadBtn", "#uploadSection").attr("data-trans", "browse_btn").html($.i18n.prop('browse_btn'));
+ $(".customfile", "#uploadSection").removeAttr("title");
+ $(".customfile span.customfile-feedback", "#uploadSection")
+ .html('<span data-trans="no_file_selected">'+$.i18n.prop('no_file_selected')+'</span>')
+ .attr('class', 'customfile-feedback');
+ }
+
+
+ function getCurrentPath(){
+ return currentPath;
+ }
+
+ function setCurrentPath(path){
+ if(path.lastIndexOf("/") == path.length - 1){
+ currentPath = path.substring(0, path.length - 1);
+ } else {
+ currentPath = path;
+ }
+ }
+
+
+ function getFileSize(object){
+ var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
+ if (isIE) { //如果是ie
+ var objValue = object.value;
+ try {
+ var fileSysObj = new ActiveXObject("Scripting.FileSystemObject");
+ fileLenth = parseInt(fileSysObj.GetFile(objValue).size);
+ } catch (e) { //('IE内核取不到长度');
+ fileLenth = 1;
+ }
+ }else{ //其他
+ try{//对于非IE获得要上传文件的大小
+ fileLenth = parseInt(object.files[0].size);
+ }catch (e) {
+ fileLenth=1; //获取不到取-1
+ }
+ }
+ return fileLenth;
+ }
+
+ function init() {
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ var fwVm = new HttpShareViewModel();
+ ko.applyBindings(fwVm, container);
+ bindEvent();
+ }
+
+
+ jQuery.validator.addMethod("check_filefold_name", function(value, element, param) {
+ var result = checkFileNameChars(value, false);
+ return this.optional(element) || result;
+ });
+
+ jQuery.validator.addMethod("sd_card_path_too_long", function(value, element, param) {
+ var newFolderName = $.trim($("#newFolderName").val());
+ var newPath = prePath + basePath + getCurrentPath() + "/" + newFolderName;
+ var result = true;
+ if (newPath.length >= 200) {
+ result = false;
+ }
+ return this.optional(element) || result;
+ });
+
+ return {
+ init : init
+ };
+});
+
+define("ussd","set service knockout jquery".split(" "), function (set, fnc, libko, libjq) {
+ var time_interval = 0;
+ var initFlg = true;
+ var numTimeout = 0;
+ var replyFlg = false;
+ var ussd_action = 1;
+
+ function init() {
+ var container = libjq('#container')[0];
+ libko.cleanNode(container);
+ var vm = new vmUSSD();
+ libko.applyBindings(vm, container);
+
+ }
+ var USSDLocation = {
+ SEND: 0,
+ REPLY: 1
+ };
+ function vmUSSD() {
+ var target = this;
+
+ target.hasUpdateCheck = set.HAS_UPDATE_CHECK;
+ target.ussd_action = libko.observable(ussd_action);
+ target.USSDLocation = libko.observable(USSDLocation.SEND);
+ target.USSDReply = libko.observable("");
+ target.USSDSend = libko.observable("");
+ target.hasDdns = set.DDNS_SUPPORT;
+
+ function checkTimeout() {
+ if (replyFlg) {
+ replyFlg = true;
+ window.clearInterval(time_interval);
+ numTimeout = 0;
+ } else {
+ if (numTimeout > 28) {
+ replyFlg = true;
+ window.clearInterval(time_interval);
+ showAlert("ussd_operation_timeout");
+ target.USSDReply("");
+ target.USSDSend("");
+ target.USSDLocation(USSDLocation.SEND);
+ numTimeout = 0;
+
+ } else {
+ numTimeout++;
+ }
+
+ }
+ };
+
+ target.sendToNet = function () {
+ numTimeout = 0;
+ window.clearInterval(time_interval);
+ var command = target.USSDSend();
+
+ var idx_t = 0;
+ var indexChar;
+ for (idx_t = 0; idx_t < command.length; ) { //corem0418, delte left blanks and right blanks
+ indexChar = command.charAt(idx_t);
+ if (indexChar == ' ') {
+ if (command.length > 1) {
+ command = command.substr(idx_t + 1);
+ } else {
+ command = ''; // string is filled with blank
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
+ for (idx_t = command.length - 1; idx_t >= 0 && command.length > 0; --idx_t) {
+ indexChar = command.charAt(idx_t);
+ if (indexChar == ' ') {
+ if (command.length > 1) {
+ command = command.substr(0, idx_t);
+ } else {
+ command = ''; // string is filled with blank
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (('string' != typeof(command)) || ('' == command)) {
+ showAlert("ussd_error_input");
+ return;
+ }
+
+ showLoading('waiting');
+
+ var tmp = {};
+ tmp.operator = "ussd_send";
+ tmp.strUSSDCommand = command;
+ tmp.sendOrReply = "send";
+
+ fnc.getUSSDResponse(tmp, function (result, content) {
+ hideLoading();
+ if (result) {
+ USSD_reset();
+ target.USSDLocation(USSDLocation.REPLY);
+ target.ussd_action(content.ussd_action);
+ libjq("#USSD_Content").val(decodeMessage(content.data, true));
+ replyFlg = false;
+ numTimeout = 0;
+ } else {
+ showAlert(content);
+ }
+ });
+ };
+
+ target.replyToNet = function () {
+ numTimeout = 0;
+ window.clearInterval(time_interval);
+ var command = target.USSDReply();
+
+ var idx_t = 0;
+ var indexChar;
+ for (idx_t = 0; idx_t < command.length; ) { //corem0418, delte left blanks and right blanks
+ indexChar = command.charAt(idx_t);
+ if (indexChar == ' ') {
+ if (command.length > 1) {
+ command = command.substr(idx_t + 1);
+ } else {
+ command = ''; // string is filled with blank
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
+ for (idx_t = command.length - 1; idx_t >= 0 && command.length > 0; --idx_t) {
+ indexChar = command.charAt(idx_t);
+ if (indexChar == ' ') {
+ if (command.length > 1) {
+ command = command.substr(0, idx_t);
+ } else {
+ command = ''; // string is filled with blank
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (('string' != typeof(command)) || ('' == command)) {
+ showAlert("ussd_error_input");
+ return;
+ }
+
+ showLoading('waiting');
+
+ var tmp = {};
+ tmp.operator = "ussd_reply";
+ tmp.strUSSDCommand = command;
+ tmp.sendOrReply = "reply";
+
+ fnc.getUSSDResponse(tmp, function (result, content) {
+ hideLoading();
+ if (result) {
+ target.ussd_action(content.ussd_action);
+ libjq("#USSD_Content").val(decodeMessage(content.data, true));
+ replyFlg = false;
+ USSD_reset();
+ numTimeout = 0;
+ } else {
+ showAlert(content);
+ }
+ });
+ };
+
+ USSD_reset = function () {
+ target.USSDReply("");
+ target.USSDSend("");
+ };
+ USSD_cancel = function () {
+ fnc.USSDReplyCancel(function (result) {});
+ };
+
+ target.noReplyCancel = function () {
+ numTimeout = 0;
+ replyFlg = true;
+ window.clearInterval(time_interval);
+ fnc.USSDReplyCancel(function (result) {
+ if (result) {
+ USSD_reset();
+ target.USSDLocation(USSDLocation.SEND);
+ } else {
+ showAlert("ussd_fail");
+ }
+ });
+ };
+
+ //如果首次进入USSD菜单,先发送USSD取消命令,进行初始化
+ if (initFlg) {
+ USSD_cancel();
+ initFlg = false;
+ }
+ }
+
+ return {
+ init: init
+ };
+});
+
+
+define("phonebook","underscore jquery knockout set service jq_chosen".split(" "),
+
+ function (_, $, ko, config, service, chosen) {
+
+ var locationValue = {
+ SIM: "0",
+ DEVICE: "1"
+ };
+ var pageState = {
+ LIST: 0,
+ NEW: 1,
+ EDIT: 2,
+ VIEW: 3,
+ SEND_MSM: 4
+ };
+ //存储位置选项
+ var saveLocationOpts = function (hasSIMCard) {
+ var opts = [];
+ opts.push(new Option($.i18n.prop("device_book"), locationValue.DEVICE));
+ if (hasSIMCard) {
+ opts.push(new Option($.i18n.prop("sim_book"), locationValue.SIM));
+ }
+ return opts;
+ };
+
+ function getCurrentGroup() {
+ return $("#selectedFilterGroup").val();
+ }
+ //列表模板对应的Columns
+ var templateColumns = {
+ cardColumns: [{
+ rowText: "index",
+ display: false
+ }, {
+ rowText: "name"
+ }, {
+ rowText: "mobile_phone_number"
+ }, {
+ rowText: "home_phone_number"
+ }
+ ],
+ listColumns: [{
+ columnType: "checkbox",
+ headerTextTrans: "number",
+ rowText: "index",
+ width: "10%"
+ }, {
+ headerTextTrans: "name",
+ rowText: "name",
+ width: "25%",
+ sortable: true
+ }, {
+ columnType: "image",
+ headerTextTrans: "save_location",
+ rowText: "imgLocation",
+ width: "20%",
+ sortable: true
+ }, {
+ headerTextTrans: "mobile_phone_number",
+ rowText: "mobile_phone_number",
+ width: "30%",
+ sortable: true
+ }, {
+ headerTextTrans: "group",
+ rowText: "transGroup",
+ width: "15%",
+ sortable: true,
+ needTrans: true
+ }
+ ]
+ };
+ //分组选项
+ var groupOpts = function () {
+ var opts = [];
+ opts.push(new Option($.i18n.prop("common"), "common"));
+ opts.push(new Option($.i18n.prop("family"), "family"));
+ opts.push(new Option($.i18n.prop("friend"), "friend"));
+ opts.push(new Option($.i18n.prop("colleague"), "colleague"));
+ return opts;
+ };
+
+ var _phoneBookStopSMSSending = false;
+
+ function pbViewMode() {
+ var target = this;
+
+ //property for common
+ target.pageState = ko.observable(pageState.LIST);
+ target.initFail = ko.observable(true);
+ target.hasSms = ko.observable(config.HAS_SMS);
+
+ var smsHasCapability = true;
+ var smsLeftCount = 0;
+
+ //property for list
+ var capacity = {
+ simMaxNameLen: 0,
+ simMaxNumberLen: 0,
+ IsSimCardFull: true,
+ IsDeviceFull: true,
+ Used: 0,
+ Capacity: 0,
+ Ratio: "(0/0)"
+ };
+ target.capacity = ko.observable(capacity);
+ target.phoneBookCapacity = ko.observable(capacity.Ratio);
+ target.books = ko.observableArray();
+ //列表模板创建
+ target.gridTemplate = new ko.simpleGrid.viewModel({
+ tableClass: "table-fixed",
+ data: target.books(),
+ idName: "index",
+ columns: templateColumns.listColumns,
+ defaultSortField: "name",
+ defaultSortDirection: "ASC",
+ pageSize: 10,
+ tmplType: 'list',
+ searchColumns: ["name", "mobile_phone_number"],
+ primaryColumn: "mobile_phone_number",
+ showPager: true,
+ rowClickHandler: function (dataId) {
+ target.editBooks(dataId, 'view');
+ },
+ deleteHandler: function (dataId) {
+ target.deleteOneBook(dataId);
+ },
+ changeTemplateHandler: function () {
+ target.changeTemplate();
+ }
+ });
+
+ //property for edit or new
+ target.locations = ko.observableArray();
+ target.originLocation = "";
+ target.selectedLocation = ko.observable(locationValue.DEVICE);
+ target.locationTrans = ko.observable();
+ target.locationTransText = ko.observable();
+ target.index = ko.observable(-1);
+ target.name = ko.observable("");
+ target.nameMaxLength = ko.computed(function () {
+ var max = getNameMaxLength();
+ var name = target.name().substring(0, max);
+ target.name(name);
+ return getNameMaxLength();
+ });
+ function getNameMaxLength() {
+ var max = 22;
+ if (target.selectedLocation() == locationValue.DEVICE) {
+ var encodeType = getEncodeType(target.name());
+ if ("UNICODE" == encodeType.encodeType || encodeType.extendLen > 0) {
+ max = 11;
+ } else {
+ max = 22;
+ }
+ //max = 22;
+ } else {
+ //对"^"需要按照2个字符处理
+ var encodeType = getEncodeType(target.name());
+ if ("UNICODE" == encodeType.encodeType || encodeType.extendLen > 0) {
+ max = (target.capacity().simMaxNameLen / 2) - 1;
+ } else {
+ max = target.capacity().simMaxNameLen;
+ }
+ }
+ return max;
+ }
+
+ target.mobile_phone_number = ko.observable("");
+ target.mobileMaxLength = ko.computed(function () {
+ var max = getMobileMaxLength();
+ var mobileNumber = target.mobile_phone_number().substring(0, max);
+ target.mobile_phone_number(mobileNumber);
+ return getMobileMaxLength();
+ });
+ function getMobileMaxLength() {
+ var max = 40;
+ if (target.selectedLocation() == locationValue.DEVICE) {
+ max = 40;
+ } else {
+ max = target.capacity().simMaxNumberLen;
+ }
+ return max;
+ }
+
+ target.home_phone_number = ko.observable("");
+ target.office_phone_number = ko.observable("");
+ target.mail = ko.observable("");
+ target.transEditAreaTitle = ko.dependentObservable(function () {
+ var state = target.pageState();
+ if (state == pageState.EDIT) {
+ return "edit";
+ } else if (state == pageState.NEW) {
+ return "new";
+ } else if (state == pageState.VIEW) {
+ return "view";
+ }
+ });
+ var groups = groupOpts();
+ target.groups = ko.observableArray(groups);
+ target.selectedGroup = ko.observable();
+ target.groupTrans = ko.observable();
+ target.groupTransText = ko.observable();
+
+ target.selectedFilterGroup = ko.observable('all');
+ target.selectedFilterGroupChangeHandler = function () {
+ target.selectedFilterGroup($("#selectedFilterGroup").val());
+ getPhoneBookReady();
+ };
+
+ //property for sendMessage
+ target.showErrorInfo = ko.observable(false);
+ target.messageContent = ko.observable("");
+ target.messageCount = ko.computed(function () {
+ var msgInput = $("#txtSmsContent", "#sendMessage");
+ var msgInputDom = msgInput[0];
+ target.messageContent();
+ var strValue = msgInput.val();
+ var encodeType = getEncodeType(strValue);
+ var maxLength = encodeType.encodeType == 'UNICODE' ? 335 : 765;
+ if (strValue.length + encodeType.extendLen > maxLength) {
+ var scrollTop = msgInputDom.scrollTop;
+ var insertPos = getInsertPos(msgInputDom);
+ var moreLen = strValue.length + encodeType.extendLen - maxLength;
+ var insertPart = strValue.substr(insertPos - moreLen > 0 ? insertPos - moreLen : 0, moreLen);
+ var reversed = insertPart.split('').reverse();
+ var checkMore = 0;
+ var cutNum = 0;
+ for (var i = 0; i < reversed.length; i++) {
+ if (getEncodeType(reversed[i]).extendLen > 0) {
+ checkMore += 2;
+ } else {
+ checkMore++;
+ }
+ if (checkMore >= moreLen) {
+ cutNum = i + 1;
+ break;
+ }
+ }
+ var iInsertToStartLength = insertPos - cutNum;
+
+ target.messageContent(strValue.substr(0, iInsertToStartLength) + strValue.substr(insertPos));
+ if (target.messageContent().length > maxLength) {
+ target.messageContent(target.messageContent().substr(0, maxLength));
+ }
+ setInsertPos(msgInputDom, iInsertToStartLength);
+ msgInputDom.scrollTop = scrollTop;
+ }
+ pbDraftListener();
+ var newValue = $(msgInputDom).val();
+ var newEncodeType = getEncodeType(newValue);
+ var newMaxLength = newEncodeType.encodeType == 'UNICODE' ? 335 : 765;
+ if (newValue.length + newEncodeType.extendLen >= newMaxLength) {
+ $("#msgCount").addClass("colorRed");
+ } else {
+ $("#msgCount").removeClass("colorRed");
+ }
+ return "(" + (newValue.length + newEncodeType.extendLen) + "/" + newMaxLength + ")" + "(" + getSmsCount(newValue) + "/5)";
+ });
+
+ target.clear = function (isNeedInit) {
+ if (target.pageState() == pageState.SEND_MSM) {
+ smsPageCheckDraft(clearPhonebookForm, isNeedInit);
+ } else {
+ clearPhonebookForm(isNeedInit);
+ }
+ config.resetContentModifyValue();
+ };
+
+ //通过按钮返回列表状态事件处理
+ target.btnClear = function (isNeedInit) {
+ if (target.pageState() == pageState.SEND_MSM) {
+ smsPageCheckDraft(clearPhonebookForm, isNeedInit);
+ config.resetContentModifyValue();
+ } else if ((target.pageState() == pageState.NEW || target.pageState() == pageState.EDIT) && (target.preContent.location != target.selectedLocation()
+ || target.preContent.name != target.name()
+ || target.preContent.mobile_phone_number != target.mobile_phone_number()
+ || target.preContent.home_phone_number != target.home_phone_number()
+ || target.preContent.office_phone_number != target.office_phone_number()
+ || target.preContent.mail != target.mail()
+ || target.preContent.group != target.selectedGroup())) {
+ showConfirm("leave_page_info", {
+ ok: function () {
+ clearPhonebookForm(isNeedInit);
+ config.resetContentModifyValue();
+ },
+ no: function () {
+ return false;
+ }
+ });
+ } else {
+ clearPhonebookForm(isNeedInit);
+ config.resetContentModifyValue();
+ }
+ };
+
+ function clearPhonebookForm(isNeedInit) {
+ $("#frmPhoneBook").hide();
+ target.pageState(pageState.LIST);
+ target.index(-1);
+ target.name("");
+ target.mobile_phone_number("");
+ target.home_phone_number("");
+ target.office_phone_number("");
+ target.mail("");
+ target.messageContent("");
+ if (true == isNeedInit) {
+ refreshPage();
+ }
+ target.gridTemplate.clearAllChecked();
+ clearValidateMsg();
+ $("#books ").translate();
+ $("#frmPhoneBook").show();
+ }
+
+ //检查SIM卡状态
+ target.checkHasSIMCard = function (showMsg) {
+ var status = service.getStatusInfo();
+ if (status.simStatus != "modem_init_complete") {
+ if (showMsg) {
+ showAlert("sim_removed", function () {
+ target.pageState(pageState.LIST);
+ target.clear(true);
+ });
+ }
+ return false;
+ }
+ return true;
+ };
+
+ //保存电话本事件
+ target.save = function () {
+ var saveBook = function (index) {
+ var isSaveInSIM = (location == locationValue.SIM);
+ if (isSaveInSIM) {
+ if (!target.checkHasSIMCard(true)) {
+ return;
+ }
+ }
+ if (target.pageState() == pageState.NEW || (target.pageState() == pageState.EDIT && location != target.originLocation)) {
+ if (isSaveInSIM) {
+ if (target.capacity().IsSimCardFull) {
+ showAlert("sim_full");
+ return;
+ }
+ } else {
+ if (target.capacity().IsDeviceFull) {
+ showAlert("device_full");
+ return;
+ }
+ }
+ }
+ var name = target.name();
+ var mobile_phone_number = target.mobile_phone_number();
+ if ($.trim(name) == "" || $.trim(mobile_phone_number) == "") {
+ return;
+ }
+ showLoading('saving');
+ var params = {};
+ params.location = location;
+ params.index = index;
+ params.name = name;
+ params.mobile_phone_number = mobile_phone_number;
+ if (!isSaveInSIM) {
+ params.home_phone_number = target.home_phone_number();
+ params.office_phone_number = target.office_phone_number();
+ params.mail = target.mail();
+ params.group = target.selectedGroup();
+ }
+ if (target.selectedLocation() != target.originLocation) {
+ params.delId = target.index();
+ }
+ service.savePhoneBook(params, target.callback);
+ }
+ var location = target.selectedLocation();
+ var editIndex = (location == target.originLocation) ? target.index() : -1;
+ if (location == locationValue.SIM && target.originLocation == locationValue.DEVICE) {
+ showConfirm("change_device_to_sim_confirm", function () {
+ saveBook(editIndex);
+ });
+ } else {
+ saveBook(editIndex);
+ }
+ };
+ //打开添加电话本记录页面事件
+ target.openNewPage = function () {
+ if (target.pageState() == pageState.SEND_MSM) {
+ pbDraftListener();
+ smsPageCheckDraft(openNewPageAct, false);
+ } else if (target.pageState() == pageState.EDIT && (target.preContent.location != target.selectedLocation()
+ || target.preContent.name != target.name()
+ || target.preContent.mobile_phone_number != target.mobile_phone_number()
+ || target.preContent.home_phone_number != target.home_phone_number()
+ || target.preContent.office_phone_number != target.office_phone_number()
+ || target.preContent.mail != target.mail()
+ || target.preContent.group != target.selectedGroup())) {
+ showConfirm("leave_page_info", {
+ ok: function () {
+ openNewPageAct(false);
+ },
+ no: function () {
+ return false;
+ }
+ });
+ } else {
+ openNewPageAct(false);
+ }
+ };
+ function openNewPageAct(isNeedInit) {
+ target.pageState(pageState.NEW);
+ target.selectedLocation(locationValue.DEVICE);
+ target.originLocation = "";
+ if (target.checkHasSIMCard(false)) {
+ target.locations(saveLocationOpts(true));
+ } else {
+ target.locations(saveLocationOpts(false));
+ }
+ var group = getCurrentGroup();
+ if (group != "all") {
+ target.selectedGroup(group);
+ } else {
+ target.selectedGroup("common");
+ }
+ target.name("");
+ target.mobile_phone_number("");
+ target.home_phone_number("");
+ target.office_phone_number("");
+ target.mail("");
+ target.index(-1);
+ target.dynamicTranslate();
+ preOpenEditPage();
+ }
+ //打开添加电话本记录编辑页面事件
+ target.openPage = function (option) {
+ var index;
+ if (target.pageState() == pageState.LIST) {
+ var result = target.checkSelect(option);
+ if (!result.isCorrectData)
+ return;
+ index = result.selectedIds[0];
+ } else {
+ index = target.index();
+ }
+ target.editBooks(index, option);
+ };
+ //打开添加电话本记录查看页面事件
+ target.openViewPage = function () {
+ target.openPage("view");
+ };
+ //打开添加电话本记录查看页面事件
+ target.openEditPage = function () {
+ target.openPage("edit");
+ if ($.browser.mozilla) {
+ $("#txtName, #txtMobile").removeAttr('maxlength');
+ }
+ preOpenEditPage();
+ };
+ //编辑电话本事件处理
+ target.editBooks = function (selectedId, option) {
+ if (!selectedId)
+ return;
+
+ if (target.checkHasSIMCard(false)) {
+ target.locations(saveLocationOpts(true));
+ } else {
+ target.locations(saveLocationOpts(false));
+ }
+ var data = target.books();
+ for (var i = 0; i < data.length; i++) {
+ var n = data[i];
+ if (n.index == selectedId) {
+ target.index(n.index);
+ target.selectedLocation(n.location);
+ target.originLocation = n.location;
+ var trans = (n.location == locationValue.DEVICE) ? "device" : "sim";
+ target.locationTrans(trans);
+ var transText = $.i18n.prop("trans");
+ target.locationTransText(transText);
+ target.name(n.name);
+ target.mobile_phone_number(n.mobile_phone_number);
+ target.home_phone_number(n.home_phone_number);
+ target.office_phone_number(n.office_phone_number);
+ target.mail(n.mail);
+ target.selectedGroup(n.group);
+ target.groupTrans("group_" + n.group);
+ target.groupTransText($.i18n.prop(target.groupTrans()));
+ if (option == "edit") {
+ target.pageState(pageState.EDIT);
+ } else {
+ target.pageState(pageState.VIEW);
+ }
+ break;
+ }
+ }
+ target.dynamicTranslate();
+
+ if (target.selectedLocation() == locationValue.SIM) {
+ target.checkHasSIMCard(true)
+ }
+ };
+ //翻译编辑区域
+ target.dynamicTranslate = function () {
+ $("#container").translate();
+ };
+ //删除一条电话本事件处理(card模式使用)
+ target.deleteOneBook = function (index) {
+ showConfirm("confirm_pb_delete", function () {
+ showLoading('deleting');
+ var params = {};
+ params.indexs = [String(index)];
+ service.deletePhoneBooks(params, target.callback);
+ });
+ return false;
+ };
+ //删除一条电话本事件处理
+ target.deleteBook = function () {
+ target.deleteOneBook(target.index());
+ };
+ //删除一条或多条电话本事件处理
+ target.deleteBooks = function () {
+ var result = target.checkSelect("delete");
+ if (!result.isCorrectData)
+ return;
+ showConfirm("confirm_pb_delete", function () {
+ showLoading('deleting');
+ var params = {};
+ params.indexs = result.selectedIds;
+ service.deletePhoneBooks(params, target.callback);
+ });
+ };
+ //判断电话本选中
+ target.checkSelect = function (pState) {
+ var ids;
+ if ("send" == pState) {
+ ids = target.gridTemplate.selectedPrimaryValue();
+ } else {
+ ids = target.gridTemplate.selectedIds();
+ }
+
+ var isCorrectData = true;
+ if (ids.length == 0) {
+ showAlert("no_data_selected");
+ isCorrectData = false;
+ } else if ("edit" == pState || "view" == pState) {
+ if (ids.length > 1) {
+ showAlert("too_many_data_selected");
+ isCorrectData = false;
+ }
+ } else if ("send" == pState) {
+ if (ids.length > 5) {
+ showAlert("max_send_number");
+ isCorrectData = false;
+ }
+ }
+ return {
+ selectedIds: ids,
+ isCorrectData: isCorrectData
+ };
+ };
+ //全部删除电话本事件处理
+ target.deleteAllBooks = function () {
+ showConfirm("confirm_data_delete", function () {
+ showLoading('deleting');
+ var group = getCurrentGroup();
+ var params = {};
+ if (group == "all") {
+ params.location = 2;
+ service.deleteAllPhoneBooks(params, target.callback);
+ } else {
+ params.location = 3;
+ params.group = group;
+ service.deleteAllPhoneBooksByGroup(params, target.callback);
+ }
+ });
+ };
+
+ target.callback = function (data) {
+ if (data && data.result == "success") {
+ target.clear(true);
+ $("#books ").translate();
+ renderCheckbox();
+ successOverlay(null, true);
+ } else {
+ errorOverlay();
+ }
+ };
+ //变换显示方式事件处理
+ target.changeTemplate = function () {
+ if (target.gridTemplate.tmplType == "card") {
+ target.gridTemplate.tmplType = "list";
+ target.gridTemplate.pageSize = 10;
+ target.gridTemplate.columns = templateColumns.listColumns;
+ } else {
+ target.gridTemplate.tmplType = "card";
+ target.gridTemplate.pageSize = 10;
+ target.gridTemplate.columns = templateColumns.cardColumns;
+ }
+ refreshPage();
+ $("#books ").translate();
+ };
+ //显示发送短信页面
+ target.openSendMessagePage = function () {
+ if (pageState.SEND_MSM == target.pageState()) {
+ return;
+ }
+ if ((target.pageState() == pageState.EDIT || pageState.NEW == target.pageState()) && (target.preContent.location != target.selectedLocation()
+ || target.preContent.name != target.name()
+ || target.preContent.mobile_phone_number != target.mobile_phone_number()
+ || target.preContent.home_phone_number != target.home_phone_number()
+ || target.preContent.office_phone_number != target.office_phone_number()
+ || target.preContent.mail != target.mail()
+ || target.preContent.group != target.selectedGroup())) {
+ showConfirm("leave_page_info", {
+ ok: function () {
+ openSendMessagePageAct();
+ },
+ no: function () {
+ return false;
+ }
+ });
+ } else {
+ openSendMessagePageAct();
+ }
+ };
+
+ function openSendMessagePageAct() {
+ if (pageState.NEW == target.pageState()) {
+ target.pageState(pageState.SEND_MSM);
+ showAlert("no_data_selected");
+ target.clear();
+ return;
+ }
+ var selectedNumber = null;
+ if (pageState.LIST == target.pageState()) {
+ var result = target.checkSelect("send");
+ if (!result.isCorrectData)
+ return;
+ selectedNumber = result.selectedIds;
+ } else {
+ selectedNumber = target.mobile_phone_number();
+ }
+
+ var select = $("#chosenUserList .chosen-select-deselect");
+ select.empty();
+ var options = [];
+ var tmp = [];
+ for (var j = 0; j < config.phonebook.length; j++) {
+ var book = config.phonebook[j];
+ if ($.inArray(book.pbm_number, tmp) == -1) {
+ options.push(new Option(book.pbm_name + "/" + book.pbm_number, book.pbm_number, false, true));
+ tmp.push(book.pbm_number);
+ } else {
+ for (var i = 0; i < options.length; i++) {
+ if (options[i].value == book.pbm_number) {
+ options[i].text = book.pbm_name + "/" + book.pbm_number;
+ break;
+ }
+ }
+ }
+ }
+ var opts = "";
+ $.each(options, function (i, e) {
+ opts += "<option value='" + HTMLEncode(e.value) + "'>" + HTMLEncode(e.text) + "</option>";
+ });
+ select.append(opts);
+ select.chosen({
+ max_selected_options: 5,
+ search_contains: true,
+ width: '545px'
+ });
+ $("#chosenUserSelect").val(selectedNumber);
+ $("#chosenUserSelect").trigger("chosen:updated.chosen");
+ config.resetContentModifyValue();
+ pbDraftListener();
+ target.pageState(pageState.SEND_MSM);
+ }
+
+ //发送短信
+ target.sendMessage = function () {
+ service.getSmsCapability({}, function (capability) {
+ var hasCapability = capability.nvUsed < capability.nvTotal;
+ if (!hasCapability) {
+ showAlert("sms_capacity_is_full_for_send");
+ return false;
+ }
+ var numbers = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));
+ if (numbers.length + capability.nvUsed > capability.nvTotal) {
+ showAlert({
+ msg: "sms_capacity_will_full_just",
+ params: [capability.nvTotal - capability.nvUsed]
+ });
+ return false;
+ }
+ target.sendMessageAction();
+ return true;
+ });
+ };
+
+ target.sendMessageAction = function () {
+ var numbers = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));
+
+ if (!numbers || numbers.length == 0) {
+ target.showErrorInfo(true);
+ var timer = addTimeout(function () {
+ target.showErrorInfo(false);
+ window.clearTimeout(timer);
+ }, 5000);
+ return;
+ }
+ var content = target.messageContent();
+ var sentCount = 0;
+ var failCount = 0;
+ if (numbers.length > 1) {
+ showLoading("sending", "<button id='btnStopSending' onclick='phoneBookStopSMSSending();' class='btn btn-primary'>"
+ + $.i18n.prop("sms_stop_sending")
+ + "</button>");
+ } else {
+ showLoading('sending');
+ }
+ var callback = function (data) {
+ sentCount++;
+ if (sentCount == numbers.length) {
+ $("#chosenUserSelect").val("");
+ target.messageContent("");
+ config.CONTENT_MODIFIED.modified = false;
+ if (failCount == 0) {
+ successOverlay();
+ location.hash = "#msg_list";
+ } else {
+ var msg = $.i18n.prop("success_info") + $.i18n.prop("colon") + (sentCount - failCount)
+ + "<br/>" + $.i18n.prop("error_info") + $.i18n.prop("colon") + (failCount);
+ showAlert(msg, function () {
+ location.hash = "#msg_list";
+ });
+ }
+
+ } else {
+ sendSMS();
+ }
+ }
+ _phoneBookStopSMSSending = false;
+ var sendSMS = function () {
+ if (_phoneBookStopSMSSending) {
+ hideLoading();
+ return;
+ }
+ if ((sentCount + 1) == numbers.length) {
+ $("#loading #loading_container").html("");
+ }
+ service.sendSMS({
+ number: numbers[sentCount],
+ message: content,
+ id: -1
+ }, function (data) {
+ callback(data);
+ }, function (data) {
+ failCount++;
+ callback(data);
+ });
+ };
+ sendSMS();
+ };
+ //清除搜索关键字事件
+ target.clearSearchKey = function () {
+ target.gridTemplate.searchInitStatus(true);
+ target.gridTemplate.searchKey($.i18n.prop("search"));
+ $("#ko_grid_search_txt").addClass("ko-grid-search-txt-default").attr("data-trans", "search");
+ };
+ //点击搜索输入框事件
+ target.searchTextClick = function () {
+ var searchText = $("#ko_grid_search_txt");
+ if (searchText.hasClass("ko-grid-search-txt-default")) {
+ target.gridTemplate.searchKey("");
+ target.gridTemplate.searchInitStatus(false);
+ searchText.removeClass("ko-grid-search-txt-default").removeAttr("data-trans");
+ }
+ };
+ //离开搜索输入框事件
+ target.searchTextBlur = function () {
+ var txt = $.trim(target.gridTemplate.searchKey()).toLowerCase();
+ if (txt == "") {
+ target.clearSearchKey();
+ }
+ };
+ //当前表格是否有数据
+ target.hasData = ko.computed(function () {
+ return target.gridTemplate.afterSearchData().length > 0;
+ });
+ //当前表格是否有选中的数据
+ target.hasChecked = ko.computed(function () {
+ return target.gridTemplate.checkedCount() > 0;
+ });
+ //是否可以点击发送按钮
+ target.canSend = ko.computed(function () {
+ var checked = target.gridTemplate.checkedCount();
+ if (!target.checkHasSIMCard(false)) {
+ return false;
+ }
+ return (checked > 0 && checked <= 5);
+ });
+
+ //发送短信时,选择用户变化的监控事件
+ target.draftListenerEvent = function () {
+ pbDraftListener();
+ };
+ //文档内容监听,判断是否修改过
+ function pbDraftListener() {
+ var smsHasCapability = true;
+ if (smsHasCapability) {
+ var content = target.messageContent();
+ var hasContent = false;
+ var numbers = getSelectValFromChosen($('.search-choice', '#chosenUserSelect_chosen'));
+ var noContactSelected = !(numbers && numbers.length > 0);
+ if (typeof content == "undefined" || content == '') {
+ config.resetContentModifyValue();
+ return false;
+ } else {
+ hasContent = true;
+ }
+ if (hasContent && !noContactSelected) {
+ config.CONTENT_MODIFIED.modified = true;
+ config.CONTENT_MODIFIED.message = 'sms_to_save_draft';
+ config.CONTENT_MODIFIED.callback.ok = saveDraftAction;
+ config.CONTENT_MODIFIED.callback.no = $.noop;
+ config.CONTENT_MODIFIED.data = {
+ content: content,
+ numbers: numbers
+ };
+ return false;
+ }
+ if (hasContent && noContactSelected) {
+ config.CONTENT_MODIFIED.modified = true;
+ config.CONTENT_MODIFIED.message = 'sms_no_recipient';
+ config.CONTENT_MODIFIED.callback.ok = $.noop;
+ config.CONTENT_MODIFIED.callback.no = function () {
+ // 返回true,页面保持原状
+ return true;
+ };
+ return false;
+ }
+ }
+ /*else { cov_2
+ config.resetContentModifyValue();
+ }*/
+ }
+
+ function saveDraftAction(data) {
+ var datetime = new Date();
+ var params = {
+ index: -1,
+ currentTimeString: getCurrentTimeString(datetime),
+ groupId: data.numbers.length > 1 ? datetime.getTime() : '',
+ message: data.content,
+ numbers: data.numbers
+ };
+ service.saveSMS(params, function () {
+ successOverlay('sms_save_draft_success');
+ }, function () {
+ errorOverlay("sms_save_draft_failed")
+ });
+ }
+ function smsPageCheckDraft(clearCallback, isNeedInit) {
+ if (config.CONTENT_MODIFIED.message != 'sms_to_save_draft') {
+ if (config.CONTENT_MODIFIED.modified) {
+ showConfirm(config.CONTENT_MODIFIED.message, {
+ ok: function () {
+ config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
+ clearCallback(isNeedInit);
+ },
+ no: function () {
+ if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
+ clearCallback(isNeedInit);
+ }
+ return false;
+ }
+ });
+ return false;
+ } else {
+ clearCallback(isNeedInit);
+ }
+ } else {
+ config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
+ clearCallback(isNeedInit);
+ }
+ }
+
+ //重新获取页面数据并显示
+ function getPhoneBookReady() {
+ service.getPhoneBookReady({}, function (data) {
+ if (data.pbm_init_flag == "6") {
+ target.initFail(true);
+ hideLoading();
+ showAlert("phonebook_init_fail");
+ } else if (data.pbm_init_flag != "0") {
+ addTimeout(getPhoneBookReady, 1000);
+ } else {
+ target.initFail(false);
+ var capacity = getCapacity();
+ target.capacity(capacity);
+ target.phoneBookCapacity(capacity.Ratio);
+ var phoneBooks = getBooks(capacity.Used);
+ target.books(phoneBooks);
+ target.gridTemplate.data(phoneBooks);
+ $('#books').find('tbody').translate();
+ hideLoading();
+ }
+ });
+ }
+
+ showLoading('waiting');
+ addTimeout(getPhoneBookReady, 200);
+
+ //重新获取页面数据并显示
+ function refreshPage() {
+ showLoading();
+ var capacity = getCapacity();
+ target.phoneBookCapacity(capacity.Ratio);
+ target.capacity(capacity);
+ var books = getBooks(capacity.Used);
+ target.books(books);
+ target.gridTemplate.data(books);
+ hideLoading();
+ }
+
+ target.preContent = {};
+ //保存编辑前的内容
+ function setPreContent() {
+ target.preContent.location = target.selectedLocation();
+ target.preContent.name = target.name();
+ target.preContent.mobile_phone_number = target.mobile_phone_number();
+ target.preContent.home_phone_number = target.home_phone_number();
+ target.preContent.office_phone_number = target.office_phone_number();
+ target.preContent.mail = target.mail();
+ target.preContent.group = target.selectedGroup();
+ }
+
+ //检测数据是否改变
+ function checkContentChang() {
+ var changed = (target.preContent.location != target.selectedLocation()
+ || target.preContent.name != target.name()
+ || target.preContent.mobile_phone_number != target.mobile_phone_number()
+ || target.preContent.home_phone_number != target.home_phone_number()
+ || target.preContent.office_phone_number != target.office_phone_number()
+ || target.preContent.mail != target.mail()
+ || target.preContent.group != target.selectedGroup());
+ config.CONTENT_MODIFIED.modified = changed;
+ }
+
+ function preOpenEditPage() {
+ config.resetContentModifyValue();
+ setPreContent();
+ config.CONTENT_MODIFIED.checkChangMethod = checkContentChang;
+ }
+ }
+
+ //设置停止发送标志为true
+ phoneBookStopSMSSending = function () {
+ _phoneBookStopSMSSending = true;
+ $("#loading #loading_container").html($.i18n.prop("sms_cancel_sending"));
+ }
+
+ //获取电话本
+ function getBooks(capacity) {
+ var para = {};
+ para.page = 0;
+ para.data_per_page = capacity;
+ para.orderBy = "name";
+ para.isAsc = true;
+ var books = [];
+ var group = getCurrentGroup();
+ if (config.HAS_SMS) {
+ books = service.getPhoneBooks(para);
+ config.phonebook = books.pbm_data;
+ if (group != "all") {
+ books = {
+ "pbm_data": _.filter(books.pbm_data, function (item) {
+ return item.pbm_group == group;
+ })
+ };
+ }
+ } else {
+ if (group != "all") {
+ para.group = group;
+ books = service.getPhoneBooksByGroup(para);
+ } else {
+ books = service.getPhoneBooks(para);
+ }
+ }
+ return translateData(books.pbm_data);
+ }
+
+ //获取电话本容量信息
+ function getCapacity() {
+ var sim = service.getSIMPhoneBookCapacity();
+ var device = service.getDevicePhoneBookCapacity();
+ return {
+ simUsed: sim.simPbmUsedCapacity,
+ deviceUsed: device.pcPbmUsedCapacity,
+ simCapacity: sim.simPbmTotalCapacity,
+ deviceCapacity: device.pcPbmTotalCapacity,
+ simMaxNameLen: sim.maxNameLen,
+ simMaxNumberLen: sim.maxNumberLen,
+ IsSimCardFull: (sim.simPbmUsedCapacity == sim.simPbmTotalCapacity),
+ IsDeviceFull: (device.pcPbmUsedCapacity == device.pcPbmTotalCapacity),
+ Used: sim.simPbmUsedCapacity + device.pcPbmUsedCapacity,
+ Capacity: sim.simPbmTotalCapacity + device.pcPbmTotalCapacity,
+ Ratio: "(" + (sim.simPbmUsedCapacity + device.pcPbmUsedCapacity) + "/" + (sim.simPbmTotalCapacity + device.pcPbmTotalCapacity) + ")"
+ };
+ }
+
+ function translateData(books) {
+ var ret = [];
+ var group = getCurrentGroup();
+ var hasFilter = (group != "all");
+ if (books) {
+ for (var i = 0; i < books.length; i++) {
+ if (hasFilter) {
+ var currentGroup = books[i].pbm_group;
+ if (books[i].pbm_location == locationValue.SIM || currentGroup != group) {
+ continue;
+ }
+ }
+ var temp = {
+ index: books[i].pbm_id,
+ location: books[i].pbm_location,
+ imgLocation: books[i].pbm_location == locationValue.SIM ? "pic/simcard.png" : "pic/res_device.png",
+ name: books[i].pbm_name,
+ mobile_phone_number: books[i].pbm_number,
+ home_phone_number: books[i].pbm_anr,
+ office_phone_number: books[i].pbm_anr1,
+ mail: books[i].pbm_email,
+ group: books[i].pbm_group,
+ transGroup: (!books[i].pbm_group) ? "group_null" : "group_" + books[i].pbm_group
+ };
+ ret.push(temp);
+ }
+ }
+ return ret;
+ }
+ //初始化ViewModel并进行绑定
+ function init() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var vm = new pbViewMode();
+ ko.applyBindings(vm, container[0]);
+ $("#txtSmsContent").die().live("contextmenu", function () {
+ return false;
+ });
+ $('#frmPhoneBook').validate({
+ submitHandler: function () {
+ vm.save();
+ },
+ rules: {
+ txtMail: "email_check",
+ txtName: "name_check",
+ txtMobile: "phonenumber_check",
+ txtHomeNumber: "phonenumber_check",
+ txtOfficeNumber: "phonenumber_check"
+ }
+ });
+
+ }
+
+ return {
+ init: init
+ };
+});
+
+define("sms_list","underscore jquery knockout set service jq_chosen".split(" "),
+ function (_, $, ko, config, service, chosen) {
+
+ var currentPage = 1;
+ //数据是否加载完成
+ var ready = false,
+ //聊天室信息正在加载中
+ chatRoomInLoading = false;
+ //快速添加联系人模板
+ var addPhonebookTmpl = null,
+ //短消息模板
+ smsTableTmpl = null,
+ //接收短消息模板
+ smsOtherTmpl = null,
+ //发送短消息模板
+ smsMeTmpl = null,
+ //群聊草稿
+ groupDrafts = [],
+ //短消息列表显示群聊草稿
+ groupDraftItems = [],
+ //短消息列表显示群聊草稿及其草稿群聊细节
+ groupedDraftsObject = {},
+ //短消息容量信息
+ smsCapability = {},
+ //短消息是否还有存储空间
+ hasCapability = true;
+ //获取全部短消息,并将短信通过回调函数getPhoneBooks,与电话本进行关联
+ function getSMSMessages(callback) {
+ return service.getSMSMessages({
+ page: 0,
+ smsCount: 500,
+ nMessageStoreType: 1,
+ tags: 10,
+ orderBy: "order by id desc"
+ }, function (data) {
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), data.messages.length);
+ config.dbMsgs = data.messages;
+ config.listMsgs = groupSms(config.dbMsgs);
+ callback();
+ }, function () {
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 0);
+ config.dbMsgs = [];
+ config.listMsgs = [];
+ cleanSmsList();
+ });
+ }
+
+ //清楚短消息列表内容
+ cleanSmsList = function () {
+ $("#smslist-table").empty();
+ };
+
+ //关联后的短消息根据电话号码进行分组
+ function groupSms(messages) {
+ var peoples = {},
+ theSortedPeoples = [];
+ config.listMsgs = [];
+ groupDrafts = [];
+ $.each(messages, function (i, e) {
+ if (e.tag == '4' && e.groupId != '') { // 群聊草稿
+ groupDrafts.push(e);
+ return;
+ }
+ e.target = e.number;
+ if (parseInt(e.id, 10) > config.smsMaxId) {
+ config.smsMaxId = e.id;
+ }
+ var last8 = getLastNumber(e.number, config.SMS_MATCH_LENGTH);
+ if (last8 in peoples) {
+ peoples[last8].push(e);
+ } else {
+ peoples[last8] = [e];
+ theSortedPeoples.push(e);
+ }
+ });
+ theSortedPeoples = _.sortBy(theSortedPeoples, function (ele) {
+ return 0 - parseInt(ele.id + "", 10);
+ });
+ $.each(theSortedPeoples, function (s_i, sp) {
+ var people = getLastNumber(sp.number, config.SMS_MATCH_LENGTH);
+ var newCount = 0;
+ var hasDraft = false;
+ for (var i = 0; i < peoples[people].length; i++) {
+ if (peoples[people][i].isNew) {
+ newCount++;
+ }
+ if (peoples[people][i].tag == '4' && peoples[people][i].groupId == '') { // 单条草稿
+ hasDraft = true;
+ }
+ }
+ config.listMsgs.push({
+ id: peoples[people][0].id,
+ name: "",
+ number: peoples[people][0].number,
+ latestId: peoples[people][0].id,
+ totalCount: peoples[people].length,
+ newCount: newCount,
+ latestSms: peoples[people][0].content,
+ latestTime: peoples[people][0].time,
+ checked: false,
+ itemId: getLastNumber(people, config.SMS_MATCH_LENGTH),
+ groupId: peoples[people][0].groupId,
+ hasDraft: hasDraft
+ });
+ });
+ return config.listMsgs;
+ }
+
+ //获取电话本信息,并与短消息关联
+ function getPhoneBooks() {
+ var books = service.getPhoneBooks({
+ page: 0,
+ data_per_page: 2000,
+ orderBy: "name",
+ isAsc: true
+ });
+ if ($.isArray(books.pbm_data) && books.pbm_data.length > 0) {
+ config.phonebook = books.pbm_data;
+ }
+ dealPhoneBooks();
+ }
+
+ //双异步获取设备侧和sim卡侧的短信息,并将其合并
+ function dealPhoneBooks() {
+ var select = $("#chosenUserList .chosen-select-deselect");
+ select.empty();
+ var options = [];
+ var tmp = [];
+ var pbTmp = [];
+ for (var j = 0; j < config.phonebook.length; j++) {
+ var book = config.phonebook[j];
+ var last8Num = getLastNumber(book.pbm_number, config.SMS_MATCH_LENGTH);
+ if (last8Num && $.inArray(last8Num, pbTmp) == -1) {
+ options.push(new Option(book.pbm_name + "/" + book.pbm_number, last8Num, false, true));
+ if ($.inArray(last8Num, tmp) == -1) {
+ tmp.push(last8Num);
+ }
+ pbTmp.push(last8Num);
+ } else {
+ for (var i = 0; i < options.length; i++) {
+ if (options[i].value == last8Num) {
+ options[i].text = book.pbm_name + "/" + book.pbm_number;
+ break;
+ }
+ }
+ }
+ }
+ var groupIds = [];
+ for (var k = 0; k < groupDrafts.length; k++) { // 将草稿做对象Map封装,供草稿组点击后的草稿分解
+ if ($.inArray(groupDrafts[k].groupId, groupIds) == -1) {
+ groupIds.push(groupDrafts[k].groupId);
+ var draft = groupDrafts[k];
+ groupedDraftsObject[groupDrafts[k].groupId] = [draft];
+ } else {
+ var draft = groupDrafts[k];
+ groupedDraftsObject[groupDrafts[k].groupId].push(draft);
+ }
+ var itemId = getLastNumber(groupDrafts[k].number, config.SMS_MATCH_LENGTH);
+ if ($.inArray(itemId, tmp) == -1) {
+ options.push(new Option(groupDrafts[k].number, itemId));
+ tmp.push(itemId);
+ }
+ }
+ for (var g in groupedDraftsObject) { // 处理列表显示的草稿信息
+ var drafts = groupedDraftsObject[g];
+ var draftItem = drafts[drafts.length - 1];
+ draftItem.draftShowName = '';
+ draftItem.draftShowNameTitle = '';
+ $.each(drafts, function (i, n) {
+ var showName = getShowNameByNumber(n.number);
+ draftItem.draftShowName += (i == 0 ? '' : ';') + showName;
+ draftItem.draftShowNameTitle += (i == 0 ? '' : ';') + showName;
+ });
+
+ var len = 10;
+ if (getEncodeType(draftItem.draftShowName).encodeType == "UNICODE") {
+ len = 10;
+ }
+ draftItem.draftShowName = draftItem.draftShowName.length > len ? draftItem.draftShowName.substring(0, len) + "..." : draftItem.draftShowName;
+ draftItem.totalCount = drafts.length;
+ draftItem.hasDraft = true;
+ draftItem.latestTime = draftItem.time;
+ groupDraftItems.push(draftItem);
+ }
+ for (var i = 0; i < config.listMsgs.length; i++) {
+ var smsItem = config.listMsgs[i];
+ for (var j = config.phonebook.length; j > 0; j--) {
+ var book = config.phonebook[j - 1];
+ var last8Num = getLastNumber(book.pbm_number, config.SMS_MATCH_LENGTH);
+ if (smsItem.itemId == last8Num) {
+ smsItem.name = book.pbm_name;
+ for (var k = 0; k < options.length; k++) {
+ if (last8Num == options[k].value) {
+ options[k].value = getLastNumber(smsItem.number, config.SMS_MATCH_LENGTH);
+ options[k].text = book.pbm_name + '/' + smsItem.number;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ if ($.inArray(smsItem.itemId, tmp) == -1) {
+ options.push(new Option(smsItem.number, getLastNumber(smsItem.number, config.SMS_MATCH_LENGTH)));
+ tmp.push(smsItem.itemId);
+ }
+ }
+
+ var opts = "";
+ $.each(options, function (i, e) {
+ opts += "<option value='" + HTMLEncode(e.value) + "'>" + HTMLEncode(e.text) + "</option>";
+ });
+ select.append(opts);
+ select.chosen({
+ max_selected_options: 5,
+ search_contains: true,
+ width: '740px'
+ });
+ showSmsListData();
+ showMultiDraftListData();
+ //changeShownMsgs();
+ ready = true;
+ }
+
+ function showSmsListData() {
+ if (smsTableTmpl == null) {
+ smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));
+ }
+ cleanSmsList();
+ $.tmpl("smsTableTmpl", {
+ data: config.listMsgs
+ }).translate().appendTo("#smslist-table");
+
+ if (config.HAS_PHONEBOOK) {
+ $(".sms-add-contact-icon").removeClass("hide");
+ } else {
+ $(".sms-add-contact-icon").addClass("hide");
+ }
+ }
+ //群组草稿列表显示
+ function showMultiDraftListData() {
+ if (groupDraftItems.length == 0) {
+ return false;
+ }
+ if (smsTableTmpl == null) {
+ smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));
+ }
+ $.tmpl("smsTableTmpl", {
+ data: groupDraftItems
+ }).translate().prependTo("#smslist-table");
+ }
+
+ // 页面发生滚动后,改变页面显示的短消息
+ function changeShownMsgs() {
+ var shownMsgsTmp = [];
+ var range = _.range((currentPage - 1) * 5, currentPage * 5);
+ $.each(range, function (i, e) {
+ if (config.listMsgs[e]) {
+ shownMsgsTmp.push(config.listMsgs[e]);
+ }
+ });
+ //shownMsgsTmp = config.listMsgs;
+ currentPage++;
+
+ if (smsTableTmpl == null) {
+ smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));
+ }
+ $.tmpl("smsTableTmpl", {
+ data: shownMsgsTmp
+ }).translate().appendTo("#smslist-table");
+
+ renderCheckbox();
+ if (shownMsgsTmp.length == 0) {
+ disableBtn($("#smslist-delete-all"));
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 0);
+ } else {
+ enableBtn($("#smslist-delete-all"));
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 1);
+ }
+ if (currentPage == 2 && window.innerHeight == $("body").height()) {
+ changeShownMsgs();
+ }
+ return shownMsgsTmp;
+ }
+
+ //将被checked的条目添加到self.checkedItem中,用于在滚动还原checkbox
+ checkboxClickHandler = function (id) {
+ checkDeleteBtnStatus();
+ };
+
+ //获取已选择的条目
+ getSelectedItem = function () {
+ var selected = [];
+ var checkedItem = $("#smslist-table input:checkbox:checked");
+ checkedItem.each(function (i, e) {
+ selected.push($(e).val());
+ });
+ return selected;
+ };
+
+ //删除按钮是否禁用
+ checkDeleteBtnStatus = function () {
+ var size = getSelectedItem().length;
+ if (size == 0) {
+ disableBtn($("#smslist-delete"));
+ } else {
+ enableBtn($("#smslist-delete"));
+ }
+ };
+
+ //刷新短消息列表
+ refreshClickHandler = function () {
+ $("#smslist-table").empty();
+ disableBtn($("#smslist-delete"));
+ disableCheckbox($("#smslist-checkAll", "#smsListForm"));
+ init();
+ renderCheckbox();
+ };
+
+ //删除全部短消息
+ deleteAllClickHandler = function () {
+ showConfirm("confirm_data_delete", function () {
+ showLoading('deleting');
+ service.deleteAllMessages({
+ location: "native_inbox"
+ }, function (data) {
+ cleanSmsList();
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), 0);
+ successOverlay();
+ }, function (error) {
+ errorOverlay(error.errorText);
+ });
+ });
+ };
+
+ //删除选中的短消息
+ deleteSelectClickHandler = function () {
+ showConfirm("confirm_sms_delete", function () {
+ showLoading('deleting');
+ var items = getIdsBySelectedIds();
+ service.deleteMessage({
+ ids: items.ids
+ }, function (data) {
+ renderAfterDelete(items);
+ disableBtn($("#smslist-delete"));
+ $("#checkbox-all").removeAttr("checked");
+ renderCheckbox();
+ successOverlay();
+ }, function (error) {
+ errorOverlay(error.errorText);
+ });
+ });
+
+ function renderAfterDelete(items) {
+ var ids = items.ids;
+ var nums = [];
+ $.each(config.dbMsgs, function (i, e) {
+ if ($.inArray(e.id, items.normalIds) != -1) {
+ nums.push(e.number);
+ }
+ });
+ nums = _.uniq(nums);
+ $.each(nums, function (i, e) {
+ $("#smslist-item-" + getLastNumber(e, config.SMS_MATCH_LENGTH)).hide().remove();
+ });
+ $.each(items.groups, function (i, e) {
+ $("#smslist-item-" + e).hide().remove();
+ });
+ synchSmsList(nums, ids);
+ }
+
+ function getIdsBySelectedIds() {
+ var nums = [];
+ var resultIds = [];
+ var normalIds = [];
+ var groups = [];
+ var selectedItem = getSelectedItem();
+ $.each(selectedItem, function (i, e) {
+ var checkbox = $("#checkbox" + e);
+ if (checkbox.attr("groupid")) {
+ groups.push(checkbox.attr("groupid"));
+ } else {
+ nums.push(getLastNumber(checkbox.attr("number"), config.SMS_MATCH_LENGTH));
+ }
+ });
+
+ $.each(config.dbMsgs, function (i, e) {
+ if ($.inArray(getLastNumber(e.number, config.SMS_MATCH_LENGTH), nums) != -1 && (typeof e.groupId == "undefined" || _.isEmpty(e.groupId + ''))) {
+ resultIds.push(e.id);
+ normalIds.push(e.id);
+ } else if ($.inArray(e.groupId + '', groups) != -1) { //删除草稿组
+ resultIds.push(e.id);
+ }
+ });
+ resultIds = _.uniq(resultIds);
+ return {
+ ids: resultIds,
+ groups: groups,
+ normalIds: normalIds
+ };
+ }
+ };
+
+ //新短信按钮点击
+ newMessageClickHandler = function () {
+ $("#chosenUser1", "#smsChatRoom").addClass("hide");
+ $("#chosenUser", "#smsChatRoom").show();
+
+ cleanChatInput();
+ checkSmsCapacityAndAlert();
+ $("select.chosen-select-deselect").val("").trigger("chosen:updated.chosen");
+ switchPage('chat');
+ gotoBottom();
+ clearChatList();
+ };
+
+ //返回聊天室列表
+ chatCancelClickHandler = function () {
+ if (config.CONTENT_MODIFIED.modified) {
+ var confirmMessage = 'sms_to_save_draft';
+ var selectedContact = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));
+ var noContactSelected = !selectedContact || selectedContact.length == 0;
+ if (noContactSelected) {
+ confirmMessage = 'sms_no_recipient';
+ }
+ if (noContactSelected) {
+ showConfirm(confirmMessage, {
+ ok: function () {
+ if (!noContactSelected) {
+ saveDraftAction({
+ content: $("#chat-input", "#smsChatRoom").val(),
+ numbers: selectedContact,
+ isFromBack: true
+ });
+ }
+ config.resetContentModifyValue();
+ backToSmsListMainPage();
+ },
+ no: function () {
+ if (noContactSelected) {
+ return true;
+ }
+ config.resetContentModifyValue();
+ backToSmsListMainPage();
+ }
+ });
+ } else {
+ saveDraftAction({
+ content: $("#chat-input", "#smsChatRoom").val(),
+ numbers: selectedContact,
+ isFromBack: true
+ });
+ config.resetContentModifyValue();
+ backToSmsListMainPage();
+ }
+ return false;
+ }
+ backToSmsListMainPage();
+ };
+
+ //跳转页面至SIM卡侧、设置界面
+ toOtherClickHandler = function (href) {
+ config.CONTENT_MODIFIED.checkChangMethod();
+ if (config.CONTENT_MODIFIED.modified) {
+ draftListener();
+ if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
+ config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
+ config.resetContentModifyValue();
+ window.location.hash = href;
+ } else {
+ showConfirm(config.CONTENT_MODIFIED.message, {
+ ok: function () {
+ config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
+ config.resetContentModifyValue();
+ window.location.hash = href;
+ },
+ no: function () {
+ var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);
+ if (!result) {
+ window.location.hash = href;
+ config.resetContentModifyValue();
+ }
+ }
+ });
+ }
+ return false;
+ } else {
+ window.location.hash = href;
+ }
+ };
+
+ function backToSmsListMainPage() {
+ $("select.chosen-select-deselect").val("").trigger("chosen:updated.chosen");
+ config.currentChatObject = null;
+ $(".smslist-btns", "#smslist-main").removeClass('smsListFloatButs');
+ switchPage('list');
+ }
+
+ function switchPage(page) {
+ if (page == 'chat') {
+ $("#smslist-main").hide();
+ $("#smsChatRoom").show();
+ } else {
+ $("#smsChatRoom").hide();
+ $("#smslist-main").show();
+ }
+ }
+
+ var sendSmsErrorTimer = null;
+ //添加发送错误消息
+ addSendSmsError = function (msg) {
+ if (sendSmsErrorTimer) {
+ window.clearTimeout(sendSmsErrorTimer);
+ sendSmsErrorTimer = null;
+ }
+ $("#sendSmsErrorLi").text($.i18n.prop(msg));
+ sendSmsErrorTimer = addTimeout(function () {
+ $("#sendSmsErrorLi").text("");
+ }, 5000);
+ };
+
+ //发送短消息
+ sendSmsClickHandler = function () {
+ if (!hasCapability) {
+ showAlert("sms_capacity_is_full_for_send");
+ return;
+ }
+ var inputVal = $("#chat-input", "#smsChatRoom");
+ var msgContent = inputVal.val();
+ if (msgContent == $.i18n.prop("chat_input_placehoder")) {
+ inputVal.val("");
+ msgContent = "";
+ }
+ var nums = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));
+ if ($.isArray(nums)) {
+ nums = $.grep(nums, function (n, i) {
+ return !_.isEmpty(n);
+ });
+ }
+ if (!nums || nums.length == 0) {
+ addSendSmsError("sms_contact_required");
+ return;
+ }
+ if (nums.length + smsCapability.nvUsed > smsCapability.nvTotal) {
+ showAlert({
+ msg: "sms_capacity_will_full_just",
+ params: [smsCapability.nvTotal - smsCapability.nvUsed]
+ });
+ return;
+ }
+ if (nums.length == 1) {
+ config.currentChatObject = getLastNumber(nums[0], config.SMS_MATCH_LENGTH);
+ showLoading('sending');
+ } else if (nums.length > 1) {
+ showLoading("sending", "<button id='sms_cancel_sending' onclick='cancelSending()' class='btn btn-primary'>"
+ + $.i18n.prop("sms_stop_sending")
+ + "</button>");
+ config.currentChatObject = null;
+ }
+ var i = 0;
+ var leftNum = nums.length;
+ couldSend = true;
+ disableBtn($("#btn-send", "#inputpanel"));
+ sendSms = function () {
+ if (!couldSend) {
+ hideLoading();
+ return;
+ }
+ var newMsg = {
+ id: -1,
+ number: nums[i],
+ content: msgContent,
+ isNew: false
+ };
+
+ if (leftNum == 1) {
+ $("#loading #loading_container").html("");
+ }
+
+ leftNum--;
+ service.sendSMS({
+ number: newMsg.number,
+ message: newMsg.content,
+ id: -1
+ }, function (data) {
+ var latestMsg = getLatestMessage() || {
+ id: parseInt(config.smsMaxId, 10) + 1,
+ time: transUnixTime($.now()),
+ number: newMsg.number
+ };
+ config.smsMaxId = latestMsg.id;
+ newMsg.id = config.smsMaxId;
+ newMsg.time = latestMsg.time;
+ newMsg.tag = 2;
+ newMsg.hasDraft = false;
+ if (nums.length > 1) {
+ newMsg.targetName = getNameOrNumberByNumber(newMsg.number);
+ }
+ addSendMessage(newMsg, i + 1 != nums.length);
+ updateDBMsg(newMsg);
+ updateMsgList(newMsg);
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);
+ gotoBottom();
+ if (i + 1 == nums.length) {
+ updateChatInputWordLength();
+ enableBtn($("#btn-send", "#inputpanel"));
+ hideLoading();
+ return;
+ }
+ i++;
+ sendSms();
+ }, function (error) {
+ var latestMsg = getLatestMessage() || {
+ id: parseInt(config.smsMaxId, 10) + 1,
+ time: transUnixTime($.now()),
+ number: newMsg.number
+ };
+ config.smsMaxId = latestMsg.id;
+ newMsg.id = config.smsMaxId;
+ newMsg.time = latestMsg.time;
+ newMsg.errorText = $.i18n.prop(error.errorText);
+ newMsg.tag = 3;
+ newMsg.target = newMsg.number;
+ newMsg.hasDraft = false;
+ if (nums.length > 1) {
+ newMsg.targetName = getNameOrNumberByNumber(newMsg.number);
+ }
+ addSendMessage(newMsg, i + 1 != nums.length);
+ updateDBMsg(newMsg);
+ updateMsgList(newMsg);
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);
+ gotoBottom();
+ if (i + 1 == nums.length) {
+ updateChatInputWordLength();
+ enableBtn($("#btn-send", "#inputpanel"));
+ hideLoading();
+ return;
+ }
+ i++;
+ sendSms();
+ });
+ };
+ sendSms();
+ };
+
+ var couldSend = true;
+
+ //取消剩余短信发送操作
+ cancelSending = function () {
+ couldSend = false;
+ $("#loading #loading_container").html($.i18n.prop('sms_cancel_sending'));
+ };
+
+ //获取最新的短消息
+ getLatestMessage = function () {
+ var data = service.getSMSMessages({
+ page: 0,
+ smsCount: 5,
+ nMessageStoreType: 1,
+ tags: 10,
+ orderBy: "order by id desc"
+ });
+ if (data.messages.length > 0) {
+ for (var i = 0; i < data.messages.length; i++) {
+ if (data.messages[i].tag == '2' || data.messages[i].tag == '3') {
+ return data.messages[i];
+ }
+ }
+ return null;
+ } else {
+ return null;
+ }
+ };
+
+ //发送短信后,更新短信数据对象
+ function updateDBMsg(msg) {
+ if (config.dbMsgs.length == 0) {
+ config.dbMsgs = [msg];
+ } else {
+ /* cov_2
+ for(var j = 0; j < config.dbMsgs.length; j++){
+ if(config.dbMsgs[j].id == msg.id){
+ config.dbMsgs[j] = msg;
+ return;
+ } else {
+ var newMsg = [msg];
+ $.merge(newMsg, config.dbMsgs);
+ config.dbMsgs = newMsg;
+ return;
+ }
+ }
+ */
+ if (config.dbMsgs[0].id == msg.id) {
+ config.dbMsgs[0] = msg;
+ return;
+ } else {
+ var newMsg = [msg];
+ $.merge(newMsg, config.dbMsgs);
+ config.dbMsgs = newMsg;
+ return;
+ }
+ }
+ }
+
+ //发送短信后,更新短信列表, number不为空做删除处理,为空做增加处理
+ function updateMsgList(msg, number, counter) {
+ if ((!msg || !msg.number) && !number) {
+ return;
+ }
+ var itemId = '';
+ if (msg && typeof msg.groupId != "undefined" && msg.groupId != '') {
+ itemId = msg.groupId;
+ } else {
+ itemId = getLastNumber((number || msg.number), config.SMS_MATCH_LENGTH);
+ }
+ var item = $("#smslist-item-" + itemId);
+ if (item && item.length > 0) {
+ var totalCountItem = item.find(".smslist-item-total-count");
+ var count = totalCountItem.text();
+ count = Number(count.substring(1, count.length - 1));
+ if (number) {
+ if (count == 1 || msg == null) {
+ item.hide().remove();
+ return;
+ } else {
+ totalCountItem.text("(" + (count - (counter || 1)) + ")");
+ item.find(".smslist-item-draft-flag").addClass('hide');
+ }
+ } else {
+ totalCountItem.text("(" + (count + 1) + ")");
+ if (msg.tag == '4') {
+ item.find(".smslist-item-draft-flag").removeClass('hide');
+ }
+ }
+ item.find(".smslist-item-checkbox p.checkbox").attr("id", msg.id);
+ item.find(".smslist-item-checkbox input:checkbox").val(msg.id).attr("id", "checkbox" + msg.id);
+ var contentHtml = msg.content;
+ var msgContent;
+ if (msg.tag == '4') {
+ //contentHtml = '<span class="smslist-item-draft-flag colorRed" data-trans="draft"></span>: ' + contentHtml;
+ msgContent = item.find(".smslist-item-msg").html('<span class="smslist-item-draft-flag colorRed" data-trans="draft"></span>: ' + HTMLEncode(contentHtml)); //.addClass("font-weight-bold");
+ } else {
+ msgContent = item.find(".smslist-item-msg").html(HTMLEncode(contentHtml)); //.addClass("font-weight-bold");
+ }
+ //var msgContent = item.find(".smslist-item-msg").html(HTMLEncode(contentHtml)); //.addClass("font-weight-bold");
+ msgContent.closest('td').prop('title', msg.content);
+ item.find(".smslist-item-repeat span").die().click(function () {
+ forwardClickHandler(msg.id);
+ });
+ item.find("span.clock-time").text(msg.time);
+ var tmpItem = item;
+ item.hide().remove();
+ $("#smslist-table").prepend(tmpItem.show());
+ } else {
+ if (smsTableTmpl == null) {
+ smsTableTmpl = $.template("smsTableTmpl", $("#smsTableTmpl"));
+ }
+ msg.checked = false;
+ msg.newCount = 0;
+ msg.latestId = msg.id;
+ msg.latestSms = msg.content;
+ msg.latestTime = msg.time;
+ if (msg.groupId == '' || typeof msg.groupId == "undefined") {
+ msg.totalCount = 1;
+ }
+ if (!msg.hasDraft) {
+ msg.hasDraft = false;
+ }
+ msg.itemId = itemId;
+ msg.name = getNameByNumber(msg.number);
+ $.tmpl("smsTableTmpl", {
+ data: [msg]
+ }).translate().prependTo("#smslist-table");
+ }
+ if (config.HAS_PHONEBOOK) {
+ $(".sms-add-contact-icon").removeClass("hide");
+ } else {
+ $(".sms-add-contact-icon").addClass("hide");
+ }
+ $("#smslist-table").translate();
+ renderCheckbox();
+ }
+
+ //增加发送内容到聊天室, notCleanChatInput 是否清除输入框内容
+ addSendMessage = function (sms, notCleanChatInput) {
+ if (smsMeTmpl == null) {
+ smsMeTmpl = $.template("smsMeTmpl", $("#smsMeTmpl"));
+ }
+ $.tmpl("smsMeTmpl", sms).appendTo("#chatlist");
+ $("#chatlist").translate();
+ if (!notCleanChatInput) {
+ cleanChatInput();
+ }
+ clearMySmsErrorMessage(sms.id);
+ };
+
+ //清楚错误消息,避免翻译问题
+ clearMySmsErrorMessage = function (id) {
+ addTimeout(function () {
+ $("div.error", "#talk-item-" + id).text("");
+ }, 3000);
+ };
+
+ //快速添加联系人overlay是否打开
+ var isPoped = false;
+
+ //关闭快速添加联系人overlay
+ hidePopup = function () {
+ $(".tagPopup").remove();
+ isPoped = false;
+ };
+
+ //清空聊天室内容
+ clearChatList = function () {
+ $("#chatlist").empty();
+ updateChatInputWordLength();
+ };
+
+ //过滤短消息内容
+ dealContent = function (content) {
+ if (config.HAS_PHONEBOOK) {
+ return HTMLEncode(content).replace(/(\d{3,})/g, function (word) {
+ var r = (new Date().getTime() + '').substring(6) + (getRandomInt(1000) + 1000);
+ return "<a id='aNumber" + r + "' href='javascript:openPhoneBook(\"" + r + "\", \"" + word + "\")'>" + word + "</a>";
+ });
+ } else {
+ return HTMLEncode(content);
+ }
+
+ };
+
+ //打开快速添加联系人overlay
+ openPhoneBook = function (id, num) {
+ var target = null;
+ var outContainer = "";
+ var itemsContainer = null;
+ var isChatRoom = false;
+ if (!id) {
+ target = $("#listNumber" + getLastNumber(num, config.SMS_MATCH_LENGTH));
+ outContainer = ".smslist-item";
+ itemsContainer = $("#addPhonebookContainer");
+ } else {
+ target = $("#aNumber" + id);
+ outContainer = ".msg_container";
+ itemsContainer = $("#chatlist");
+ isChatRoom = true;
+ }
+ if (isPoped) {
+ hidePopup();
+ }
+ isPoped = true;
+ $("#tagPopup").remove();
+
+ if (addPhonebookTmpl == null) {
+ addPhonebookTmpl = $.template("addPhonebookTmpl", $("#addPhonebookTmpl"));
+ }
+ $.tmpl("addPhonebookTmpl", {
+ number: num
+ }).appendTo(itemsContainer);
+ var p = target.position();
+ var msgContainer = target.closest(outContainer);
+ var msgP = msgContainer.position();
+ var _left = 0,
+ _top = 0;
+ if (isChatRoom) {
+ var containerWidth = itemsContainer.width();
+ var containerHeight = itemsContainer.height();
+ var pop = $("#innerTagPopup");
+ _left = msgP.left + p.left;
+ _top = msgP.top + p.top + 20;
+ if (pop.width() + _left > containerWidth) {
+ _left = containerWidth - pop.width() - 20;
+ }
+ if (containerHeight > 100 && pop.height() + _top > containerHeight) {
+ _top = containerHeight - pop.height() - 5;
+ }
+ } else {
+ _left = p.left;
+ _top = p.top;
+ }
+ $("#innerTagPopup").css({
+ top: _top + "px",
+ left: _left + "px"
+ });
+ $('#quickSaveContactForm').translate().validate({
+ submitHandler: function () {
+ quickSaveContact(isChatRoom);
+ },
+ rules: {
+ name: "name_check",
+ number: "phonenumber_check"
+ }
+ });
+ };
+
+ //快速添加联系人
+ quickSaveContact = function () {
+ var name = $(".tagPopup #innerTagPopup #name").val();
+ var number = $(".tagPopup #innerTagPopup #number").val();
+ var newContact = {
+ index: -1,
+ location: 1,
+ name: name,
+ mobile_phone_number: number,
+ home_phone_number: "",
+ office_phone_number: "",
+ mail: ""
+ };
+ var device = service.getDevicePhoneBookCapacity();
+ if (device.pcPbmUsedCapacity >= device.pcPbmTotalCapacity) {
+ showAlert("device_full");
+ return false;
+ }
+ showLoading('waiting');
+ service.savePhoneBook(newContact, function (data) {
+ if (data.result == "success") {
+ config.phonebook.push({
+ pbm_name: name,
+ pbm_number: number
+ });
+ updateItemShowName(name, number);
+ hidePopup();
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }, function (data) {
+ errorOverlay();
+ });
+ };
+
+ function updateItemShowName(name, number) {
+ var lastNum = getLastNumber(number, config.SMS_MATCH_LENGTH);
+ $("span.smslist-item-name2", "#smslist-item-" + lastNum).text(name);
+ $("#listNumber" + lastNum).hide();
+ }
+
+ //聊天室删除单条消息
+ deleteSingleItemClickHandler = function (id, resendCallback) {
+ if (resendCallback) {
+ deleteTheSingleItem(id);
+ } else {
+ showConfirm("confirm_sms_delete", function () {
+ showLoading('deleting');
+ deleteTheSingleItem(id);
+ });
+ }
+
+ function deleteTheSingleItem(id) {
+ service.deleteMessage({
+ ids: [id]
+ }, function (data) {
+ var target = $(".smslist-item-delete", "#talk-item-" + id).attr("target");
+ $("#talk-item-" + id).hide().remove();
+
+ synchSmsList(null, [id]);
+ updateMsgList(getPeopleLatestMsg(target), target);
+ if (resendCallback) {
+ resendCallback();
+ } else {
+ hideLoading();
+ }
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);
+ }, function (error) {
+ if (resendCallback) {
+ resendCallback();
+ } else {
+ hideLoading();
+ }
+ });
+ }
+ };
+
+ //删除草稿
+ function deleteDraftSms(ids, numbers) {
+ stopNavigation();
+ service.deleteMessage({
+ ids: ids
+ }, function (data) {
+ updateSmsCapabilityStatus(null, function () {
+ draftListener();
+ restoreNavigation();
+ });
+ for (var i = 0; i < numbers.length; i++) {
+ updateMsgList(getPeopleLatestMsg(numbers[i]), numbers[i], ids.length);
+ }
+ synchSmsList(null, ids);
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);
+ }, function (error) {
+ restoreNavigation();
+ // Do nothing
+ });
+ }
+
+ //删除群聊草稿草稿
+ function deleteMultiDraftSms(ids, groupId) {
+ service.deleteMessage({
+ ids: ids
+ }, function (data) {
+ synchSmsList(null, ids);
+ $("#smslist-item-" + groupId).hide().remove();
+ checkSmsCapacityAndAlert();
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);
+ }, function (error) {
+ // Do nothing
+ });
+ }
+
+ getCurrentChatObject = function () {
+ var nums = $("select.chosen-select-deselect").val();
+ if (!nums) {
+ config.currentChatObject = null;
+ } else if (nums.length == 1) {
+ config.currentChatObject = getLastNumber(nums, config.SMS_MATCH_LENGTH);
+ } else if (nums.length > 1) {
+ config.currentChatObject = null;
+ }
+ return config.currentChatObject;
+ };
+
+ //获取当前聊天对象最新的短消息
+ getPeopleLatestMsg = function (number) {
+ for (var j = 0; j < config.dbMsgs.length; j++) {
+ if (!config.dbMsgs[j].groupId && getLastNumber(config.dbMsgs[j].number, config.SMS_MATCH_LENGTH) == getLastNumber(number, config.SMS_MATCH_LENGTH)) {
+ return config.dbMsgs[j];
+ }
+ }
+ return null;
+ };
+
+ //重新发送,复制消息到发送框
+ resendClickHandler = function (id) {
+ if (!hasCapability) {
+ showAlert("sms_capacity_is_full_for_send");
+ return;
+ }
+ showLoading('sending');
+ $("div.error", "#talk-item-" + id).text($.i18n.prop("sms_resending"));
+ var targetNumber = $("div.smslist-item-resend", "#talk-item-" + id).attr("target");
+ var content = $("div.J_content", "#talk-item-" + id).text();
+ for (var j = 0; j < config.dbMsgs.length; j++) {
+ if (config.dbMsgs[j].id == id) {
+ content = config.dbMsgs[j].content;
+ }
+ }
+
+ disableBtn($("#btn-send", "#inputpanel"));
+ var newMsg = {
+ id: -1,
+ number: targetNumber,
+ content: content,
+ isNew: false
+ };
+ service.sendSMS({
+ number: newMsg.number,
+ message: newMsg.content,
+ id: -1
+ }, function (data) {
+ var latestMsg = getLatestMessage() || {
+ id: parseInt(config.smsMaxId, 10) + 1,
+ time: transUnixTime($.now()),
+ number: newMsg.number
+ };
+ config.smsMaxId = latestMsg.id;
+ newMsg.id = config.smsMaxId;
+ newMsg.time = latestMsg.time;
+ newMsg.tag = 2;
+ newMsg.target = latestMsg.number;
+ newMsg.targetName = getNameOrNumberByNumber(targetNumber);
+ updateDBMsg(newMsg);
+ updateMsgList(newMsg);
+ deleteSingleItemClickHandler(id, function () {
+ addSendMessage(newMsg, true);
+ updateChatInputWordLength();
+ enableBtn($("#btn-send", "#inputpanel"));
+ hideLoading();
+ gotoBottom();
+ });
+ }, function (error) {
+ var latestMsg = getLatestMessage() || {
+ id: parseInt(config.smsMaxId, 10) + 1,
+ time: transUnixTime($.now()),
+ number: newMsg.number
+ };
+ config.smsMaxId = latestMsg.id;
+ newMsg.id = config.smsMaxId;
+ newMsg.time = latestMsg.time;
+ newMsg.errorText = $.i18n.prop("sms_resend_fail");
+ newMsg.tag = 3;
+ newMsg.target = latestMsg.number;
+ newMsg.targetName = getNameOrNumberByNumber(targetNumber);
+ updateDBMsg(newMsg);
+ updateMsgList(newMsg);
+ deleteSingleItemClickHandler(id, function () {
+ addSendMessage(newMsg, true);
+ updateChatInputWordLength();
+ enableBtn($("#btn-send", "#inputpanel"));
+ hideLoading();
+ gotoBottom();
+ });
+ });
+ };
+
+ //滚动到底部
+ gotoBottom = function () {
+ $("#chatpanel .clear-container").animate({
+ scrollTop: $("#chatlist").height()
+ });
+ };
+
+ //最后一条短消息距离顶部的距离
+ var lastItemOffsetTop = 0;
+ //页面是否处于滚动中
+ var scrolling = false;
+ //初始化页面状态信息
+ function initStatus() {
+ currentPage = 1;
+ ready = false;
+ shownMsgs = [];
+ scrolling = false;
+ lastItemOffsetTop = 0;
+ groupDrafts = groupDraftItems = [];
+ groupedDraftsObject = {};
+ config.dbMsgs = [];
+ config.listMsgs = null;
+ config.smsMaxId = 0;
+ config.phonebook = [];
+ }
+
+ function getReadyStatus() {
+ showLoading('waiting');
+ config.currentChatObject = null;
+ var getSMSReady = function () {
+ service.getSMSReady({}, function (data) {
+ if (data.sms_cmd_status_result == "2") {
+ $("input:button", "#smsListForm .smslist-btns").attr("disabled", "disabled");
+ hideLoading();
+ showAlert("sms_init_fail");
+ } else if (data.sms_cmd_status_result == "1") {
+ addTimeout(getSMSReady, 1000);
+ } else {
+ if (config.HAS_PHONEBOOK) {
+ getPhoneBookReady();
+ } else {
+ initSMSList(false);
+ }
+ }
+ });
+ };
+
+ var getPhoneBookReady = function () {
+ service.getPhoneBookReady({}, function (data) {
+ if (data.pbm_init_flag == "6") {
+ initSMSList(false);
+ } else if (data.pbm_init_flag != "0") {
+ addTimeout(getPhoneBookReady, 1000);
+ } else {
+ initSMSList(true);
+ }
+ });
+ };
+
+ var initSMSList = function (isPbmInitOK) {
+ initStatus();
+ if (isPbmInitOK) {
+ getSMSMessages(function () {
+ getPhoneBooks();
+ hideLoading();
+ });
+ } else {
+ getSMSMessages(function () {
+ config.phonebook = [];
+ //if(config.HAS_PHONEBOOK){
+ dealPhoneBooks();
+ //}
+ hideLoading();
+ });
+ }
+ bindingEvents();
+ fixScrollTop();
+ window.scrollTo(0, 0);
+ initSmsCapability();
+ };
+
+ getSMSReady();
+ }
+
+ //初始化短信容量状态
+ function initSmsCapability() {
+ var capabilityContainer = $("#smsCapability");
+ updateSmsCapabilityStatus(capabilityContainer);
+ checkSimStatusForSend();
+ addInterval(function () {
+ updateSmsCapabilityStatus(capabilityContainer);
+ checkSimStatusForSend();
+ }, 5000);
+ }
+
+ //SIM卡未准备好时,禁用发送按钮
+ function checkSimStatusForSend() {
+ var data = service.getStatusInfo();
+ if (data.simStatus != 'modem_init_complete') {
+ disableBtn($("#btn-send"));
+ $("#sendSmsErrorLi").html('<span data-trans="no_sim_card_message">' + $.i18n.prop('no_sim_card_message') + '</span>');
+ $("#chatpanel .smslist-item-resend:visible").hide();
+ } else {
+ enableBtn($("#btn-send"));
+ $("#chatpanel .smslist-item-resend:hidden").show();
+ }
+ }
+
+ //更新短信容量状态
+ function updateSmsCapabilityStatus(capabilityContainer, callback) {
+ service.getSmsCapability({}, function (capability) {
+ if (capabilityContainer != null) {
+ capabilityContainer.text("(" + (capability.nvUsed > capability.nvTotal ? capability.nvTotal : capability.nvUsed) + "/" + capability.nvTotal + ")");
+ }
+ hasCapability = capability.nvUsed < capability.nvTotal;
+ smsCapability = capability;
+ if ($.isFunction(callback)) {
+ callback();
+ }
+ });
+ }
+
+ //初始化页面及VM
+ function init() {
+ getReadyStatus();
+ }
+
+ //事件绑定
+ bindingEvents = function () {
+ var $win = $(window);
+ var $smsListBtns = $("#smslist-main .smslist-btns");
+ var offsetTop = $("#mainContainer").offset().top;
+ $win.unbind("scroll").scroll(function () {
+ if ($win.scrollTop() > offsetTop) {
+ $smsListBtns.addClass("smsListFloatButs marginnone");
+ } else {
+ $smsListBtns.removeClass("smsListFloatButs marginnone");
+ }
+ //loadData(); //由于目前数据显示是全显示,不做动态加载,因此暂时注释掉
+ });
+
+ $("#smslist-table p.checkbox").die().live("click", function () {
+ checkboxClickHandler($(this).attr("id"));
+ });
+
+ $("#smslist-checkAll", "#smsListForm").die().live("click", function () {
+ checkDeleteBtnStatus();
+ });
+
+ $("#chat-input", "#smsChatRoom").die().live("drop", function () {
+ $("#inputpanel .chatform").addClass("chatformfocus");
+ var $this = $(this);
+ $this.removeAttr("data-trans");
+ if ($this.val() == $.i18n.prop("chat_input_placehoder")) {
+ $this.val("");
+ }
+ updateChatInputWordLength();
+ }).live("focusin", function () {
+ $("#inputpanel .chatform").addClass("chatformfocus");
+ var $this = $(this);
+ $this.removeAttr("data-trans");
+ if ($this.val() == $.i18n.prop("chat_input_placehoder")) {
+ $this.val("");
+ }
+ updateChatInputWordLength();
+ }).live("focusout", function () {
+ $("#inputpanel .chatform").removeClass("chatformfocus");
+ var $this = $(this);
+ if ($this.val() == "" || $this.val() == $.i18n.prop("chat_input_placehoder")) {
+ $this.val($.i18n.prop("chat_input_placehoder")).attr("data-trans", "chat_input_placehoder");
+ }
+ updateChatInputWordLength();
+ }).live("keyup", function () {
+ updateChatInputWordLength();
+ }).live("paste", function () {
+ window.setTimeout(function () {
+ updateChatInputWordLength();
+ }, 0);
+ }).live("cut", function () {
+ window.setTimeout(function () {
+ updateChatInputWordLength();
+ }, 0);
+ }).live("drop", function () {
+ window.setTimeout(function () {
+ updateChatInputWordLength();
+ }, 0);
+ }).live("contextmenu", function () {
+ return false;
+ });
+
+ $("#name").die().live("drop", function () {
+ updateNameInputWordLength();
+ }).live("focusin", function () {
+ updateNameInputWordLength();
+ }).live("focusout", function () {
+ updateNameInputWordLength();
+ }).live("keyup", function () {
+ updateNameInputWordLength();
+ }).live("paste", function () {
+ updateNameInputWordLength();
+ }).live("cut", function () {
+ updateNameInputWordLength();
+ }).live("dragend", function () {
+ updateNameInputWordLength();
+ }).live("contextmenu", function () {
+ return false;
+ });
+
+ $("select.chosen-select-deselect", "#smsChatRoom").die().live('change', function () {
+ draftListener();
+ });
+ $("#searchInput").die().live('blur', function () {
+ searchTextBlur();
+ }).live('keyup', function () {
+ updateSearchValue($("#searchInput").val());
+ });
+ };
+
+ //更新剩余字数
+ updateNameInputWordLength = function () {
+
+ var msgInput = $("#name", "#quickSaveContactForm");
+ var msgInputDom = msgInput[0];
+ var strValue = msgInput.val();
+ var encodeType = getEncodeType(strValue);
+ var maxLength = encodeType.encodeType == 'UNICODE' ? 11 : 22;
+ while (strValue.length + encodeType.extendLen > maxLength) {
+ strValue = strValue.substring(0, strValue.length - 1);
+ msgInputDom.value = strValue;
+ encodeType = getEncodeType(strValue);
+ maxLength = encodeType.encodeType == 'UNICODE' ? 11 : 22;
+ }
+ };
+
+//获取聊天对象的名字
+ getNameByNumber = function (num) {
+ for (var i = config.phonebook.length; i > 0; i--) {
+ if (getLastNumber(config.phonebook[i - 1].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH)) {
+ return config.phonebook[i - 1].pbm_name;
+ }
+ }
+ return "";
+ };
+ //获取聊天对象的名字和号码
+ getShowNameByNumber = function (num) {
+ for (var i = config.phonebook.length; i > 0; i--) {
+ if (getLastNumber(config.phonebook[i - 1].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH)) {
+ return config.phonebook[i - 1].pbm_name /* + "/" + num*/;
+ }
+ }
+ return num;
+ };
+
+ //获取聊天对象的名字,如果没有名字,则显示号码
+ getNameOrNumberByNumber = function (num) {
+ for (var i = config.phonebook.length; i > 0; i--) {
+ if (config.phonebook[i - 1].pbm_number == num) {
+ return config.phonebook[i - 1].pbm_name;
+ }
+ }
+ for (var i = config.phonebook.length; i > 0; i--) {
+ if (getLastNumber(config.phonebook[i - 1].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH)) {
+ return config.phonebook[i - 1].pbm_name;
+ }
+ }
+ return num;
+ };
+
+ //点击短信列表条目,进入聊天室页面
+ smsItemClickHandler = function (num) {
+ if (chatRoomInLoading) {
+ return false;
+ }
+ chatRoomInLoading = true;
+ if (smsOtherTmpl == null) {
+ smsOtherTmpl = $.template("smsOtherTmpl", $("#smsOtherTmpl"));
+ }
+ if (smsMeTmpl == null) {
+ smsMeTmpl = $.template("smsMeTmpl", $("#smsMeTmpl"));
+ }
+
+ var name = getShowNameByNumber(num);
+ $("#chosenUser", "#smsChatRoom").hide();
+ $("#chosenUser1", "#smsChatRoom").addClass("hide");
+
+ config.currentChatObject = getLastNumber(num, config.SMS_MATCH_LENGTH);
+ setAsRead(num);
+ cleanChatInput();
+ clearChatList();
+ var userSelect = $("select.chosen-select-deselect", "#smsChatRoom");
+ var ops = $("option", userSelect);
+ var numberExist = false;
+ for (var i = 0; i < ops.length; i++) {
+ var n = ops[i];
+ if (getLastNumber(n.value, config.SMS_MATCH_LENGTH) == config.currentChatObject) {
+ num = n.value;
+ numberExist = true;
+ break;
+ }
+ }
+ if (!numberExist) {
+ userSelect.append("<option value='" + HTMLEncode(num) + "' selected='selected'>" + HTMLEncode(num) + "</option>");
+ }
+ $("select.chosen-select-deselect").val(num).trigger("chosen:updated.chosen");
+ switchPage('chat');
+ config.dbMsgs = _.sortBy(config.dbMsgs, function (e) {
+ return 0 - e.id;
+ });
+ var draftIds = [];
+ var dbMsgsTmp = [];
+ var dbMsgsTmpIds = [];
+ var chatHasDraft = false;
+ for (var i = config.dbMsgs.length - 1; i >= 0; i--) {
+ var e = config.dbMsgs[i];
+ if (_.indexOf(dbMsgsTmpIds, e.id) != -1) {
+ continue;
+ }
+ if (getLastNumber(e.number, config.SMS_MATCH_LENGTH) == config.currentChatObject && _.isEmpty(e.groupId)) {
+ e.isNew = false;
+ e.errorText = '';
+ e.targetName = '';
+ if (e.tag == "0" || e.tag == "1") {
+ $.tmpl("smsOtherTmpl", e).appendTo("#chatlist");
+ dbMsgsTmpIds.push(e.id);
+ dbMsgsTmp.push(e);
+ } else if (e.tag == "2" || e.tag == "3") {
+ $.tmpl("smsMeTmpl", e).appendTo("#chatlist");
+ dbMsgsTmpIds.push(e.id);
+ dbMsgsTmp.push(e);
+ } else if (e.tag == "4") {
+ draftIds.push(e.id);
+ $("#chat-input", "#smsChatRoom").val(e.content).removeAttr('data-trans');
+ updateChatInputWordLength();
+ chatHasDraft = true;
+ }
+ } else {
+ dbMsgsTmpIds.push(e.id);
+ dbMsgsTmp.push(e);
+ }
+ }
+ $("#chatlist").translate();
+ if (chatHasDraft) {
+ $("#chosenUser", "#smsChatRoom").show();
+ $("#chosenUser1", "#smsChatRoom").addClass("hide");
+ } else {
+ $("#chosenUser", "#smsChatRoom").hide();
+ $("#chosenUser1", "#smsChatRoom").removeClass("hide").html(HTMLEncode(name));
+ }
+ config.dbMsgs = dbMsgsTmp.reverse();
+ if (draftIds.length > 0) {
+ deleteDraftSms(draftIds, [num]);
+ } else {
+ checkSmsCapacityAndAlert();
+ }
+
+ checkSimStatusForSend();
+ gotoBottom();
+ chatRoomInLoading = false;
+ };
+
+ function checkSmsCapacityAndAlert() {
+ var capabilityContainer = $("#smsCapability");
+ updateSmsCapabilityStatus(capabilityContainer);
+ addTimeout(function () {
+ if (!hasCapability) {
+ showAlert("sms_capacity_is_full_for_send");
+ }
+ }, 2000);
+ }
+
+ cleanChatInput = function () {
+ $("#chat-input", "#smsChatRoom").val($.i18n.prop("chat_input_placehoder")).attr("data-trans", "chat_input_placehoder");
+ };
+
+ //设置为已读
+ setAsRead = function (num) {
+ var ids = [];
+ $.each(config.dbMsgs, function (i, e) {
+ if (getLastNumber(e.number, config.SMS_MATCH_LENGTH) == getLastNumber(num, config.SMS_MATCH_LENGTH) && e.isNew) {
+ ids.push(e.id);
+ e.isNew = false;
+ }
+ });
+ if (ids.length > 0) {
+ service.setSmsRead({
+ ids: ids
+ }, function (data) {
+ if (data.result) {
+ $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH) + " .smslist-item-new-count").text("").addClass("hide");
+ $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH)).removeClass("font-weight-bold");
+ $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH) + " td:nth-child(2)").removeClass("font-weight-bold");
+ }
+ $.each(config.listMsgs, function (i, e) {
+ if (e.number == num && e.newCount > 0) {
+ e.newCount = 0;
+ }
+ });
+ });
+ }
+ };
+
+ //转发按钮点击事件
+ forwardClickHandler = function (id) {
+ var selectedContact = syncSelectAndChosen($("select#chosenUserSelect"), $('.search-choice', '#chosenUserSelect_chosen'));
+ var content = $("#chat-input", "#smsChatRoom").val();
+ var hasContent = typeof content != "undefined" && content != '' && content != $.i18n.prop('chat_input_placehoder');
+ if (hasContent) {
+ saveDraftAction({
+ content: content,
+ numbers: selectedContact,
+ isFromBack: true,
+ noLoading: true
+ });
+ }
+
+ clearChatList();
+ config.currentChatObject = null;
+
+ $("#chosenUser1", "#smsChatRoom").addClass("hide");
+ $("#chosenUser", "#smsChatRoom").show();
+ for (var j = 0; j < config.dbMsgs.length; j++) {
+ if (config.dbMsgs[j].id == id) {
+ var theChatInput = $("#chat-input", "#smsChatRoom");
+ theChatInput.val(config.dbMsgs[j].content);
+ setInsertPos(theChatInput[0], config.dbMsgs[j].content.length);
+ }
+ }
+ updateChatInputWordLength();
+ $("select.chosen-select-deselect").val("").trigger("chosen:updated.chosen");
+ addTimeout(function () {
+ $("#chosen-search-field-input").focus();
+ }, 300);
+ switchPage('chat');
+ gotoBottom();
+ };
+
+ //更新剩余字数
+ updateChatInputWordLength = function () {
+ var msgInput = $("#chat-input", "#smsChatRoom");
+ var msgInputDom = msgInput[0];
+ var strValue = msgInput.val();
+ var encodeType = getEncodeType(strValue);
+ var maxLength = encodeType.encodeType == 'UNICODE' ? 335 : 765;
+ if (strValue.length + encodeType.extendLen > maxLength) {
+ var scrollTop = msgInputDom.scrollTop;
+ var insertPos = getInsertPos(msgInputDom);
+ var moreLen = strValue.length + encodeType.extendLen - maxLength;
+ var insertPart = strValue.substr(insertPos - moreLen > 0 ? insertPos - moreLen : 0, moreLen);
+ var reversed = insertPart.split('').reverse();
+ var checkMore = 0;
+ var cutNum = 0;
+ for (var i = 0; i < reversed.length; i++) {
+ if (getEncodeType(reversed[i]).extendLen > 0) {
+ checkMore += 2;
+ } else {
+ checkMore++;
+ }
+ if (checkMore >= moreLen) {
+ cutNum = i + 1;
+ break;
+ }
+ }
+ var iInsertToStartLength = insertPos - cutNum;
+ msgInputDom.value = strValue.substr(0, iInsertToStartLength) + strValue.substr(insertPos);
+ if (msgInputDom.value.length > maxLength) {
+ msgInputDom.value = msgInputDom.value.substr(0, maxLength);
+ }
+ setInsertPos(msgInputDom, iInsertToStartLength);
+ msgInputDom.scrollTop = scrollTop;
+ }
+ var textLength = 0;
+ var newValue = $(msgInputDom).val();
+ var newEncodeType = {
+ encodeType: 'GSM7_default',
+ extendLen: 0
+ };
+ if (newValue != $.i18n.prop('chat_input_placehoder')) {
+ newEncodeType = getEncodeType(newValue);
+ }
+ var newMaxLength = newEncodeType.encodeType == 'UNICODE' ? 335 : 765;
+ var $inputCount = $("#inputcount", "#inputpanel");
+ var $inputItemCount = $("#inputItemCount", "#inputpanel");
+ if (newValue.length + newEncodeType.extendLen >= newMaxLength) {
+ $inputCount.addClass("colorRed");
+ $inputItemCount.addClass("colorRed");
+ } else {
+ $("#inputcount", "#inputpanel").removeClass("colorRed");
+ $("#inputItemCount", "#inputpanel").removeClass("colorRed");
+ }
+ if ("" != newValue && $.i18n.prop('chat_input_placehoder') != newValue) {
+ textLength = newValue.length + newEncodeType.extendLen;
+ }
+ $inputCount.html("(" + textLength + "/" + newMaxLength + ")");
+ $inputItemCount.html("(" + getSmsCount(newValue) + "/5)");
+ draftListener();
+ };
+
+ //文档内容监听,判断是否修改过
+ function draftListener() {
+ var content = $("#chat-input", "#smsChatRoom").val();
+ if (hasCapability) {
+ var selectedContact = getSelectValFromChosen($('.search-choice', '#chosenUserSelect_chosen'));
+ var noContactSelected = !selectedContact || selectedContact.length == 0;
+ var hasContent = typeof content != "undefined" && content != '' && content != $.i18n.prop('chat_input_placehoder');
+
+ if (!hasContent) {
+ config.resetContentModifyValue();
+ return;
+ }
+ if (hasContent && !noContactSelected) {
+ config.CONTENT_MODIFIED.modified = true;
+ config.CONTENT_MODIFIED.message = 'sms_to_save_draft';
+ config.CONTENT_MODIFIED.callback.ok = saveDraftAction;
+ config.CONTENT_MODIFIED.callback.no = $.noop;
+ config.CONTENT_MODIFIED.data = {
+ content: $("#chat-input", "#smsChatRoom").val(),
+ numbers: selectedContact
+ };
+ return;
+ }
+ if (hasContent && noContactSelected) {
+ config.CONTENT_MODIFIED.modified = true;
+ config.CONTENT_MODIFIED.message = 'sms_no_recipient';
+ config.CONTENT_MODIFIED.callback.ok = $.noop;
+ config.CONTENT_MODIFIED.callback.no = function () {
+ // 返回true,页面保持原状
+ return true;
+ }; //$.noop;
+ return;
+ }
+ } else {
+ config.resetContentModifyValue();
+ }
+ }
+
+ //保存草稿回调动作
+ function saveDraftAction(data) {
+ var datetime = new Date();
+ var params = {
+ index: -1,
+ currentTimeString: getCurrentTimeString(datetime),
+ groupId: data.numbers.length > 1 ? datetime.getTime() : '',
+ message: data.content,
+ numbers: data.numbers
+ };
+ !data.noLoading && showLoading('waiting');
+ service.saveSMS(params, function () {
+ if (data.isFromBack) {
+ getLatestDraftSms(data.numbers);
+ !data.noLoading && successOverlay('sms_save_draft_success');
+ } else {
+ !data.noLoading && successOverlay('sms_save_draft_success');
+ }
+ }, function () {
+ !data.noLoading && errorOverlay("sms_save_draft_failed")
+ });
+
+ //获取最新的草稿信息
+ function getLatestDraftSms(numbers) {
+ service.getSMSMessages({
+ page: 0,
+ smsCount: 5,
+ nMessageStoreType: 1,
+ tags: 4,
+ orderBy: "order by id desc"
+ }, function (data) {
+ if (data.messages && data.messages.length > 0) {
+ var theGroupId = '',
+ draftShowName = '',
+ draftShowNameTitle = '',
+ i = 0,
+ drafts = [];
+ for (; i < data.messages.length; i++) {
+ var msg = data.messages[i];
+ for (var k = 0; k < numbers.length; k++) {
+ var num = numbers[k];
+ if (getLastNumber(num, config.SMS_MATCH_LENGTH) == getLastNumber(msg.number, config.SMS_MATCH_LENGTH)) { //if (num.indexOf(msg.number) == 0) {
+ msg.number = num;
+ }
+ }
+ if (theGroupId != '' && theGroupId != msg.groupId) {
+ break;
+ }
+ updateDBMsg(msg);
+ if (msg.groupId == '') { // 单条草稿
+ break;
+ } else { // 多条草稿
+ theGroupId = msg.groupId;
+ var showName = getShowNameByNumber(msg.number);
+ draftShowName += (i == 0 ? '' : ';') + showName;
+ draftShowNameTitle += (i == 0 ? '' : ';') + showName;
+ }
+ drafts.push(msg);
+ }
+ if (theGroupId == '') { // 单条草稿
+ var msg = data.messages[0];
+ msg.hasDraft = true;
+ updateMsgList(msg);
+ } else { // 多条草稿
+ var msg = data.messages[0];
+ var len = 10;
+ if (getEncodeType(draftShowName).encodeType == "UNICODE") {
+ len = 10;
+ }
+ msg.draftShowNameTitle = draftShowNameTitle;
+ msg.draftShowName = draftShowName.length > len ? draftShowName.substring(0, len) + "..." : draftShowName;
+ msg.hasDraft = true;
+ msg.totalCount = i;
+ groupedDraftsObject[theGroupId] = drafts;
+ updateMsgList(msg);
+ }
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);
+ }
+ }, function () {
+ // do nothing
+ });
+ }
+ }
+
+ //点击群聊草稿进入草稿发送页面 在进入的过程中会先删掉草稿
+ draftSmsItemClickHandler = function (groupId) {
+ if (chatRoomInLoading) {
+ return false;
+ }
+ chatRoomInLoading = true;
+ var msgs = groupedDraftsObject[groupId];
+ var numbers = [];
+ var ids = [];
+ for (var i = 0; msgs && i < msgs.length; i++) {
+ numbers.push(getLastNumber(msgs[i].number, config.SMS_MATCH_LENGTH));
+ ids.push(msgs[i].id + '');
+ }
+ $("#chosenUser", "#smsChatRoom").show();
+ $("#chosenUser1", "#smsChatRoom").addClass("hide").html('');
+ $("select.chosen-select-deselect").val(numbers).trigger("chosen:updated.chosen");
+ $("#chat-input", "#smsChatRoom").val(msgs[0].content);
+ updateChatInputWordLength();
+ clearChatList();
+ switchPage('chat');
+ draftListener();
+ gotoBottom();
+ chatRoomInLoading = false;
+ deleteMultiDraftSms(ids, groupId);
+ };
+
+ //按列表条目删除短消息
+ deletePhoneMessageClickHandler = function (num) {
+ showConfirm("confirm_sms_delete", function () {
+ showLoading('deleting');
+ var ids = [];
+ $.each(config.dbMsgs, function (i, e) {
+ if (e.number == num) {
+ ids.push(e.id);
+ }
+ });
+ service.deleteMessage({
+ ids: ids
+ }, function (data) {
+ $("#smslist-item-" + getLastNumber(num, config.SMS_MATCH_LENGTH)).hide().remove();
+ synchSmsList([num], ids);
+ successOverlay();
+ tryToDisableCheckAll($("#smslist-checkAll", "#smsListForm"), $(".smslist-item", "#smslist-table").length);
+ }, function (error) {
+ errorOverlay(error.errorText);
+ });
+ });
+ };
+
+ //同步短信列表数据
+ synchSmsList = function (nums, ids) {
+ if (nums && nums.length > 0) {
+ config.listMsgs = $.grep(config.listMsgs, function (n, i) {
+ return $.inArray(n.number, nums) == -1;
+ });
+ }
+ if (ids && ids.length > 0) {
+ var dbMsgsTmp = [];
+ $.each(config.dbMsgs, function (i, e) {
+ if ($.inArray(e.id, ids) == -1) {
+ dbMsgsTmp.push(e);
+ }
+ });
+ config.dbMsgs = dbMsgsTmp;
+ }
+ };
+
+ //确定最后一条短消息距离顶部的距离
+ function fixScrollTop() {
+ var items = $(".smslist-item");
+ var lastOne;
+ if (items.length > 0) {
+ lastOne = items[items.length - 1];
+ } else {
+ lastOne = items[0];
+ }
+ lastItemOffsetTop = lastOne ? lastOne.offsetTop : 600;
+ }
+
+ function loadData() {
+ if (ready && !scrolling && lastItemOffsetTop < ($(window).scrollTop() + $(window).height())
+ && $(".smslist-item").length != config.listMsgs.length) {
+ scrolling = true;
+ addTimeout(function () {
+ removeChecked("smslist-checkAll");
+ changeShownMsgs();
+ fixScrollTop();
+ scrolling = false;
+ }, 100);
+ }
+ }
+
+ function stopNavigation() {
+ disableBtn($('#btn-back'));
+ $('a', '#left').bind("click", function () {
+ return false;
+ });
+ $('a', '#list-nav').bind("click", function () {
+ return false;
+ });
+ }
+
+ function restoreNavigation() {
+ enableBtn($('#btn-back'));
+ $('a', '#left').unbind("click");
+ $('a', '#list-nav').unbind("click");
+ }
+
+ function searchTable(key) {
+ key = $.trim(key);
+ var $trs = $('tr', '#smslist-table'),
+ trLength = $trs.length;
+ if (key == '') {
+ $trs.show();
+ return false;
+ }
+ $trs.hide();
+ while (trLength) {
+ var $tr = $($trs[trLength - 1]),
+ $tds = $('td', $tr),
+ tdLength = $tds.length;
+ while (tdLength - 1) {
+ var $td = $($tds[tdLength - 1]);
+ if ($td.text().toLowerCase().indexOf(key.toLowerCase()) != -1) {
+ $tr.show();
+ break;
+ }
+ tdLength--;
+ }
+ trLength--;
+ }
+
+ addTimeout(function () {
+ $(":checkbox:checked", "#addPhonebookContainer").removeAttr('checked');
+ vm.selectedItemIds([]);
+ vm.freshStatus($.now());
+ renderCheckbox();
+ }, 300);
+ return true;
+ }
+ updateSearchValue = function (key) {
+ if (key == "" || key == $.i18n.prop("search")) {
+ return true;
+ }
+ searchTable(key);
+ };
+ //清除搜索关键字事件
+ clearSearchKey = function () {
+ updateSearchValue($.i18n.prop("search"));
+ $("#searchInput").addClass("ko-grid-search-txt-default").attr("data-trans", "search");
+ };
+ //点击搜索输入框事件
+ searchTextClick = function () {
+ var searchText = $("#searchInput");
+ if (searchText.hasClass("ko-grid-search-txt-default")) {
+ updateSearchValue("");
+ searchText.val("");
+ searchText.removeClass("ko-grid-search-txt-default").removeAttr("data-trans");
+ }
+ };
+ //离开搜索输入框事件
+ searchTextBlur = function () {
+ var txt = $.trim($("#searchInput").val()).toLowerCase();
+ if (txt == "") {
+ clearSearchKey();
+ }
+ };
+
+ window.smsUtil = {
+ changeLocationHandler: function (ele) {
+ if ($(ele).val() == 'sim') {
+ window.location.hash = '#msg_sim';
+ } else {
+ window.location.hash = '#msg_main';
+ }
+ }
+ };
+
+ return {
+ init: init
+ };
+});
+
+define("sms_set","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var validityModes = _.map(config.SMS_VALIDITY, function (item) {
+ return new Option(item.name, item.value);
+ });
+
+ function SmsSetViewMode() {
+ var target = this;
+ var setting = getSmsSetting();
+ target.modes = ko.observableArray(validityModes);
+ target.selectedMode = ko.observable(setting.validity);
+ target.centerNumber = ko.observable(setting.centerNumber);
+ target.deliveryReport = ko.observable(setting.deliveryReport);
+
+ target.clear = function () {
+ init();
+ clearValidateMsg();
+ };
+
+ target.save = function () {
+ showLoading('waiting');
+ var params = {};
+ params.validity = target.selectedMode();
+ params.centerNumber = target.centerNumber();
+ params.deliveryReport = target.deliveryReport();
+ service.setSmsSetting(params, function (result) {
+ if (result.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+ }
+
+ //获取短信设置参数
+
+ function getSmsSetting() {
+ return service.getSmsSetting();
+ }
+
+ function init() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var vm = new SmsSetViewMode();
+ ko.applyBindings(vm, container[0]);
+ $('#smsSettingForm').validate({
+ submitHandler: function () {
+ vm.save();
+ },
+ rules: {
+ txtCenterNumber: "sms_service_center_check"
+ }
+ });
+ }
+
+ return {
+ init: init
+ };
+});
+
+define("sms_sim_messages","jquery knockout set service".split(" "),
+ function ($, ko, config, service) {
+ var simMsgListTmpl = null;
+ //每页记录条数
+ var perPage = 200;
+
+ //获取短信分页记录
+ function getSMSMessages() {
+ return service.getSMSMessages({
+ page: 0,
+ smsCount: perPage,
+ nMessageStoreType: 0,
+ tags: 10,
+ orderBy: "order by id desc"
+ }, function (data) {
+ tryToDisableCheckAll($("#simMsgList-checkAll"), data.messages.length);
+ dealPhoneBooks(data.messages);
+ }, function (data) {
+ dealPhoneBooks([]);
+ });
+ }
+
+ //短信显示联系人名字,并将结果显示在UI
+ function dealPhoneBooks(messages) {
+ $.each(messages, function (j, n) {
+ n.itemId = getLastNumber(n.number, config.SMS_MATCH_LENGTH);
+ for (var i = 0; i < config.phonebook.length; i++) {
+ var person = config.phonebook[i];
+ if (n.itemId == getLastNumber(person.pbm_number, config.SMS_MATCH_LENGTH)) {
+ n.name = person.pbm_name;
+ break;
+ }
+ }
+ });
+ renderSimMessageList(messages);
+ }
+
+ //清楚短信列表内容
+ cleanSimSmsList = function () {
+ $("#simMsgList_container").empty();
+ };
+
+ //将短信显示结果显示在UI
+ function renderSimMessageList(messages) {
+ if (simMsgListTmpl == null) {
+ simMsgListTmpl = $.template("simMsgListTmpl", $("#simMsgListTmpl"));
+ }
+ cleanSimSmsList();
+ $("#simMsgList_container").html($.tmpl("simMsgListTmpl", {
+ data: messages
+ }));
+ hideLoading();
+ }
+
+ //初始化电话本信息
+ function initPhoneBooks(cb) {
+ service.getPhoneBooks({
+ page: 0,
+ data_per_page: 2000,
+ orderBy: "name",
+ isAsc: true
+ }, function (books) {
+ if ($.isArray(books.pbm_data) && books.pbm_data.length > 0) {
+ config.phonebook = books.pbm_data;
+ } else {
+ config.phonebook = [];
+ }
+ cb();
+ }, function () {
+ errorOverlay();
+ });
+ }
+
+ function simSmsViewMode() {
+ var self = this;
+ start();
+ }
+
+ //短信删除事件处理
+ deleteSelectedSimMsgClickHandler = function () {
+ var checkbox = $("input[name=msgId]:checked", "#simMsgList_container");
+ var msgIds = [];
+ for (var i = 0; i < checkbox.length; i++) {
+ msgIds.push($(checkbox[i]).val());
+ }
+ if (msgIds.length == 0) {
+ return false;
+ }
+ showConfirm("confirm_sms_delete", function () {
+ showLoading('deleting');
+ service.deleteMessage({
+ ids: msgIds
+ }, function (data) {
+ removeChecked("simMsgList-checkAll");
+ disableBtn($("#simMsgList-delete"));
+ var idsForDelete = "";
+ checkbox.each(function (i, n) {
+ idsForDelete += ".simMsgList-item-class-" + $(n).val() + ",";
+ });
+ if (idsForDelete.length > 0) {
+ $(idsForDelete.substring(0, idsForDelete.length - 1)).hide().remove();
+ }
+ tryToDisableCheckAll($("#simMsgList-checkAll"), $(".smslist-item", "#simMsgList_container").length);
+ successOverlay();
+ }, function (error) {
+ errorOverlay(error.errorText);
+ });
+ //删除短信后需要刷新列表
+ updateSimSmsCapabilityStatus($("#simSmsCapability"));
+ });
+ };
+ //将被checked的条目添加到self.checkedItem中,用于在滚动还原checkbox
+ function checkboxClickHandler() {
+ if (getSelectedItemSize() == 0) {
+ disableBtn($("#simMsgList-delete"));
+ } else {
+ enableBtn($("#simMsgList-delete"));
+ }
+ }
+
+ //获取已选择的条目
+ function getSelectedItemSize() {
+ return $("input:checkbox:checked", '#simMsgList_container').length;
+ }
+
+ //模块开始,检查电话本及短信状态并加装页码数据
+ function start() {
+ showLoading('waiting');
+ var getSMSReady = function () {
+ service.getSMSReady({}, function (data) {
+ if (data.sms_cmd_status_result == "2") {
+ hideLoading();
+ showAlert("sms_init_fail");
+ } else if (data.sms_cmd_status_result == "1") {
+ addTimeout(function () {
+ getSMSReady();
+ }, 1000);
+ } else {
+ if (!config.HAS_PHONEBOOK) {
+ initSMSList(config.HAS_PHONEBOOK);
+ } else {
+ getPhoneBookReady();
+ }
+ }
+ });
+ };
+
+ var getPhoneBookReady = function () {
+ service.getPhoneBookReady({}, function (data) {
+ if (data.pbm_init_flag == "6") {
+ initSMSList(false);
+ } else if (data.pbm_init_flag != "0") {
+ addTimeout(function () {
+ getPhoneBookReady();
+ }, 1000);
+ } else {
+ initSMSList(config.HAS_PHONEBOOK);
+ }
+ });
+ };
+
+ var initSMSList = function (isPbmInitOK) {
+ if (isPbmInitOK) {
+ initPhoneBooks(function () {
+ getSMSMessages();
+ });
+ } else {
+ config.phonebook = [];
+ getSMSMessages();
+ }
+ };
+ getSMSReady();
+ initSimSmsCapability();
+ }
+
+ //初始化短信容量状态
+ function initSimSmsCapability() {
+ var capabilityContainer = $("#simSmsCapability");
+ updateSimSmsCapabilityStatus(capabilityContainer);
+ addInterval(function () {
+ updateSimSmsCapabilityStatus(capabilityContainer);
+ }, 5000);
+ }
+
+ //更新短信容量状态
+ function updateSimSmsCapabilityStatus(capabilityContainer) {
+ service.getSmsCapability({}, function (capability) {
+ if (capabilityContainer != null) {
+ capabilityContainer.text("(" + capability.simUsed + "/" + capability.simTotal + ")");
+ }
+ });
+ }
+
+ //清除搜索关键字事件
+ clearSearchKey = function () {
+ updateSearchValue($.i18n.prop("search"));
+ $("#searchInput").addClass("ko-grid-search-txt-default").attr("data-trans", "search");
+ };
+ //点击搜索输入框事件
+ searchTextClick = function () {
+ var searchText = $("#searchInput");
+ if (searchText.hasClass("ko-grid-search-txt-default")) {
+ updateSearchValue("");
+ searchText.val("");
+ searchText.removeClass("ko-grid-search-txt-default").removeAttr("data-trans");
+ }
+ };
+ //离开搜索输入框事件
+ searchTextBlur = function () {
+ var txt = $.trim($("#searchInput").val()).toLowerCase();
+ if (txt == "") {
+ clearSearchKey();
+ }
+ };
+
+ updateSearchValue = function (key) {
+ if (key == "" || key == $.i18n.prop("search")) {
+ return true;
+ }
+ searchTable(key);
+ }
+
+ function searchTable(key) {
+ key = $.trim(key);
+ var $trs = $('tr', '#smslist-table'),
+ trLength = $trs.length;
+ if (key == '') {
+ $trs.show();
+ return false;
+ }
+ $trs.hide();
+ while (trLength) {
+ var $tr = $($trs[trLength - 1]),
+ $tds = $('td', $tr),
+ tdLength = $tds.length;
+ while (tdLength - 1) {
+ var $td = $($tds[tdLength - 1]);
+ if ($td.text().toLowerCase().indexOf(key.toLowerCase()) != -1) {
+ $tr.show();
+ break;
+ }
+ tdLength--;
+ }
+ trLength--;
+ }
+
+ addTimeout(function () {
+ $(":checkbox:checked", "#addPhonebookContainer").removeAttr('checked');
+ vm.selectedItemIds([]);
+ vm.freshStatus($.now());
+ renderCheckbox();
+ }, 300);
+ return true;
+ }
+
+ //点击短信列表条目
+ simsmsItemClickHandler = function (tag, id, num) {
+ if (tag == "1") {
+ var ids = [];
+ ids.push(id);
+ service.setSmsRead({
+ ids: ids
+ }, function (data) {
+ if (data.result) {
+ $(".simMsgList-item-class-" + id, "#simMsgTableContainer").removeClass('font-weight-bold');
+ }
+ });
+ }
+ }
+
+ //页面事件绑定
+ function initEventBind() {
+ $(".smslist-item-msg", "#simMsgTableContainer").die().live("click", function () {
+ var $this = $(this).addClass('showFullHeight');
+ $('.smslist-item-msg.showFullHeight', '#simMsgTableContainer').not($this).removeClass('showFullHeight');
+ });
+ $("#simMsgList_container p.checkbox, #simMsgListForm #simMsgList-checkAll").die().live("click", function () {
+ checkboxClickHandler();
+ });
+ $("#searchInput").die().live('blur', function () {
+ searchTextBlur();
+ }).live('keyup', function () {
+ updateSearchValue($("#searchInput").val());
+ });
+ }
+
+ //模块初始化开始
+ function init() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var vm = new simSmsViewMode();
+ ko.applyBindings(vm, container[0]);
+ initEventBind();
+ }
+
+ window.smsUtil = {
+ changeLocationHandler: function (ele) {
+ if ($(ele).val() == 'sim') {
+ window.location.hash = '#msg_sim';
+ } else {
+ window.location.hash = '#msg_main';
+ }
+ }
+ };
+
+ return {
+ init: init
+ };
+});
diff --git a/lynq/R305/ap/app/zte_webui/js/wifi.js b/lynq/R305/ap/app/zte_webui/js/wifi.js
new file mode 100755
index 0000000..df3583a
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/js/wifi.js
@@ -0,0 +1,3732 @@
+define("wifi_advance","underscore jquery knockout set service jqui".split(" "),
+ function (_, $, ko, config, service, jqui) {
+ var $sliderRange = null;
+ //当前是否WiFi连接
+ var viaWifi = false;
+
+ function paintRateOption(data) {
+ var opts = [];
+ for (var i = 0; i < data.length; i++) {
+ var rate = data[i].rate == 0 ? "Auto" : data[i].rate + " Mbps";
+ opts.push(new Option(rate, data[i].index));
+ }
+ return opts;
+ }
+
+ //wifi传输速率
+ var transpeed = [0, 1, 2, 5.5, 6, 6.5, 9, 11, 12, 13, 18, 19.5, 24, 26, 36, 39, 48, 52, 54, 58.5, 65];
+
+ function rateSort(a, b) {
+ return a.rate - b.rate;
+ }
+ //删除重复速率值
+ function unionRate(rateTable) {
+ var rates = [],
+ result = [];
+ for (var i = 0; i < rateTable.length; i++) {
+ for (var j = 0; j < rateTable[i].length; j++) {
+ if (ko.utils.arrayIndexOf(rates, rateTable[i][j]) == -1) {
+ rates.push(rateTable[i][j]);
+ result.push({
+ index: rateTable[i][j],
+ rate: transpeed[rateTable[i][j]]
+ });
+ }
+ }
+ }
+ result.sort(rateSort);
+ return result;
+ }
+
+ //根据模式生成速率选项
+ function modeRateOption(wifimode) {
+ var wifimodeN = [0, 5, 9, 11, 13, 15, 17, 19, 20];
+ var wifimodeG = [0, 4, 6, 8, 10, 12, 14, 16, 18];
+ var wifimodeB = [0, 1, 2, 3, 7];
+ var rate = [];
+
+ switch (wifimode) {
+ //--wifimode
+ case '5':
+ rate.push(wifimodeN);
+ rate.push(wifimodeG);
+ rate.push(wifimodeB);
+ break;
+ case '4':
+ rate.push(wifimodeN);
+ rate.push(wifimodeG);
+ rate.push(wifimodeB);
+ break;
+ case '3':
+ rate.push(wifimodeG);
+ rate.push(wifimodeB);
+ break;
+ case '2':
+ rate.push(wifimodeN);
+ break;
+ case '1':
+ rate.push(wifimodeG);
+ break;
+ case '0':
+ rate.push(wifimodeB);
+ break;
+
+ default:
+ rate.push(wifimodeN);
+ break;
+ }
+ var union = unionRate(rate);
+ return paintRateOption(union);
+ }
+
+ function getCountryCode(country) {
+ var countryCodeArr = config.countryCode;
+ var type = '';
+ for (key in countryCodeArr) {
+ var codes = countryCodeArr[key];
+ if ($.inArray(country, codes) != -1) {
+ type = key;
+ break;
+ }
+ }
+ var typeCode = config.countryCodeType[type];
+ return typeCode ? typeCode : "0";
+ }
+
+ function channelOption(country) {
+ var showOption = [new Option('Auto', '0')];
+ var type = getCountryCode(country) + '';
+ switch (type) {
+ //--type
+ case '9':
+ generateChannelOption(showOption, 2307, 13);
+ break;
+ case '7':
+ generateChannelOption(showOption, 2307, 13);
+ generateChannelOption(showOption, 2407, 11);
+ generateChannelOption(showOption, 2462, 2);
+ break;
+ case '3':
+ generateChannelOption(showOption, 2407, 11);
+ generateChannelOption(showOption, 2462, 2);
+ break;
+ //--type
+ case '2':
+ generateChannelOption(showOption, 2307, 13);
+ generateChannelOption(showOption, 2407, 11);
+ break;
+ case '1':
+ generateChannelOption(showOption, 2407, 11);
+ break;
+ default:
+ generateChannelOption(showOption, 2407, 11);
+ }
+ return showOption;
+ }
+ function generateChannelOption(showOption, start, count) {
+ for (var i = 1; i <= count; i++) {
+ var txt = start + i * 5 + "MHz (Channel " + showOption.length + ")";
+ showOption.push(new Option(txt, showOption.length + "_" + (start + i * 5)));
+ }
+ }
+
+ function channelOption5g(country) {
+ for (key in config.countryCode_5g) {
+ var item = config.countryCode_5g[key];
+ if ($.inArray(country, item.codes) != -1) {
+ return generate5gChannelOption(item.channels);
+ }
+ }
+ return [new Option('Auto', '0')];
+ }
+ function generate5gChannelOption(channels) {
+ var showOption = [new Option('Auto', '0')];
+ for (var i = 0; i < channels.length; i++) {
+ var channel = channels[i];
+ var mhz = channel * 5 + 5000;
+ var txt = mhz + "MHz (Channel " + channel + ")";
+ showOption.push(new Option(txt, channel + "_" + (mhz)));
+ }
+ return showOption;
+ }
+
+ function getBandOptions() {
+ var showOption = [];
+ if (!config.WIFI_HAS_5G) {
+ showOption.push(new Option('2.4GHz', 'b'));
+ } else {
+ showOption.push(new Option('5GHz', 'a'));
+ showOption.push(new Option('2.4GHz', 'b'));
+ }
+ return showOption;
+ }
+
+ function getChannelBandwidthsOptions(isSupport40) {
+ var showOption = [];
+ if (isSupport40) {
+ showOption.push(new Option('20MHz', '0'));
+ showOption.push(new Option('20MHz/40MHz', '1'));
+ } else {
+ showOption.push(new Option('20MHz', '0'));
+ }
+ return showOption;
+ }
+
+ function countryCodeOption(is5G) {
+ var countries = is5G ? config.countries_5g : config.countries;
+ var showOption = [];
+ for (key in countries) {
+ showOption.push(new Option(countries[key], key));
+ }
+ showOption = _.sortBy(showOption, function (opt) {
+ return opt.text;
+ });
+ return showOption;
+ }
+
+ function getWifiAdvance() {
+ return service.getWifiAdvance();
+ }
+
+ function getWpsState() {
+ return service.getWpsInfo();
+ }
+
+ function getModeOption(wifiBand) {
+ var modes = wifiBand == 'a' ? config.NETWORK_MODES_BAND : config.NETWORK_MODES;
+ if (wifiBand == 'a') {
+ $("#mode").hide();
+ $("#modeFor5HZ").show();
+ $("#modeLabel").attr('for', 'modeFor5HZ');
+ } else if (modes.length == 1) {
+ $("#mode").hide();
+ $("#modeFor5HZ").hide();
+ } else {
+ $("#mode").show();
+ $("#modeFor5HZ").hide();
+ }
+ var modeOptions = [];
+ for (var i = 0; i < modes.length; i++) {
+ modeOptions.push(new Option(modes[i].name, modes[i].value));
+ }
+ return modeOptions;
+ }
+
+ function getSelectedRateV(rate, rates) {
+ for (var i = 0; i < rates.length; i++) {
+ var opt = rates[i];
+ if (opt.text == rate + " Mbps") {
+ return opt.value;
+ }
+ }
+ return '0';
+ }
+ //获取所选的信道对应的value值
+ function getSelectedChannelV(channel, channels) {
+ for (var i = 0; i < channels.length; i++) {
+ var opt = $(channels[i]);
+ if (opt.val().split("_")[0] == channel) {
+ return opt.val();
+ }
+ }
+ return '0';
+ }
+
+ function WifiAdvanceViewModel() {
+ // Data
+ var target = this;
+
+ var wifiInfo = service.getWifiAdvance();
+ target.origin_ap_station_enable = wifiInfo.ap_station_enable;
+ target.modes = ko.observableArray(getModeOption(wifiInfo.wifiBand));
+ target.bands = ko.observableArray(getBandOptions());
+
+ var countryOpts = countryCodeOption(wifiInfo.wifiBand == 'a');
+ target.countries = ko.observableArray(countryOpts);
+ target.channels = ko.observableArray(wifiInfo.wifiBand == 'a' ? channelOption5g(wifiInfo.countryCode) : channelOption(wifiInfo.countryCode));
+ target.rates = ko.observableArray(modeRateOption(wifiInfo.mode));
+
+ target.hasAPStation = config.AP_STATION_SUPPORT;
+ target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
+ target.hasMultiSSID = config.HAS_MULTI_SSID;
+ target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
+ target.hasWifiBand = ko.observable(config.WIFI_BAND_SUPPORT);
+ target.hasBandwidth = ko.observable(config.WIFI_BANDWIDTH_SUPPORT);
+
+ target.selectedMode = ko.observable(wifiInfo.mode);
+ target.selectedChannel = ko.observable(getSelectedChannelV(wifiInfo.channel, target.channels()));
+ target.selectedChannelBandwidth = ko.observable(wifiInfo.bandwidth); //5:a, 2.5:b
+ target.selectedCountry = ko.observable(wifiInfo.countryCode.toUpperCase());
+ target.selectedBand = ko.observable(wifiInfo.wifiBand); //5:a, 2.5:b
+ target.selectedRate = ko.observable(getSelectedRateV(wifiInfo.rate, target.rates()));
+
+ var baseInfo = service.getWifiBasic();
+ target.wifi_enable = ko.observable(baseInfo.wifi_enable);
+ if (config.HAS_MULTI_SSID && ((baseInfo.m_AuthMode == "OPEN" && baseInfo.m_encryptType == "WEP") || (baseInfo.m_AuthMode == "SHARED" && baseInfo.m_encryptType == "WEP") || baseInfo.m_encryptType == "TKIP")) {
+ target.isF = ko.observable(true);
+ } else if ((baseInfo.AuthMode == "OPEN" && baseInfo.encryptType == "WEP") || (baseInfo.AuthMode == "SHARED" && baseInfo.encryptType == "WEP") || baseInfo.encryptType == "TKIP") {
+ target.isF = ko.observable(true);
+ } else {
+ target.isF = ko.observable(false);
+ }
+ target.isShowSSIDInfoDiv = ko.observable(false);
+ if (config.WIFI_SWITCH_SUPPORT) {
+ if (baseInfo.wifi_enable == "1") {
+ target.isShowSSIDInfoDiv(true);
+ } else {
+ target.isShowSSIDInfoDiv(false);
+ }
+ } else {
+ target.isShowSSIDInfoDiv(true);
+ }
+ target.multi_ssid_enable = ko.observable(baseInfo.multi_ssid_enable);
+ target.origin_multi_ssid_enable = baseInfo.multi_ssid_enable;
+ target.maxStationNumber = ko.observable(wifiInfo.MAX_Station_num);
+ target.selectedStation = ko.observable(wifiInfo.MAX_Access_num);
+ target.selectedStationM = ko.observable(wifiInfo.m_MAX_Access_num);
+
+ target.oneBandTrans = ko.observable(wifiInfo.wifiBand == 'a' ? '5G' : '2.4G');
+ target.oneModeTrans = ko.observable((wifiInfo.wifiBand == 'a' ? 'network_modes_band_select_' : 'network_mode_select_') + wifiInfo.mode);
+
+ target.channelBandwidths = ko.computed(function () {
+ if (config.WIFI_BANDWIDTH_SUPPORT_40MHZ) {
+ return getChannelBandwidthsOptions(true);
+ } else {
+ return getChannelBandwidthsOptions(false);
+ }
+ });
+
+ wifiInfo = $.extend(wifiInfo, target);
+
+ //Event Handler 频段切换时更新对应的国家/地区码、信道和网络模式选项
+ target.bandChangeHandler = function () {
+ if (target.selectedBand() == 'a') { //5g
+ //802.11a only 802.11n only 802.11a/n
+ target.modes(getModeOption(target.selectedBand()));
+ target.countries(countryCodeOption(true));
+ } else { // 2.4g
+ //802.11 n only 802.11 b/g/n
+ target.modes(getModeOption(target.selectedBand()));
+ target.countries(countryCodeOption(false));
+ }
+ target.selectedCountry('0');
+ target.channels(target.generateChannelOption());
+ target.selectedChannel('0');
+ };
+
+ target.countryChangeHandler = function (data, event) {
+ var opts = target.generateChannelOption();
+ target.channels(opts);
+ target.selectedChannel('0');
+ };
+
+ target.modeChangeHandler = function (data, event) {
+ var opts = modeRateOption(target.selectedMode());
+ target.rates(opts);
+ target.selectedRate('0');
+ };
+
+ target.generateChannelOption = function () {
+ if (target.selectedBand() == 'a') {
+ return channelOption5g(target.selectedCountry());
+ } else {
+ return channelOption(target.selectedCountry());
+ }
+ };
+
+ target.save = function () {
+ var status = getWpsState();
+ if (status.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return;
+ }
+ var selectedRateTxt = $("#rate option:selected").text();
+ var rateVal = null;
+ if (selectedRateTxt != $.i18n.prop('rate_0')) {
+ rateVal = $.trim(selectedRateTxt.replace('Mbps', ''));
+ } else {
+ rateVal = 0;
+ }
+ var wifiParam = {};
+ wifiParam.countryCode = target.selectedCountry();
+ wifiParam.mode = target.selectedMode();
+ var selectedChannel = target.selectedChannel();
+ wifiParam.channel = selectedChannel == '0' ? '0' : selectedChannel.split("_")[0];
+ wifiParam.rate = rateVal;
+ wifiParam.wifiBand = target.selectedBand();
+ if (config.WIFI_BANDWIDTH_SUPPORT) {
+ wifiParam.bandwidth = target.selectedChannelBandwidth();
+ }
+ wifiParam.station = target.selectedStation();
+ wifiParam.m_station = target.selectedStationM();
+ showConfirm('wifi_disconnect_confirm', function () {
+ showLoading('waiting');
+ service.setWifiAdvance(wifiParam, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(advanceReloadVarWifi, 15000);
+ } else {
+ addInterval(advanceReload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ });
+ };
+
+ target.checkSettings = function (ssid) {
+ var status = getWpsState();
+ if (status.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+ if (config.HAS_MULTI_SSID && baseInfo.multi_ssid_enable == "1") {
+ if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(baseInfo.m_MAX_Access_num) > baseInfo.MAX_Station_num)
+ || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(baseInfo.MAX_Access_num) > baseInfo.MAX_Station_num)) {
+ showAlert({
+ msg: 'multi_ssid_max_access_number_alert',
+ wifiParam: baseInfo.MAX_Station_num
+ });
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ target.setMultiSSIDSwitch = function () {
+ if (target.checkSettings("switch")) {
+ return;
+ }
+
+ var setSwitch = function () {
+ showLoading('waiting');
+ var wifiParam = {};
+ wifiParam.m_ssid_enable = target.multi_ssid_enable();
+ if (config.WIFI_SWITCH_SUPPORT) {
+ wifiParam.wifiEnabled = target.wifi_enable();
+ }
+ service.setWifiBasicMultiSSIDSwitch(wifiParam, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(hasApReloadVarWifi, 15000);
+ } else {
+ addInterval(hasApReload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+ var baseInfo = service.getStatusInfo();
+ if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
+ if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
+ if (!baseInfo.wifiStatus) {
+ showConfirm("multi_ssid_enable_confirm", function () {
+ setSwitch();
+ });
+ } else {
+ showConfirm("multi_ssid_enable_confirm2", function () {
+ setSwitch();
+ });
+ }
+ } else {
+ if (!baseInfo.wifiStatus) {
+ setSwitch();
+ } else {
+ showConfirm("wifi_disconnect_confirm2", function () {
+ setSwitch();
+ });
+ }
+ }
+ } else {
+ setSwitch();
+ }
+
+ function hasApReloadVarWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }
+ function hasApReload() {
+ var baseInfo = service.getWifiBasic();
+ if (baseInfo.wifi_enable == target.wifi_enable()) {
+ successOverlay();
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }
+ }
+
+ };
+
+ }
+
+ function checkAccessMode() {
+ service.getParams({
+ nv: 'user_ip_addr'
+ }, function (dataIp) {
+ service.getParams({
+ nv: 'station_list'
+ }, function (dataList) {
+ viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
+ });
+ });
+ }
+
+ function advanceReloadVarWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ }
+
+ function advanceReload() {
+ var baseInfo = service.getWifiBasic();
+ if (baseInfo.wifi_enable == "1") {
+ successOverlay();
+ clearTimer();
+ clearValidateMsg();
+ initialize();
+ }
+ }
+
+ function initialize() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var vm = new WifiAdvanceViewModel();
+ ko.applyBindings(vm, container[0]);
+ addTimeout(function () {
+ checkAccessMode();
+ }, 600);
+
+ if (config.WDS_SUPPORT) {
+ checkWifiStatusUseWDS();
+ } else if (config.AP_STATION_SUPPORT) {
+ checkWifiStatus();
+ }
+
+ $('#wifi_advance_form').validate({
+ submitHandler: function () {
+ vm.save();
+ }
+ });
+
+ $('#frmWifiSwitch').validate({
+ submitHandler: function () {
+ vm.setMultiSSIDSwitch();
+ }
+ });
+ }
+
+ function checkWifiStatusUseWDS() {
+ var baseInfo = service.getWdsInfo();
+ if (baseInfo.currentMode == "0") {
+ $(':input', '#frmWifiSwitch,#wifi_advance_form').each(function () {
+ $(this).prop("disabled", false);
+ });
+ } else {
+ $(':input', '#frmWifiSwitch,#wifi_advance_form').each(function () {
+ $(this).prop("disabled", true);
+ });
+ }
+ }
+
+ function checkWifiStatus() {
+ var baseInfo = service.getAPStationBasic();
+ if (baseInfo.ap_station_enable != "1") {
+ $(':input', '#wifi_advance_form').each(function () {
+ $(this).prop("disabled", false);
+ });
+ } else {
+ $(':input', '#wifi_advance_form').each(function () {
+ $(this).prop("disabled", true);
+ });
+ }
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("wifi_ap_station","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+ var viaWifi = false;
+ function checkAccessMode() {
+ service.getParams({
+ nv: 'user_ip_addr'
+ }, function (dataIp) {
+ service.getParams({
+ nv: 'station_list'
+ }, function (dataList) {
+ viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
+ });
+ });
+ }
+
+ function apStationViewMode() {
+ var target = this;
+ var ssid_ex = "";
+ target.hasMultiSSID = config.HAS_MULTI_SSID;
+ target.hasAPStation = config.AP_STATION_SUPPORT;
+ target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
+ target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
+
+ var securityModes = _.map(config.AUTH_MODES_ALL, function (item) {
+ return new Option(item.name, item.value);
+ });
+ //当前页面标识 list列表页 add添加页面 edit编辑页面
+ target.page = {
+ list: 1,
+ add: 2,
+ edit: 3
+ };
+ //WiFi热点列表列的配置项
+ var gridColumn = [{
+ columnType: "radio",
+ headerTextTrans: "option",
+ rowText: "profileName",
+ width: "10%"
+ }, {
+ headerTextTrans: "ssid_title",
+ rowText: "ssid",
+ width: "30%"
+ }, {
+ columnType: "image",
+ headerTextTrans: "signal",
+ rowText: "imgSignal",
+ width: "30%"
+ }, {
+ headerTextTrans: "security_mode",
+ rowText: "authMode_show",
+ width: "30%"
+ }
+ ];
+ //搜索到的WiFi热点列表列的配置项
+ var searchGridColumn = [{
+ columnType: "radio",
+ rowText: "index",
+ width: "10%"
+ }, {
+ headerTextTrans: "ssid_title",
+ rowText: "ssid",
+ width: "30%"
+ }, {
+ columnType: "image",
+ headerTextTrans: "signal",
+ rowText: "imgSignal",
+ width: "30%"
+ }, {
+ headerTextTrans: "security_mode",
+ rowText: "authMode_show",
+ width: "30%"
+ }
+ ];
+
+ target.pageState = ko.observable(target.page.list);
+
+ var info = service.getAPStationBasic();
+
+ target.origin_ap_station_enable = info.ap_station_enable;
+ target.ap_station_enable = ko.observable(info.ap_station_enable);
+ target.apList = ko.observable([]);
+ if (target.origin_ap_station_enable == "1") {
+ var apList = service.getHotspotList();
+ target.apList(fixHotspotList(apList.hotspotList));
+ }
+
+ target.apSearchList = ko.observable([]);
+
+ target.connectButtonStatus = ko.observable("disable");
+ target.hasSelectFromUser = ko.observable();
+ target.showPassword = ko.observable(false);
+
+ target.isCableMode = ko.observable();
+
+ var infoBasic = service.getWifiBasic();
+ target.wifi_enable = ko.observable(infoBasic.wifi_enable);
+
+ target.isShowSSIDInfoDiv = ko.observable(false);
+ if (config.WIFI_SWITCH_SUPPORT) {
+ if (infoBasic.wifi_enable == "1") {
+ target.isShowSSIDInfoDiv(true);
+ } else {
+ target.isShowSSIDInfoDiv(false);
+ }
+ } else {
+ target.isShowSSIDInfoDiv(true);
+ }
+ target.multi_ssid_enable = ko.observable(infoBasic.multi_ssid_enable);
+
+ //密码显示事件
+ target.showPasswordHandler = function () {
+ $("#codeWPAKey").parent().find(".error").hide();
+ $("#pwdWepKey").parent().find(".error").hide();
+ var checkbox = $("#showPassword:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showPassword(true);
+ } else {
+ target.showPassword(false);
+ }
+ };
+
+ target.showWPAPasswordHandler = function () {
+ $("#codeWPAKey").parent().find(".error").hide();
+ $("#pwdWepKey").parent().find(".error").hide();
+ if ($("#showWPAPassword").is(":checked")) {
+ target.showPassword(true);
+ } else {
+ target.showPassword(false);
+ }
+ };
+
+ //列表模板创建
+ target.apGrid = new ko.simpleGrid.viewModel({
+ idName: "profileName",
+ data: target.apList(),
+ tmplType: 'list',
+ pageSize: 100,
+ columns: gridColumn,
+ primaryColumn: "fromProvider",
+ radioClickHandler: function () {
+ computeButtonState();
+ }
+ });
+ //热点搜索结果列表模板创建
+ target.apSearchGrid = new ko.simpleGrid.viewModel({
+ data: target.apSearchList(),
+ idName: "index",
+ tmplType: 'list',
+ pageSize: 100,
+ columns: searchGridColumn,
+ radioClickHandler: function () {
+ var index = target.apSearchGrid.radioSelectValue();
+ var aplist = target.apSearchList();
+ for (var i = 0; i < aplist.length; i++) {
+ var list_item = aplist[i];
+ if (list_item.index == index) {
+ target.profileName("");
+ target.ssid(list_item.ssid);
+ ssid_ex = list_item.ssid;
+ target.signal(list_item.signal);
+ target.authMode(list_item.authMode);
+ target.password(list_item.password);
+ target.mac(list_item.mac);
+ if (list_item.authMode == "WPAPSKWPA2PSK" || list_item.authMode == "WPA2PSK" || list_item.authMode == "WPAPSK" || list_item.authMode == "WPA3Personal" || list_item.authMode == "WPA2WPA3") {
+ target.encryptType_WPA(list_item.encryptType);
+ } else {
+ target.encryptType(list_item.encryptType);
+ }
+ target.keyID(list_item.keyID);
+ renderCustomElement($("#cipherGroup"));
+ break;
+ }
+ }
+ }
+ });
+
+ //计算并设置当前连接和按钮的状态
+ target.computeConnectStatus = function () {
+ computeButtonState();
+
+ var networkStatus = target.connectStatus();
+ if (networkStatus == "ppp_connected") {
+ target.current_status_trans("ap_station_wan_connected");
+ target.current_status_text($.i18n.prop("ap_station_wan_connected"));
+ return;
+ }
+
+ var ssid = target.connectWifiSSID();
+ var wifiStatus = target.connectWifiStatus();
+ if (ssid && wifiStatus == "connect") {
+ target.current_status_trans("ap_station_wlan_connected");
+ target.current_status_text($.i18n.prop("ap_station_wlan_connected"));
+ return;
+ }
+
+ target.current_status_trans("ap_station_no_connection");
+ target.current_status_text($.i18n.prop("ap_station_no_connection"));
+ };
+ //计算并设置按钮的状态
+ function computeButtonState() {
+ var profileName = target.apGrid.radioSelectValue();
+ if (!profileName) {
+ target.hasSelectFromUser(false);
+ target.connectButtonStatus("disable");
+ return;
+ }
+
+ var status = "";
+ var fromProvider = "";
+ for (var i = 0; i < target.apList().length; i++) {
+ var list_item = target.apList()[i];
+ if (list_item.profileName == profileName) {
+ status = list_item.connectStatus;
+ fromProvider = list_item.fromProvider;
+ break;
+ }
+ }
+
+ if (status == "1") {
+ target.connectButtonStatus("hide");
+ target.hasSelectFromUser(false);
+ } else {
+ target.connectButtonStatus("show");
+ target.hasSelectFromUser(fromProvider == "0");
+ }
+ }
+ var statusInfo = service.getStatusInfo();
+ target.networkType = ko.observable(statusInfo.networkType);
+ target.networkOperator = ko.observable(statusInfo.networkOperator);
+ target.connectStatus = ko.observable(statusInfo.connectStatus);
+ target.connectWifiStatus = ko.observable(statusInfo.connectWifiStatus);
+ target.connectWifiProfile = ko.observable(statusInfo.connectWifiProfile);
+ target.connectWifiSSID = ko.observable(statusInfo.connectWifiSSID);
+
+ target.current_status_trans = ko.observable("");
+ target.current_status_text = ko.observable("");
+ target.current_status = ko.computed(function () {
+ target.computeConnectStatus()
+ });
+
+ target.modes = securityModes;
+ target.profileName = ko.observable("");
+ target.ssid = ko.observable();
+ target.signal = ko.observable("0");
+ target.authMode = ko.observable();
+ target.password = ko.observable();
+ target.encryptType = ko.observable();
+ target.encryptType_WPA = ko.observable("TKIPCCMP");
+ target.keyID = ko.observable("0");
+ target.mac = ko.observable();
+
+ target.openAddPage = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+ target.clear();
+ getSearchHotspot();
+ };
+
+ //打开基本设置页面
+ target.openListPage = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+ target.clear();
+ target.pageState(target.page.list);
+ target.apGrid.data(target.apList());
+ v.computeConnectStatus();
+ };
+
+ target.addHotspot = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+ if (target.pageState() == target.page.add && target.apList().length >= config.AP_STATION_LIST_LENGTH) {
+ showAlert({
+ msg: "ap_station_exceed_list_max",
+ params: config.AP_STATION_LIST_LENGTH
+ });
+ return;
+ }
+ showLoading('waiting');
+ var wifi_para = {};
+ var profileName = target.apGrid.radioSelectValue();
+ wifi_para.profileName = target.profileName();
+ wifi_para.ssid = target.ssid();
+ wifi_para.signal = target.signal();
+ wifi_para.authMode = target.authMode();
+ wifi_para.password = target.password();
+ if (wifi_para.authMode == "SHARED") {
+ wifi_para.encryptType = "WEP";
+ } else if (wifi_para.authMode == "WPAPSKWPA2PSK" || wifi_para.authMode == "WPA2PSK" || wifi_para.authMode == "WPAPSK" || wifi_para.authMode == "WPA3Personal" || wifi_para.authMode == "WPA2WPA3") {
+ wifi_para.encryptType = target.encryptType_WPA();
+ } else {
+ wifi_para.encryptType = target.encryptType();
+ }
+ wifi_para.keyID = target.keyID();
+ wifi_para.mac = (target.mac() == "" || target.ssid() != ssid_ex) ? "0F:00:00:00:00:00" : target.mac();
+ wifi_para.apList = target.apList();
+ service.saveHotspot(wifi_para, function (data) {
+ target.callback(data, true);
+ });
+ };
+
+ target.deleteHotspot = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+ showConfirm("confirm_data_delete", function () {
+ var wifi_para = {};
+ wifi_para.profileName = target.apGrid.radioSelectValue();
+ wifi_para.apList = target.apList();
+ showLoading('waiting');
+ service.deleteHotspot(wifi_para, function (data) {
+ target.callback(data, true);
+ });
+ });
+ };
+
+ target.openEditPage = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+ var profileName = target.apGrid.radioSelectValue();
+ var aplist = target.apList();
+ for (var i = 0; i < aplist.length; i++) {
+ var list_item = aplist[i];
+ if (list_item.profileName == profileName) {
+ target.profileName(profileName);
+ target.ssid(list_item.ssid);
+ target.signal(list_item.signal);
+ target.authMode(list_item.authMode);
+ target.password(list_item.password);
+ target.mac(list_item.mac);
+ if (list_item.authMode == "WPAPSKWPA2PSK" || list_item.authMode == "WPA2PSK" || list_item.authMode == "WPAPSK" || list_item.authMode == "WPA3Personal" || list_item.authMode == "WPA2WPA3") {
+ target.encryptType_WPA(list_item.encryptType);
+ } else {
+ target.encryptType(list_item.encryptType);
+ }
+ target.keyID(list_item.keyID);
+ }
+ }
+ target.pageState(target.page.edit);
+ };
+
+ target.connectHotspot = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+ var profileName = target.apGrid.radioSelectValue();
+ var apList = target.apList();
+
+ function connect() {
+ showLoading("connecting");
+ var wifi_para = {};
+ var connectIndex = -1;
+ var ssid = "";
+ for (var i = 0; i < apList.length; i++) {
+ if (apList[i].profileName == profileName) {
+
+ wifi_para.EX_SSID1 = apList[i].ssid;
+ wifi_para.EX_AuthMode = apList[i].authMode;
+ wifi_para.EX_EncrypType = apList[i].encryptType;
+ wifi_para.EX_DefaultKeyID = apList[i].keyID;
+ wifi_para.EX_WEPKEY = apList[i].password;
+ wifi_para.EX_WPAPSK1 = apList[i].password;
+ wifi_para.EX_wifi_profile = apList[i].profileName;
+ wifi_para.EX_mac = apList[i].mac;
+ connectIndex = i;
+ ssid = apList[i].ssid;
+ break;
+ }
+ }
+
+ target.connectWifiSSID(ssid);
+ target.connectWifiStatus("connecting");
+ target.apGrid.setRadioSelect(profileName);
+ target.connectButtonStatus("disable");
+
+ service.connectHotspot(wifi_para, function (data) {
+ if (data && data.result == "success") {
+ target.connectButtonStatus("disable");
+ //延迟检测 确保取得的状态是最新的
+ addTimeout(checkWifiStatus, 3000);
+ } else if (data && data.result == "processing") {
+ showAlert("ap_station_processing");
+ } else {
+ var apList = target.apList(); // cov_2
+ apList[connectIndex].connectStatus = "0";
+ target.connectWifiStatus("disconnect");
+ target.connectButtonStatus("show");
+ hideLoading();
+ errorOverlay();
+ }
+ var apList = service.getHotspotList();
+ target.apList(fixHotspotList(apList.hotspotList));
+ target.connectWifiProfile(profileName);
+ target.connectWifiSSID(ssid);
+ target.apGrid.data([]);
+ target.apGrid.data(target.apList());
+ target.apGrid.setRadioSelect(profileName);
+ });
+ }
+
+ //将用户选中的profile排在运营商定制profile后的第一位
+ function refreshApList(profile, aplist) {
+ var apListLeft = [];
+ var apListPre = [];
+ for (var i = 0; i < aplist.length; i++) {
+ if (aplist[i].fromProvider != "1") {
+ if (aplist[i].profileName == profile) {
+ apListPre.push(apList[i]);
+ } else {
+ apListLeft.push(apList[i]);
+ }
+ } else {
+ apListPre.push(apList[i]);
+ }
+ }
+ var apListNew = apListPre.concat(apListLeft);
+ service.saveHotspot({
+ apList: apListNew
+ }, function (data) {
+ if (data && data.result == "success") {
+ apList = apListNew;
+ target.apList(fixHotspotList(apList));
+ }
+ });
+ }
+
+ var check_count = 0;
+ var connectStatus = false;
+
+ var status = service.getStatusInfo();
+ if (status.connectStatus == "ppp_connected" || status.connectStatus == "ppp_connecting") {
+ showConfirm("ap_station_connect_change_alert", function () {
+ showLoading();
+ connect();
+ });
+ } else {
+ connect();
+ }
+
+ function checkWifiStatus() {
+ check_count = check_count + 1;
+ if (check_count > 60) {
+ hideLoading();
+ errorOverlay();
+ return;
+ }
+ if (!connectStatus) {
+ var status = service.getStatusInfo();
+ if (status.connectWifiStatus != "connect") {
+ addTimeout(checkWifiStatus, 1000);
+ } else {
+ connectStatus = true;
+ }
+ }
+ if (connectStatus) {
+ //继续判断profile中连接状态是否为1
+ service.getHotspotList({}, function (data) {
+ for (var i = 0, len = data.hotspotList.length; i < len; i++) {
+ var list_item = data.hotspotList[i];
+ if (list_item.profileName == profileName) {
+ if (list_item.connectStatus == "1") {
+ hideLoading();
+ return;
+ } else {
+ var errorMsg = {
+ msg: 'ap_connect_error',
+ params: [list_item.ssid]
+ };
+ showAlert(errorMsg);
+ return;
+ }
+ break;
+ }
+ }
+ addTimeout(checkWifiStatus, 1000);
+ });
+ }
+ }
+
+ };
+
+ target.disconnectHotspot = function () {
+ if (wpsIsOn()) {
+ return;
+ }
+ showLoading('disconnecting');
+ service.disconnectHotspot({}, function (data) {
+ target.callback(data, true);
+ })
+ };
+
+ function getSearchHotspot() {
+ var check_count = 0;
+
+ function search() {
+ var result = service.getSearchHotspotList();
+ if (result.scan_finish == "0") {
+ if (check_count <= 60) {
+ check_count = check_count + 1;
+ addTimeout(search, 1000);
+ } else {
+ hideLoading();
+ showAlert("ap_station_search_hotspot_fail");
+ }
+ } else {
+ if ("2" == result.scan_finish) {
+ hideLoading();
+ showAlert("ap_station_processing");
+ } else {
+ target.apSearchList(fixHotspotList(result.hotspotList));
+ target.apSearchGrid.data(target.apSearchList());
+ hideLoading();
+ }
+ }
+ }
+
+ showLoading('scanning');
+ service.searchHotspot({}, function (data) {
+ if (data && data.result == "processing") {
+ hideLoading();
+ showAlert("ap_station_processing");
+ } else if (data && data.result == "success") {
+ if (target.pageState() != target.page.add) {
+ target.pageState(target.page.add);
+ }
+ search();
+ } else {
+ if (target.pageState() != target.page.add) {
+ target.pageState(target.page.add);
+ }
+ hideLoading();
+ showAlert("ap_station_search_hotspot_fail");
+ }
+ });
+ }
+
+ //清除编辑页面的信息
+ target.clear = function () {
+ target.apSearchGrid.clearRadioSelect();
+ target.profileName("");
+ target.ssid("");
+ target.signal("0");
+ target.authMode("OPEN");
+ target.password("");
+ target.encryptType("NONE");
+ target.encryptType_WPA("TKIPCCMP");
+ target.keyID("0");
+ target.mac("");
+ };
+
+ target.apply = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+
+ function setBasic() {
+ showLoading('waiting');
+ var wifi_para = {};
+ wifi_para.ap_station_enable = target.ap_station_enable();
+ service.setAPStationBasic(wifi_para, function (data) {
+ if (target.origin_ap_station_enable == target.ap_station_enable()) {
+ target.callback(data, true);
+ } else {
+ target.callback2(data, true);
+ }
+ });
+ service.refreshAPStationStatus();
+ }
+ if (!config.HAS_MULTI_SSID) {
+ setBasic();
+ } else {
+ var infoBasic = service.getWifiBasic();
+ if (target.ap_station_enable() == "1" && infoBasic.multi_ssid_enable == "1") {
+ showConfirm("ap_station_enable_confirm", setBasic);
+ } else {
+ setBasic();
+ }
+ }
+ };
+ //刷新搜到的热点列表
+ target.searchHotspot = function () {
+ if (wifiIsClosed()) {
+ return;
+ }
+ if (wpsIsOn()) {
+ return;
+ }
+ getSearchHotspot();
+ };
+ //和webserver交互时的回调,wifi不重启的情况
+ target.callback = function (data, isInitPage) {
+ if (data) {
+ if (isInitPage) {
+ initialize();
+ $("#apList").translate();
+ }
+ if (data.result == "processing") {
+ showAlert("ap_station_processing");
+ } else if (data.result == "spot_connected" || data.result == "spot_connecting") {
+ showAlert("ap_station_update_fail");
+ } else if (data.result == "success") {
+ successOverlay();
+ } else if (data.result == "exist") {
+ showAlert("ap_station_exist");
+ } else {
+ errorOverlay();
+ }
+ } else {
+ errorOverlay();
+ }
+ }
+
+ //和webserver交互时的回调,wifi会重启的情况
+ target.callback2 = function (data, isInitPage) {
+ if (data) {
+ if (!viaWifi) { //通过wifi登录webui
+ addInterval(function () {
+ var info = service.getWifiBasic();
+ if (info.wifi_enable == "1") {
+ clearTimer();
+ clearValidateMsg();
+ initialize();
+ $("#apList").translate();
+ if (data.result == "spot_connected" || data.result == "spot_connecting") {
+ showAlert("ap_station_update_fail");
+ } else if (data.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }
+ }, 1000);
+ } else {
+ setTimeout(function () {
+ if (data.result == "processing") {
+ showAlert("ap_station_processing");
+ } else if (data.result == "spot_connecting" || data.result == "spot_connected") {
+ showAlert("ap_station_update_fail");
+ } else if (data.result == "success") {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ clearTimer();
+ clearValidateMsg();
+ initialize();
+ } else {
+ errorOverlay();
+ }
+ }, 15000);
+ }
+ } else {
+ errorOverlay();
+ }
+ };
+
+ target.checkSettings = function (ssid) {
+ var status = service.getWpsInfo();
+ if (status.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+ if (config.HAS_MULTI_SSID && info.multi_ssid_enable == "1") {
+ if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)
+ || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)) {
+ showAlert({
+ msg: 'multi_ssid_max_access_number_alert',
+ params: info.MAX_Station_num
+ });
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ target.setMultiSSIDSwitch = function () {
+ if (target.checkSettings("switch")) {
+ return;
+ }
+
+ var setSwitch = function () {
+ showLoading('waiting');
+ var params = {};
+ params.m_ssid_enable = target.multi_ssid_enable();
+ if (config.WIFI_SWITCH_SUPPORT) {
+ params.wifiEnabled = target.wifi_enable();
+ }
+ service.setWifiBasicMultiSSIDSwitch(params, function (result) {
+ if (result.result == "success") {
+ if (!viaWifi) {
+ addInterval(function () {
+ var info = service.getWifiBasic();
+ if (info.wifi_enable == target.wifi_enable()) {
+ successOverlay();
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }
+ }, 1000);
+ } else {
+ setTimeout(function () {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }, 15000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+ var info = service.getStatusInfo();
+ if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
+ if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
+ if (!info.wifiStatus) {
+ showConfirm("multi_ssid_enable_confirm", function () {
+ setSwitch();
+ });
+ } else {
+ showConfirm("multi_ssid_enable_confirm2", function () {
+ setSwitch();
+ });
+ }
+ } else {
+ if (!info.wifiStatus) {
+ setSwitch();
+ } else {
+ showConfirm("wifi_disconnect_confirm2", function () {
+ setSwitch();
+ });
+ }
+ }
+ } else {
+ setSwitch();
+ }
+ };
+
+ }
+
+ function wpsIsOn() {
+ var wifi_info = service.getWpsInfo();
+ if (wifi_info.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+ }
+
+ //处理热点列表内容,以便在表格显示
+ function fixHotspotList(list) {
+ var fixedList = [];
+ for (var ii = 0; ii < list.length; ii++) {
+ list[ii].index = ii;
+ var url_image = "";
+ if (list[ii].connectStatus != "1") {
+ if (list[ii].encryptType.toLowerCase() == "none" && list[ii].authMode.toLowerCase() == "open") {
+ url_image = "pic/wlan_signal_" + list[ii].signal + ".png";
+ } else {
+ url_image = "pic/wlan_lock_signal_" + list[ii].signal + ".png";
+ }
+ } else {
+ if (list[ii].encryptType.toLowerCase() == "none" && list[ii].authMode.toLowerCase() == "open") {
+ url_image = "pic/wlan_connected.png";
+ } else {
+ url_image = "pic/wlan_lock_connected.png";
+ }
+ }
+ list[ii].imgSignal = url_image;
+ list[ii].authMode_show = $.i18n.prop("ap_station_security_mode_" + list[ii].authMode);
+ }
+ return list;
+ }
+
+ function wifiIsClosed() {
+ var wifi_info = service.getWpsInfo();
+ if (wifi_info.radioFlag == "0") {
+ showAlert('wps_wifi_off');
+ return true;
+ }
+ }
+
+ function event_bind(aps_vm) {
+ $("#showWPAPassword").change(function () {
+ aps_vm.showWPAPasswordHandler();
+ });
+ $("#showPassword").change(function () {
+ aps_vm.showPasswordHandler();
+ });
+ }
+
+ function initialize() {
+ var aps_vm = new apStationViewMode();
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ ko.applyBindings(aps_vm, container);
+ event_bind(aps_vm);
+
+ aps_refresh(true);
+ clearTimer();
+ addInterval(function () {
+ aps_refresh(false);
+ checkAccessMode();
+ }, 1000);
+
+ $('#frmWifiSwitch').validate({
+ submitHandler: function () {
+ aps_vm.setMultiSSIDSwitch();
+ }
+ });
+
+ $("#frmAPStation").validate({
+ submitHandler: function () {
+ aps_vm.addHotspot();
+ },
+ rules: {
+ txtSSID: "ssid_ap"
+ },
+ errorPlacement: function (error, element) {
+ var id = element.attr("id");
+ if (id == "txtWPAKey" || id == "codeWPAKey") {
+ error.insertAfter("#lblshowWPAPassword");
+ } else if (id == "txtWepKey" || id == "pwdWepKey") {
+ error.insertAfter("#lblShowPassword");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+
+ function aps_refresh(initPage) {
+ var info = service.getStatusInfo();
+ if (info.multi_ssid_enable != "1") {
+ aps_vm.isCableMode(checkCableMode(info.blc_wan_mode));
+ aps_vm.connectWifiProfile(info.connectWifiProfile);
+ aps_vm.connectWifiSSID(info.connectWifiSSID);
+ aps_vm.connectWifiStatus(info.connectWifiStatus);
+ aps_vm.networkType(info.networkType);
+ aps_vm.connectStatus(info.connectStatus);
+ aps_vm.computeConnectStatus();
+
+ service.getHotspotList({}, function (data) {
+ var list = fixHotspotList(data.hotspotList);
+ aps_vm.apList(list);
+ var gripList = aps_vm.apGrid.data();
+ if (list.length > 0 && list[0].profileName != gripList[0].profileName && list[0].connectStatus == "1") {
+ aps_vm.apGrid.data([]);
+ aps_vm.apGrid.data(aps_vm.apList());
+ aps_vm.apGrid.setRadioSelect(list[0].profileName);
+ }
+ renderCustomElement($("#apList"));
+ var radios = $("input[type='radio']", "#apList").each(function () {
+ for (var i = 0, len = list.length; i < len; i++) {
+ if (list[i].profileName == $(this).val()) {
+ var img = $(this).parent().parent().find("img")[0];
+ img.src = list[i].imgSignal;
+ if (initPage) {
+ if (list[i].connectStatus == "1") {
+ aps_vm.hasSelectFromUser(false);
+ aps_vm.connectButtonStatus("disable");
+ }
+ }
+ }
+ }
+ });
+ });
+ } else {
+ //to do
+ }
+ }
+
+ }
+
+ return {
+ init: initialize
+ }
+});
+
+define("wifi_guest","underscore jquery knockout set service CryptoJS".split(" "),
+
+ function (_, $, ko, config, service, CryptoJS) {
+
+ var viaWifi = false;
+ function checkAccessMode() {
+ service.getParams({
+ nv: 'user_ip_addr'
+ }, function (dataIp) {
+ service.getParams({
+ nv: 'station_list'
+ }, function (dataList) {
+ viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
+ });
+ });
+ }
+
+ var securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
+ return new Option(item.name, item.value);
+ });
+
+ function maxStationAccess(max) {
+ var showOption = [];
+ for (var i = 1; i <= max; i++) {
+ showOption.push(new Option(i, i));
+ }
+ return showOption;
+ }
+
+ function wifiGuestVM() {
+ var target = this;
+ var info = service.getWifiBasic();
+
+ target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
+ target.hasMultiSSID = config.HAS_MULTI_SSID;
+ target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;
+ target.hasAPStation = config.AP_STATION_SUPPORT;
+ target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
+ target.hasWifiWep = config.WIFI_WEP_SUPPORT;
+ target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
+ target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
+
+ var advanceInfo = service.getWifiAdvance();
+ target.adBand = ko.observable(advanceInfo.wifiBand);
+ target.adMode = ko.observable(advanceInfo.mode);
+
+ target.showQRSwitch = config.WIFI_SUPPORT_QR_CODE && config.WIFI_SUPPORT_QR_SWITCH;
+ target.showQR = ko.observable(info.m_show_qrcode_flag);
+ if (config.WIFI_SUPPORT_QR_SWITCH) {
+ target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE && target.showQR());
+ } else {
+ target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE);
+ }
+ if(config.WIFI_SUPPORT_QR_CODE){
+ target.qrcodeSrc = './pic/qrcode_multi_ssid_wifikey.png?_=' + $.now();
+ } else {
+ target.qrcodeSrc = './pic/res_blacktrans.png';
+ }
+ target.origin_ap_station_enable = info.ap_station_enable;
+ target.wifi_enable = ko.observable(info.wifi_enable);
+ target.isShowSSIDInfoDiv = ko.observable(false);
+ if (config.WIFI_SWITCH_SUPPORT) {
+ if (info.wifi_enable == "1") {
+ target.isShowSSIDInfoDiv(true);
+ } else {
+ target.isShowSSIDInfoDiv(false);
+ }
+ } else {
+ target.isShowSSIDInfoDiv(true);
+ }
+
+ target.multi_ssid_enable = ko.observable(info.multi_ssid_enable);
+ target.origin_multi_ssid_enable = info.multi_ssid_enable;
+
+ target.maxStationNumber = ko.computed(function () {
+ return config.MAX_STATION_NUMBER;
+ });
+
+ target.modes = ko.observableArray(securityModes);
+ target.selectedMode = ko.observable(info.AuthMode);
+ target.passPhrase = ko.observable(info.passPhrase);
+ target.showPassword = ko.observable(false);
+ target.ssid = ko.observable(info.SSID);
+ target.broadcast = ko.observable(info.broadcast == '1' ? '1' : '0');
+ target.apIsolation = ko.observable(info.apIsolation == '1' ? '1' : '0');
+ target.cipher = info.cipher;
+ target.selectedStation = ko.observable(info.MAX_Access_num);
+ target.maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
+
+ target.m_modes = ko.observableArray(securityModes);
+ target.m_selectedMode = ko.observable(info.m_AuthMode);
+ target.m_passPhrase = ko.observable(info.m_passPhrase);
+ target.m_showPassword = ko.observable(false);
+ target.m_ssid = ko.observable(info.m_SSID);
+ target.m_broadcast = ko.observable(info.m_broadcast == '1' ? '1' : '0');
+ target.m_apIsolation = ko.observable(info.m_apIsolation == '1' ? '1' : '0');
+ target.m_cipher = info.m_cipher;
+ target.m_selectedStation = ko.observable(info.m_MAX_Access_num);
+ target.m_maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
+ target.m_encryptType = ko.observable(info.m_encryptType);
+ target.m_keyID = ko.observable(info.m_keyID);
+ target.m_wepPassword = ko.observable("");
+
+ //刷新界面状态值显示
+ target.clear = function (option) {
+ if (option == "switch") {
+ target.multi_ssid_enable(info.multi_ssid_enable);
+ target.wifi_enable(info.wifi_enable);
+ } else if (option == "ssid1") {
+ target.selectedMode(info.AuthMode);
+ target.passPhrase(info.passPhrase);
+ target.ssid(info.SSID);
+ target.broadcast(info.broadcast == '1' ? '1' : '0');
+ target.cipher = info.cipher;
+ target.selectedStation(info.MAX_Access_num);
+ target.apIsolation(info.apIsolation == '1' ? '1' : '0');
+ } else if (option == "ssid2") {
+ target.m_selectedMode(info.m_AuthMode);
+ target.m_passPhrase(info.m_passPhrase);
+ target.m_ssid(info.m_SSID);
+ target.m_broadcast(info.m_broadcast == '1' ? '1' : '0');
+ target.m_cipher = info.m_cipher;
+ target.m_selectedStation(info.m_MAX_Access_num);
+ target.m_apIsolation(info.m_apIsolation == '1' ? '1' : '0');
+ if (config.WIFI_WEP_SUPPORT) {
+ target.m_encryptType(info.m_encryptType);
+ target.m_keyID(info.m_keyID);
+ target.m_wepPassword(target.getWepPassword());
+ }
+ } else {
+ clearTimer();
+ clearValidateMsg();
+ initialize();
+ service.refreshAPStationStatus();
+ }
+ };
+
+ target.getWepPassword = function () {
+ return target.m_keyID() == '3' ? info.m_Key4Str1 : (target.m_keyID() == '2' ? info.m_Key3Str1 : target.m_keyID() == '1' ? info.m_Key2Str1 : info.m_Key1Str1);
+ }
+ target.m_wepPassword(target.getWepPassword());
+ //WEP加密模式下网络秘钥切换事件
+ target.profileChangeHandler = function (data, event) {
+ $("#pwdWepKey").parent().find("label[class='error']").hide();
+ target.m_wepPassword(target.getWepPassword());
+ return true;
+ };
+
+ target.saveSSID1 = function () {
+ if (target.checkSettings("ssid1")) {
+ return;
+ }
+ showConfirm('wifi_disconnect_confirm', function () {
+ target.saveSSID1Action();
+ });
+ };
+ target.saveSSID1Action = function () {
+ showLoading('waiting');
+ target.broadcast($("#broadcastCheckbox:checked").length > 0 ? '0' : '1');
+ target.apIsolation($("#apisolatedCheckbox:checked").length);
+ var params = {};
+ params.AuthMode = target.selectedMode();
+ params.passPhrase = target.passPhrase();
+ params.SSID = target.ssid();
+ params.broadcast = target.broadcast();
+ params.station = target.selectedStation();
+ params.cipher = target.selectedMode() == "WPA2PSK" ? 1 : 2;
+ if (params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {
+ params.cipher = 1;
+ }
+ params.NoForwarding = target.apIsolation();
+ params.show_qrcode_flag = target.showQR() == true ? 1 : 0;
+ service.setWifiBasic(params, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(guestReloadVarWifi, 15000);
+ } else {
+ addInterval(guestReload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+ target.saveSSID2 = function () {
+ if (target.checkSettings("ssid2")) {
+ return;
+ }
+ if (!config.PASSWORD_ENCODE) {
+ var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
+ if (!pwdRegex.test(target.m_passPhrase())) {
+ showConfirm("password_note_too_low", function () {
+ showConfirm('wifi_disconnect_confirm', function () {
+ target.saveSSID2Action();
+ return;
+ });
+ return;
+ });
+ return;
+ }
+ }
+ showConfirm('wifi_disconnect_confirm', function () {
+ target.saveSSID2Action();
+ });
+ };
+ target.saveSSID2Action = function () {
+ showLoading('waiting');
+ target.m_broadcast($("#mBroadcastCheckbox:checked").length > 0 ? '0' : '1');
+ target.m_apIsolation($("#mApIsolatedCheckbox:checked").length);
+ var ciphertext = "";
+ if (config.PASSWORD_ENCODE) {
+ ciphertext = target.m_passPhrase();
+ } else {
+ var kparam = service.getDeviceInfoLow();
+ var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
+ var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
+ ciphertext = CryptoJS.AES.encrypt(target.m_passPhrase(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+ }
+ var params = {};
+ params.m_AuthMode = target.m_selectedMode();
+ params.m_passPhrase = ciphertext;
+ params.m_SSID = target.m_ssid();
+ params.m_broadcast = target.m_broadcast();
+ params.m_station = target.m_selectedStation();
+ params.m_cipher = target.m_selectedMode() == "WPA2PSK" ? 1 : 2;
+ if (params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {
+ params.m_cipher = 1;
+ }
+ params.m_NoForwarding = target.m_apIsolation();
+ params.m_show_qrcode_flag = target.showQR() == true ? 1 : 0;
+
+ if (config.WIFI_WEP_SUPPORT) {
+ if (params.m_AuthMode == "SHARED") {
+ params.m_encryptType = "WEP";
+ } else if (params.m_AuthMode == "WPAPSKWPA2PSK" || params.m_AuthMode == "WPA2PSK" || params.m_AuthMode == "WPAPSK" || params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {
+ //params.m_encryptType = target.m_encryptType_WPA();
+ } else {
+ params.m_encryptType = target.m_encryptType();
+ }
+ params.m_wep_default_key = target.m_keyID();
+ params.m_wep_key_4 = info.m_Key4Str1;
+ params.m_wep_key_3 = info.m_Key3Str1;
+ params.m_wep_key_2 = info.m_Key2Str1;
+ params.m_wep_key_1 = info.m_Key1Str1;
+ var mWEPSelect = '0';
+ if (target.m_wepPassword().length == '13' || target.m_wepPassword().length == '5') {
+ mWEPSelect = '1';
+ } else {
+ mWEPSelect = '0';
+ }
+ if (target.m_keyID() == '3') {
+ params.m_wep_key_4 = target.m_wepPassword();
+ params.m_WEP4Select = mWEPSelect;
+ } else if (target.m_keyID() == '2') {
+ params.m_wep_key_3 = target.m_wepPassword();
+ params.m_WEP3Select = mWEPSelect;
+ } else if (target.m_keyID() == '1') {
+ params.m_wep_key_2 = target.m_wepPassword();
+ params.m_WEP2Select = mWEPSelect;
+ } else {
+ params.m_wep_key_1 = target.m_wepPassword();
+ params.m_WEP1Select = mWEPSelect;
+ }
+ }
+
+ service.setWifiBasic4SSID2(params, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(ssid2ReloadVarWifi, 15000);
+ } else {
+ addInterval(ssid2Reload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+ function guestReloadVarWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ target.clear();
+ }
+ function guestReload() {
+ var info = getWifiMain();
+ if (info.wifi_enable == "1") {
+ successOverlay();
+ target.clear();
+ }
+ }
+ function ssid2ReloadVarWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ target.clear();
+ }
+ function ssid2Reload() {
+ var info = getWifiMain();
+ if (info.wifi_enable == "1") {
+ successOverlay();
+ target.clear();
+ }
+ }
+
+ target.checkSettings = function (ssid) {
+ var status = getWpsState();
+
+ if (config.HAS_MULTI_SSID) {
+ if (ssid == "ssid1" || ssid == "ssid2") {
+ if (ssid == "ssid2") {
+ var accessDevice = service.getStatusInfo().ssid2AttachedNum;
+ if (parseInt(target.m_selectedStation()) < accessDevice) {
+ showAlert('Extend_accessDevice');
+ return true;
+ }
+ } else {
+ var accessDevice = service.getStatusInfo().ssid1AttachedNum;
+ if (parseInt(target.selectedStation()) < accessDevice) {
+ showAlert('Extend_accessDevice');
+ return true;
+ }
+ }
+ }
+ }
+
+ if (status.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+ if (config.HAS_MULTI_SSID && info.multi_ssid_enable == "1") {
+ if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)
+ || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)) {
+ showAlert({
+ msg: 'multi_ssid_max_access_number_alert',
+ params: info.MAX_Station_num
+ });
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ target.setMultiSSIDSwitch = function () {
+ if (target.checkSettings("switch")) {
+ return;
+ }
+
+ var setSwitch = function () {
+ showLoading('waiting');
+ var params = {};
+ params.m_ssid_enable = target.multi_ssid_enable();
+ if (config.WIFI_SWITCH_SUPPORT) {
+ params.wifiEnabled = target.wifi_enable();
+ }
+ service.setWifiBasicMultiSSIDSwitch(params, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(multiReloadViaWifi, 15000);
+ } else {
+ addInterval(multiReload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+ function multiReloadViaWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ target.clear();
+ }
+ function multiReload() {
+ var info = getWifiMain();
+ if (info.wifi_enable == target.wifi_enable()) {
+ successOverlay();
+ target.clear();
+ }
+ }
+ var info = service.getStatusInfo();
+ if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
+ if (config.AP_STATION_SUPPORT && target.multi_ssid_enable() == "1" && target.origin_ap_station_enable == "1") {
+ if (!info.wifiStatus) {
+ showConfirm("multi_ssid_enable_confirm", function () {
+ setSwitch();
+ });
+ } else {
+ showConfirm("multi_ssid_enable_confirm2", function () {
+ setSwitch();
+ });
+ }
+ } else {
+ if (!info.wifiStatus) {
+ setSwitch();
+ } else {
+ showConfirm("wifi_disconnect_confirm2", function () {
+ setSwitch();
+ });
+ }
+ }
+ } else {
+ setSwitch();
+ }
+ };
+ target.showQRHandler = function () {
+ var checkbox = $("#showQR:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showQR(true);
+ } else {
+ target.showQR(false);
+ }
+ target.showQRCode(config.WIFI_SUPPORT_QR_CODE && target.showQR());
+ };
+
+ target.showPasswordHandler = guestShowPassword;
+
+ target.m_showPasswordHandler = m_guestShowPassword;
+
+ function guestShowPassword() {
+ $("#passShow").parent().find(".error").hide();
+ var checkbox = $("#showPassword:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showPassword(true);
+ } else {
+ target.showPassword(false);
+ }
+ }
+ function m_guestShowPassword() {
+ $("#m_passShow").parent().find(".error").hide();
+ $("#m_pwdWepKey").parent().find(".error").hide();
+ var checkbox = $("#m_showPassword:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.m_showPassword(true);
+ } else {
+ target.m_showPassword(false);
+ }
+ }
+
+ }
+
+ function getWifiMain() {
+ return service.getWifiBasic();
+ }
+
+ function initialize() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var vm = new wifiGuestVM();
+ ko.applyBindings(vm, container[0]);
+ addTimeout(function () {
+ checkAccessMode();
+ }, 600);
+
+ function checkWifiStatus() {
+ var info = service.getAPStationBasic();
+ if (info.ap_station_enable != "1") {
+ $('#frmMultiSSID :input').each(function () {
+ $(this).attr("disabled", false);
+ });
+ } else {
+ $('#frmMultiSSID :input').each(function () {
+ $(this).attr("disabled", true);
+ });
+ }
+ }
+
+ function checkWifiStatusAccordingToWDS() {
+ var info = service.getWdsInfo();
+ if (info.currentMode == "0") {
+ $('#frmWifiSwitch :input').each(function () {
+ $(this).attr("disabled", false);
+ });
+ $('#frmSSID2 :input').each(function () {
+ $(this).attr("disabled", false);
+ });
+ $('#frmSSID1 :input').each(function () {
+ $(this).attr("disabled", false);
+ });
+ } else {
+ $('#frmWifiSwitch :input').each(function () {
+ $(this).attr("disabled", true);
+ });
+ $('#frmSSID2 :input').each(function () {
+ $(this).attr("disabled", true);
+ });
+ $('#frmSSID1 :input').each(function () {
+ $(this).attr("disabled", true);
+ });
+ }
+ }
+
+ if (config.WDS_SUPPORT) {
+ checkWifiStatusAccordingToWDS();
+ } else if (config.AP_STATION_SUPPORT) {
+ checkWifiStatus();
+ }
+
+ $('#frmMultiSSID').validate({
+ submitHandler: function () {
+ vm.setMultiSSIDSwitch();
+ }
+ });
+ $('#frmWifiSwitch').validate({
+ submitHandler: function () {
+ vm.setMultiSSIDSwitch();
+ }
+ });
+ $('#frmSSID2').validate({
+ submitHandler: function () {
+ vm.saveSSID2();
+ },
+ rules: {
+ m_ssid: 'ssid',
+ m_pwdWepKey: {
+ wifi_wep_password_check: true,
+ wifi_password_check: true
+ },
+ m_txtWepKey: {
+ wifi_wep_password_check: true,
+ wifi_password_check: true
+ },
+ m_pass: 'wifi_password_check',
+ m_passShow: 'wifi_password_check'
+ },
+ errorPlacement: function (error, element) {
+ var id = element.attr("id");
+ if (id == "m_passShow" || id == "m_pass") {
+ error.insertAfter("#m_lblShowPassword");
+ } else if (id == "m_txtWepKey" || id == "m_pwdWepKey") {
+ error.insertAfter("#m_lblShowWepPassword");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+ $('#frmSSID1').validate({
+ submitHandler: function () {
+ vm.saveSSID1();
+ },
+ rules: {
+ pass: 'wifi_password_check',
+ ssid: 'ssid',
+ passShow: 'wifi_password_check'
+ },
+ errorPlacement: function (error, element) {
+ var id = element.attr("id");
+ if (id == "passShow" || id == "pass") {
+ error.insertAfter("#lblShowPassword");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+
+ }
+
+ function getWpsState() {
+ return service.getWpsInfo();
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("wifi_mac_filter","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var viaWifi = false;
+ function checkAccessMode() {
+ service.getParams({
+ nv: 'user_ip_addr'
+ }, function (dataIp) {
+ service.getParams({
+ nv: 'station_list'
+ }, function (dataList) {
+ viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
+ });
+ });
+ }
+
+ function macFilterViewModel() {
+ var target = this;
+ target.hasAPStation = config.AP_STATION_SUPPORT;
+ target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
+ target.hasMultiSSID = config.HAS_MULTI_SSID;
+ target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;
+
+ var info = service.getMacFilterInfo();
+ var wifiBaseInfo = service.getWifiBasic();
+ target.multi_ssid_enable = ko.observable(wifiBaseInfo.multi_ssid_enable);
+ target.origin_ap_station_enable = wifiBaseInfo.ap_station_enable;
+ target.wifi_enable = ko.observable(wifiBaseInfo.wifi_enable);
+
+ target.isShowSSIDInfoDiv = ko.observable(false);
+ if (config.WIFI_SWITCH_SUPPORT) {
+ if (wifiBaseInfo.wifi_enable == "1") {
+ target.isShowSSIDInfoDiv(true);
+ } else {
+ target.isShowSSIDInfoDiv(false);
+ }
+ } else {
+ target.isShowSSIDInfoDiv(true);
+ }
+
+ target.selectedAction = ko.observable(info.ACL_mode);
+ target.mac1 = ko.observable("");
+ target.mac2 = ko.observable("");
+ target.mac3 = ko.observable("");
+ target.mac4 = ko.observable("");
+ target.mac5 = ko.observable("");
+ target.mac6 = ko.observable("");
+ target.mac7 = ko.observable("");
+ target.mac8 = ko.observable("");
+ target.mac9 = ko.observable("");
+ target.mac10 = ko.observable("");
+ if (info.ACL_mode == "1") {
+ macInfoWhite = info.wifi_mac_white_list.split(";");
+ target.mac1 = ko.observable(macInfoWhite[0]);
+ target.mac2 = ko.observable(macInfoWhite[1]);
+ target.mac3 = ko.observable(macInfoWhite[2]);
+ target.mac4 = ko.observable(macInfoWhite[3]);
+ target.mac5 = ko.observable(macInfoWhite[4]);
+ target.mac6 = ko.observable(macInfoWhite[5]);
+ target.mac7 = ko.observable(macInfoWhite[6]);
+ target.mac8 = ko.observable(macInfoWhite[7]);
+ target.mac9 = ko.observable(macInfoWhite[8]);
+ target.mac10 = ko.observable(macInfoWhite[9]);
+ } else if (info.ACL_mode == "2") {
+ macInfoBlack = info.wifi_mac_black_list.split(";");
+ target.mac1 = ko.observable(macInfoBlack[0]);
+ target.mac2 = ko.observable(macInfoBlack[1]);
+ target.mac3 = ko.observable(macInfoBlack[2]);
+ target.mac4 = ko.observable(macInfoBlack[3]);
+ target.mac5 = ko.observable(macInfoBlack[4]);
+ target.mac6 = ko.observable(macInfoBlack[5]);
+ target.mac7 = ko.observable(macInfoBlack[6]);
+ target.mac8 = ko.observable(macInfoBlack[7]);
+ target.mac9 = ko.observable(macInfoBlack[8]);
+ target.mac10 = ko.observable(macInfoBlack[9]);
+ }
+
+ target.save = filter_save;
+ //切换MAC过滤规则事件
+ target.ChangeHandler = function () {
+ $("#mac_filter_form").find(".error").hide();
+ $("#mac_filter_form").find("input[type=text]").show();
+ var info = service.getMacFilterInfo();
+ if (target.selectedAction() == "1") {
+ macInfoWhite = info.wifi_mac_white_list.split(";");
+ target.mac1(macInfoWhite[0]);
+ target.mac2(macInfoWhite[1]);
+ target.mac3(macInfoWhite[2]);
+ target.mac4(macInfoWhite[3]);
+ target.mac5(macInfoWhite[4]);
+ target.mac6(macInfoWhite[5]);
+ target.mac7(macInfoWhite[6]);
+ target.mac8(macInfoWhite[7]);
+ target.mac9(macInfoWhite[8]);
+ target.mac10(macInfoWhite[9]);
+ } else if (target.selectedAction() == "2") {
+ macInfoBlack = info.wifi_mac_black_list.split(";");
+ target.mac1(macInfoBlack[0]);
+ target.mac2(macInfoBlack[1]);
+ target.mac3(macInfoBlack[2]);
+ target.mac4(macInfoBlack[3]);
+ target.mac5(macInfoBlack[4]);
+ target.mac6(macInfoBlack[5]);
+ target.mac7(macInfoBlack[6]);
+ target.mac8(macInfoBlack[7]);
+ target.mac9(macInfoBlack[8]);
+ target.mac10(macInfoBlack[9]);
+ } else {
+ target.mac1("");
+ target.mac2("");
+ target.mac3("");
+ target.mac4("");
+ target.mac5("");
+ target.mac6("");
+ target.mac7("");
+ target.mac8("");
+ target.mac9("");
+ target.mac10("");
+ }
+ }
+ //检查WPS状态
+ target.checkSettings = function (ssid) {
+ var wifi_status = service.getWpsInfo();
+ if (wifi_status.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+ return false;
+ };
+
+ //设置多SSID开关
+ target.setMultiSSIDSwitch = function () {
+ if (target.checkSettings("switch")) {
+ return;
+ }
+
+ var setSwitch = setFilterSwitch;
+
+ var info = service.getStatusInfo();
+ if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
+ if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
+ if (!info.wifiStatus) {
+ showConfirm("multi_ssid_enable_confirm", function () {
+ setSwitch();
+ });
+ } else {
+ showConfirm("multi_ssid_enable_confirm2", function () {
+ setSwitch();
+ });
+ }
+ } else {
+ if (!info.wifiStatus) {
+ setSwitch();
+ } else {
+ showConfirm("wifi_disconnect_confirm2", function () {
+ setSwitch();
+ });
+ }
+ }
+ } else {
+ setSwitch();
+ }
+
+ function setFilterSwitch() {
+ showLoading('waiting');
+ var filter_param = {};
+ filter_param.m_ssid_enable = target.multi_ssid_enable();
+ if (config.WIFI_SWITCH_SUPPORT) {
+ filter_param.wifiEnabled = target.wifi_enable();
+ }
+ service.setWifiBasicMultiSSIDSwitch(filter_param, function (result) {
+ if (result.result == "success") {
+ if (!viaWifi) {
+ addInterval(function () {
+ var info = service.getWifiBasic();
+ service.refreshAPStationStatus();
+ if (info.wifi_enable == target.wifi_enable()) {
+ successOverlay();
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }
+ }, 1000);
+ } else {
+ setTimeout(function () {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }, 15000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+ };
+
+ function filter_save() {
+ var wifi_status = service.getWpsInfo();
+ if (wifi_status.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+
+ if (target.mac1() == undefined || target.mac1().indexOf(" ") >= 0) {
+ target.mac1("")
+ }
+ if (target.mac2() == undefined || target.mac2().indexOf(" ") >= 0) {
+ target.mac2("")
+ }
+ if (target.mac3() == undefined || target.mac3().indexOf(" ") >= 0) {
+ target.mac3("")
+ }
+ if (target.mac4() == undefined || target.mac4().indexOf(" ") >= 0) {
+ target.mac4("")
+ }
+ if (target.mac5() == undefined || target.mac5().indexOf(" ") >= 0) {
+ target.mac5("")
+ }
+ if (target.mac6() == undefined || target.mac6().indexOf(" ") >= 0) {
+ target.mac6("")
+ }
+ if (target.mac7() == undefined || target.mac7().indexOf(" ") >= 0) {
+ target.mac7("")
+ }
+ if (target.mac8() == undefined || target.mac8().indexOf(" ") >= 0) {
+ target.mac8("")
+ }
+ if (target.mac9() == undefined || target.mac9().indexOf(" ") >= 0) {
+ target.mac9("")
+ }
+ if (target.mac10() == undefined || target.mac10().indexOf(" ") >= 0) {
+ target.mac10("")
+ }
+
+ var mac_list = new Array(target.mac1(), target.mac2(), target.mac3(), target.mac4(), target.mac5(),
+ target.mac6(), target.mac7(), target.mac8(), target.mac9(), target.mac10());
+ if (target.selectedAction() == "2" && info.client_mac_address != "" && $.inArray(info.client_mac_address, mac_list) != -1) {
+ showAlert('black_yourself_tip');
+ return false;
+ }
+ var list_sort = mac_list.sort(); //排序
+ for (var i = 0; i < list_sort.length - 1; i++) {
+ if (list_sort[i] != "" && list_sort[i] == list_sort[i + 1]) {
+ showAlert('mac_repeat_tip');
+ return false;
+ }
+ }
+ var string_maclist = "";
+ for (var i = 0; i < 10; i++) {
+ if (string_maclist == "") {
+ string_maclist = mac_list[i];
+ } else {
+ if (mac_list[i]) {
+ string_maclist = string_maclist + ";" + mac_list[i];
+ }
+ }
+ }
+ var filter_param = {};
+ filter_param.ACL_mode = target.selectedAction();
+ if (target.selectedAction() == "2") {
+ filter_param.wifi_mac_black_list = string_maclist;
+ } else if (target.selectedAction() == "1") {
+ filter_param.wifi_mac_white_list = string_maclist;
+ }
+ showLoading('waiting');
+ service.setMacFilter(filter_param, function (result) {
+ if (result.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+ }
+
+ function bindContainer(filter_vm) {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(filter_vm, container[0]);
+
+ $('#frmWifiSwitch').validate({
+ submitHandler: function () {
+ filter_vm.setMultiSSIDSwitch();
+ }
+ });
+ $('#mac_filter_form').validate({
+ submitHandler: function () {
+ filter_vm.save();
+ },
+ rules: {
+ mac_1: 'mac_check',
+ mac_2: 'mac_check',
+ mac_3: 'mac_check',
+ mac_4: 'mac_check',
+ mac_5: 'mac_check',
+ mac_6: 'mac_check',
+ mac_7: 'mac_check',
+ mac_8: 'mac_check',
+ mac_9: 'mac_check',
+ mac_10: 'mac_check'
+ }
+ });
+ }
+ function initialize() {
+ var filter_vm = new macFilterViewModel();
+ bindContainer(filter_vm);
+
+ addTimeout(function () {
+ checkAccessMode();
+ }, 600);
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("wifi_main","underscore jquery knockout set service CryptoJS".split(" "),
+ function (_, $, ko, config, service, CryptoJS) {
+
+ var securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
+ return new Option(item.name, item.value);
+ });
+
+ function maxStationAccess(max) {
+ var showOption = [];
+ for (var i = 1; i <= max; i++) {
+ showOption.push(new Option(i, i));
+ }
+ return showOption;
+ }
+ //是否通过wifi接入
+ var viaWifi = false;
+ function checkAccessMode() {
+ service.getParams({
+ nv: 'user_ip_addr'
+ }, function (dataIp) {
+ service.getParams({
+ nv: 'station_list'
+ }, function (dataList) {
+ viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
+ });
+ });
+ }
+
+ function WifiMainVM() {
+ var target = this;
+ var info = getWifiMain();
+
+ target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
+ target.hasMultiSSID = config.HAS_MULTI_SSID;
+ target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;
+ target.hasAPStation = config.AP_STATION_SUPPORT;
+ target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
+ target.hasWifiWep = config.WIFI_WEP_SUPPORT;
+ target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
+ target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
+
+ var advanceInfo = service.getWifiAdvance();
+ target.adBand = ko.observable(advanceInfo.wifiBand);
+ target.adMode = ko.observable(advanceInfo.mode);
+ target.showQRSwitch = config.WIFI_SUPPORT_QR_CODE && config.WIFI_SUPPORT_QR_SWITCH;
+ target.showQR = ko.observable(info.show_qrcode_flag);
+ if (config.WIFI_SUPPORT_QR_SWITCH) {
+ target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE && target.showQR());
+ } else {
+ target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE);
+ }
+ if(config.WIFI_SUPPORT_QR_CODE){
+ target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + $.now();
+ } else {
+ target.qrcodeSrc = './pic/res_blacktrans.png';
+ }
+ target.origin_ap_station_enable = info.ap_station_enable;
+ target.wifi_enable = ko.observable(info.wifi_enable);
+
+ target.isShowSSIDInfoDiv = ko.observable(false);
+ if (config.WIFI_SWITCH_SUPPORT) {
+ if (info.wifi_enable == "1") {
+ target.isShowSSIDInfoDiv(true);
+ } else {
+ target.isShowSSIDInfoDiv(false);
+ }
+ } else {
+ target.isShowSSIDInfoDiv(true);
+ }
+
+ target.multi_ssid_enable = ko.observable(info.multi_ssid_enable);
+ target.origin_multi_ssid_enable = info.multi_ssid_enable;
+
+ target.maxStationNumber = ko.computed(function () {
+ return config.MAX_STATION_NUMBER;
+ });
+
+ target.modes = ko.observableArray(securityModes);
+ target.selectedMode = ko.observable(info.AuthMode);
+ target.passPhrase = ko.observable(info.passPhrase);
+ target.showPassword = ko.observable(false);
+ target.ssid = ko.observable(info.SSID);
+ target.broadcast = ko.observable(info.broadcast == '1' ? '1' : '0');
+ target.apIsolation = ko.observable(info.apIsolation == '1' ? '1' : '0');
+ target.cipher = info.cipher;
+ target.selectedStation = ko.observable(info.MAX_Access_num);
+ target.maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
+ target.encryptType = ko.observable(info.encryptType);
+ target.keyID = ko.observable(info.keyID);
+ target.wepPassword = ko.observable("");
+
+ target.m_modes = ko.observableArray(securityModes);
+ target.m_selectedMode = ko.observable(info.m_AuthMode);
+ target.m_passPhrase = ko.observable(info.m_passPhrase);
+ target.m_showPassword = ko.observable(false);
+ target.m_ssid = ko.observable(info.m_SSID);
+ target.m_broadcast = ko.observable(info.m_broadcast == '1' ? '1' : '0');
+ target.m_apIsolation = ko.observable(info.m_apIsolation == '1' ? '1' : '0');
+ target.m_cipher = info.m_cipher;
+ target.m_selectedStation = ko.observable(info.m_MAX_Access_num);
+ target.m_maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
+
+ target.getWepPassword = function () {
+ return target.keyID() == '3' ? info.Key4Str1 : (target.keyID() == '2' ? info.Key3Str1 : target.keyID() == '1' ? info.Key2Str1 : info.Key1Str1);
+ }
+ target.wepPassword(target.getWepPassword());
+ target.profileChangeHandler = function (data, event) {
+ $("#pwdWepKey").parent().find("label[class='error']").hide();
+ target.wepPassword(target.getWepPassword());
+ return true;
+ };
+
+ target.clear = function (option) {
+ if (option == "switch") {
+ target.multi_ssid_enable(info.multi_ssid_enable);
+ target.wifi_enable(info.wifi_enable);
+ } else if (option == "ssid2") {
+ target.m_selectedMode(info.m_AuthMode);
+ target.m_passPhrase(info.m_passPhrase);
+ target.m_ssid(info.m_SSID);
+ target.m_broadcast(info.m_broadcast == '1' ? '1' : '0');
+ target.m_cipher = info.m_cipher;
+ target.m_selectedStation(info.m_MAX_Access_num);
+ target.m_apIsolation(info.m_apIsolation == '1' ? '1' : '0');
+ } else if (option == "ssid1") {
+ target.selectedMode(info.AuthMode);
+ target.passPhrase(info.passPhrase);
+ target.ssid(info.SSID);
+ target.broadcast(info.broadcast == '1' ? '1' : '0');
+ target.cipher = info.cipher;
+ target.selectedStation(info.MAX_Access_num);
+ target.apIsolation(info.apIsolation == '1' ? '1' : '0');
+ if (config.WIFI_WEP_SUPPORT) {
+ target.encryptType(info.encryptType);
+ target.keyID(info.keyID);
+ target.wepPassword(target.getWepPassword());
+ }
+ } else {
+ clearTimer();
+ clearValidateMsg();
+ initialize();
+ }
+ };
+
+ target.saveSSID1 = function () {
+ if (target.checkSettings("ssid1")) {
+ return;
+ }
+ if (!config.PASSWORD_ENCODE) {
+ var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
+ if (!pwdRegex.test(target.passPhrase())) {
+ showConfirm("password_note_too_low", function () {
+ showConfirm('wifi_disconnect_confirm', function () {
+ target.saveSSID1Action();
+ return;
+ });
+ return;
+ });
+ return;
+ }
+ }
+ showConfirm('wifi_disconnect_confirm', function () {
+ target.saveSSID1Action();
+ });
+ };
+
+ target.saveSSID1Action = getSSID1Action;
+
+ target.saveSSID2 = function () {
+ if (target.checkSettings("ssid2")) {
+ return;
+ }
+ showConfirm('wifi_disconnect_confirm', function () {
+ target.saveSSID2Action();
+ });
+ };
+
+ target.saveSSID2Action = getSSID2Action;
+
+ //检测wps\最大接入数
+ target.checkSettings = function (ssid) {
+ var status = getWpsState();
+ if (ssid == "ssid1" || ssid == "ssid2") {
+ if (ssid == "ssid2") {
+ var accessDevice = service.getStatusInfo().ssid2AttachedNum;
+ if (parseInt(target.m_selectedStation()) < accessDevice) {
+ showAlert('Extend_accessDevice');
+ return true;
+ }
+ } else {
+ var accessDevice = service.getStatusInfo().ssid1AttachedNum;
+ if (parseInt(target.selectedStation()) < accessDevice) {
+ showAlert('Extend_accessDevice');
+ return true;
+ }
+ }
+ }
+
+ if (status.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+
+ if (info.multi_ssid_enable == "1" && config.HAS_MULTI_SSID) {
+ if ((ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)
+ || (ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)) {
+ showAlert({
+ msg: 'multi_ssid_max_access_number_alert',
+ params: info.MAX_Station_num
+ });
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ target.setMultiSSIDSwitch = function () {
+ if (target.checkSettings("switch")) {
+ return;
+ }
+
+ var setSwitch = function () {
+ showLoading('waiting');
+ var params = {};
+ params.m_ssid_enable = target.multi_ssid_enable();
+ if (config.WIFI_SWITCH_SUPPORT) {
+ params.wifiEnabled = target.wifi_enable();
+ }
+ service.setWifiBasicMultiSSIDSwitch(params, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(hasApReloadVarWifi, 15000);
+ } else {
+ addInterval(hasApReload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ };
+
+ function hasApReloadVarWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ service.refreshAPStationStatus();
+ target.clear();
+ }
+ function hasApReload() {
+ var info = getWifiMain();
+ service.refreshAPStationStatus();
+ if (info.wifi_enable == target.wifi_enable()) {
+ successOverlay();
+ target.clear();
+ }
+ }
+
+ var info = service.getStatusInfo();
+ if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
+ if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
+ if (!info.wifiStatus) {
+ showConfirm("multi_ssid_enable_confirm", function () {
+ setSwitch();
+ });
+ } else {
+ showConfirm("multi_ssid_enable_confirm2", function () {
+ setSwitch();
+ });
+ }
+ } else {
+ if (!info.wifiStatus) {
+ setSwitch();
+ } else {
+ showConfirm("wifi_disconnect_confirm2", function () {
+ setSwitch();
+ });
+ }
+ }
+ } else {
+ setSwitch();
+ }
+ };
+
+ //二维码显示事件
+ target.showQRHandler = function () {
+ var checkbox = $("#showQR:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showQR(true);
+ } else {
+ target.showQR(false);
+ }
+ target.showQRCode(config.WIFI_SUPPORT_QR_CODE && target.showQR());
+ };
+
+ //SSID2
+ target.m_showPasswordHandler = function () {
+ $("#m_passShow").parent().find(".error").hide();
+ var checkbox = $("#m_showPassword:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.m_showPassword(true);
+ } else {
+ target.m_showPassword(false);
+ }
+ };
+ target.showPasswordHandler = function () {
+ $("#codeWPAKey").parent().find(".error").hide();
+ $("#pwdWepKey").parent().find(".error").hide();
+ var checkbox = $("#showPassword:checked");
+ if (checkbox && checkbox.length == 0) {
+ target.showPassword(true);
+ } else {
+ target.showPassword(false);
+ }
+ };
+
+ function getSSID2Action() {
+ showLoading('waiting');
+ var params = {};
+ params.m_AuthMode = target.m_selectedMode();
+ params.m_passPhrase = target.m_passPhrase();
+ params.m_SSID = target.m_ssid();
+ params.m_broadcast = target.m_broadcast();
+ params.m_station = target.m_selectedStation();
+ params.m_cipher = target.m_selectedMode() == "WPA2PSK" ? 1 : 2;
+ if (params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {
+ params.m_cipher = 1;
+ }
+ params.m_NoForwarding = target.m_apIsolation();
+ params.m_show_qrcode_flag = target.showQR() == true ? 1 : 0;
+ service.setWifiBasic4SSID2(params, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(ssid2ReloadVarWifi, 15000);
+ } else {
+ addInterval(ssid2Reload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+ function ssid2ReloadVarWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ target.clear();
+ }
+ function ssid2Reload() {
+ var info = getWifiMain();
+ if (info.wifi_enable == "1") {
+ successOverlay();
+ target.clear();
+ }
+ }
+
+ function getSSID1Action() {
+
+ showLoading('waiting');
+ target.broadcast($("#broadcastCheckbox:checked").length > 0 ? '0' : '1');
+ target.apIsolation($("#apisolatedCheckbox:checked").length);
+ var ciphertext = "";
+ if (config.PASSWORD_ENCODE) {
+ ciphertext = target.passPhrase();
+ } else {
+ var kparam = service.getDeviceInfoLow();
+ var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
+ var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
+ ciphertext = CryptoJS.AES.encrypt(target.passPhrase(), tkey, {
+ iv: tiv,
+ mode: CryptoJS.mode.CBC,
+ padding: CryptoJS.pad.ZeroPadding
+ }).toString();
+ }
+ var params = {};
+ params.AuthMode = target.selectedMode();
+ params.passPhrase = ciphertext;
+ params.SSID = target.ssid();
+ params.broadcast = target.broadcast();
+ params.station = target.selectedStation();
+ params.cipher = target.selectedMode() == "WPA2PSK" ? 1 : 2;
+ if (params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {
+ params.cipher = 1;
+ }
+ params.NoForwarding = target.apIsolation();
+ params.show_qrcode_flag = target.showQR() == true ? 1 : 0;
+ if (config.WIFI_WEP_SUPPORT) {
+ if (params.AuthMode == "WPAPSK" || params.AuthMode == "WPA2PSK" || params.AuthMode == "WPAPSKWPA2PSK" || params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {}
+ else if (params.AuthMode == "SHARED") {
+ params.encryptType = "WEP";
+ } else {
+ params.encryptType = target.encryptType();
+ }
+ params.wep_default_key = target.keyID();
+ params.wep_key_1 = info.Key1Str1;
+ params.wep_key_2 = info.Key2Str1;
+ params.wep_key_3 = info.Key3Str1;
+ params.wep_key_4 = info.Key4Str1;
+ var WEPSelect = '0';
+ if (target.wepPassword().length == '5' || target.wepPassword().length == '13') {
+ WEPSelect = '1';
+ } else {
+ WEPSelect = '0';
+ }
+ if (target.keyID() == '3') {
+ params.wep_key_4 = target.wepPassword();
+ params.WEP4Select = WEPSelect;
+ } else if (target.keyID() == '2') {
+ params.wep_key_3 = target.wepPassword();
+ params.WEP3Select = WEPSelect;
+ } else if (target.keyID() == '1') {
+ params.wep_key_2 = target.wepPassword();
+ params.WEP2Select = WEPSelect;
+ } else {
+ params.wep_key_1 = target.wepPassword();
+ params.WEP1Select = WEPSelect;
+ }
+ }
+
+ service.setWifiBasic(params, function (result) {
+ if (result.result == "success") {
+ if (viaWifi) {
+ setTimeout(ssid1ReloadVarWifi, 15000);
+ } else {
+ addInterval(ssid1Reload, 1000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+ function ssid1ReloadVarWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ target.clear();
+ }
+ function ssid1Reload() {
+ var info = getWifiMain();
+ if (info.wifi_enable == "1") {
+ successOverlay();
+ target.clear();
+ }
+ }
+
+ }
+
+ function getWpsState() {
+ return service.getWpsInfo();
+ }
+
+ function getWifiMain() {
+ return service.getWifiBasic();
+ }
+
+ function initialize() {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ var vm = new WifiMainVM();
+ ko.applyBindings(vm, container[0]);
+ addTimeout(function () {
+ checkAccessMode();
+ }, 600);
+
+ if (config.WDS_SUPPORT) {
+ checkWifiStatusAccordingToWDS();
+ } else if (config.AP_STATION_SUPPORT) {
+ checkWifiStatus();
+ }
+
+ $('#frmSSID1').validate({
+ submitHandler: function () {
+ vm.saveSSID1();
+ },
+ rules: {
+ ssid: 'ssid',
+ pwdWepKey: {
+ wifi_wep_password_check: true,
+ wifi_password_check: true
+ },
+ txtWepKey: {
+ wifi_wep_password_check: true,
+ wifi_password_check: true
+ },
+ codeWPAKey: 'wifi_password_check',
+ txtWPAKey: 'wifi_password_check'
+ },
+ errorPlacement: function (error, element) {
+ var id = element.attr("id");
+ if (id == "codeWPAKey" || id == "txtWPAKey") {
+ error.insertAfter("#lblshowWPAPassword");
+ } else if (id == "pwdWepKey" || id == "txtWepKey") {
+ error.insertAfter("#lblShowWepPassword");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+ $('#frmSSID2').validate({
+ submitHandler: function () {
+ vm.saveSSID2();
+ },
+ rules: {
+ m_ssid: 'ssid',
+ m_pass: 'wifi_password_check',
+ m_passShow: 'wifi_password_check'
+ },
+ errorPlacement: function (error, element) {
+ var id = element.attr("id");
+ if (id == "m_pass" || id == "m_passShow") {
+ error.insertAfter("#m_lblShowPassword");
+ } else if (id == "pass" || id == "passShow") {
+ error.insertAfter("#lblShowPassword");
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+ //表单提交函数、校验规则配置
+ $('#frmWifiSwitch').validate({
+ submitHandler: function () {
+ vm.setMultiSSIDSwitch();
+ }
+ });
+
+ $('#frmMultiSSID').validate({
+ submitHandler: function () {
+ vm.setMultiSSIDSwitch();
+ }
+ });
+
+ }
+
+ function checkWifiStatusAccordingToWDS() {
+ var info = service.getWdsInfo();
+ if (info.currentMode == "0") {
+ $('#frmWifiSwitch :input').each(function () {
+ $(this).prop("disabled", false);
+ });
+ $('#frmSSID1 :input').each(function () {
+ $(this).prop("disabled", false);
+ });
+ $('#frmSSID2 :input').each(function () {
+ $(this).prop("disabled", false);
+ });
+ } else {
+ $('#frmWifiSwitch :input').each(function () {
+ $(this).prop("disabled", true);
+ });
+ $('#frmSSID1 :input').each(function () {
+ $(this).prop("disabled", true);
+ });
+ $('#frmSSID2 :input').each(function () {
+ $(this).prop("disabled", true);
+ });
+ }
+ }
+ function checkWifiStatus() {
+ var info = service.getAPStationBasic();
+ if (info.ap_station_enable == "1") {
+ $('#frmMultiSSID :input').each(function () {
+ $(this).prop("disabled", true);
+ });
+ } else {
+ $('#frmMultiSSID :input').each(function () {
+ $(this).prop("disabled", false);
+ });
+ }
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("wifi_sleep_mode","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ //休眠方式
+ function getSleepMode() {
+ return service.getSleepMode();
+ }
+
+ //覆盖范围
+ function getWifiRange() {
+ return service.getWifiRange();
+ }
+
+ var sleepTime = _.map(config.SLEEP_MODES, function (item) {
+ return new Option(item.name, item.value);
+ });
+
+ function SleepModeViewMode() {
+ var target = this;
+
+ target.isCPE = config.PRODUCT_TYPE == 'CPE';
+ target.showTSWDiv = config.TSW_SUPPORT;
+ target.showSleepDiv = config.WIFI_SLEEP_SUPPORT;
+ target.hasUssd = config.HAS_USSD;
+ target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
+ target.hasDdns = config.DDNS_SUPPORT;
+
+ target.modes = ko.observableArray(sleepTime);
+
+ var smInfo = getSleepMode();
+ target.selectedMode = ko.observable(smInfo.sleepMode);
+
+ var wifiRangeInfo = getWifiRange();
+ target.wifiRangeMode = ko.observable(wifiRangeInfo.wifiRangeMode);
+
+ target.setWifiRange = smSetWifiRange;
+
+ target.setWifiRangeAct = smSetWifiRangeAct;
+
+ target.setSleepMode = smSetSleepMode;
+
+ target.setSleepModeAct = smSetSleepModeAct;
+
+ var tsw = service.getTsw();
+ target.openEnable = ko.observable(tsw.openEnable == "" ? '0' : tsw.openEnable);
+ target.openH = ko.observable(tsw.openH);
+ target.openM = ko.observable(tsw.openM);
+ target.closeH = ko.observable(tsw.closeH);
+ target.closeM = ko.observable(tsw.closeM);
+ //定时休眠唤醒
+ target.saveTsw = smSaveTsw;
+
+ function smSetWifiRange() {
+ service.getWpsInfo({}, function (smInfo) {
+ if (smInfo.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ } else if (smInfo.radioFlag == '0') {
+ showAlert('wps_wifi_off');
+ } else {
+ showConfirm('wifi_sleep_confirm', function () {
+ showLoading('waiting');
+ target.setWifiRangeAct();
+ });
+
+ }
+ });
+ }
+ function smSetSleepModeAct() {
+ var params = {};
+ params.sleepMode = target.selectedMode();
+ service.setSleepMode(params, function (result) {
+ if (result.result != "success") {
+ errorOverlay();
+ } else {
+ successOverlay();
+ }
+ });
+ }
+
+ function smSetWifiRangeAct() {
+ var params = {};
+ params.wifiRangeMode = target.wifiRangeMode();
+ service.setWifiRange(params, function (result) {
+ if (result.result != "success") {
+ errorOverlay();
+ } else {
+ successOverlay();
+ }
+ });
+ }
+
+ function smSetSleepMode() {
+ showLoading('waiting');
+ service.getWpsInfo({}, function (info) {
+ if (info.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ } else if (info.radioFlag == '0') {
+ showAlert('wps_wifi_off');
+ } else {
+ target.setSleepModeAct();
+ }
+ });
+ }
+ function smSaveTsw() {
+ if (target.openEnable() == '1') {
+ if (Math.abs((target.openH() * 60 + parseInt(target.openM(), 10)) - (target.closeH() * 60 + parseInt(target.closeM(), 10))) < 10) {
+ showAlert('tsw_time_interval_alert');
+ return false;
+ }
+ showLoading('waiting');
+ service.saveTsw({
+ openEnable: target.openEnable(),
+ closeEnable: target.openEnable(),
+ openTime: leftInsert(target.openH(), 2, '0') + ':' + leftInsert(target.openM(), 2, '0'),
+ closeTime: leftInsert(target.closeH(), 2, '0') + ':' + leftInsert(target.closeM(), 2, '0')
+ }, smShowRes, $.noop);
+ } else {
+ showLoading('waiting');
+ service.saveTsw({
+ openEnable: target.openEnable(),
+ closeEnable: target.openEnable()
+ }, smShowRes, $.noop);
+ }
+
+ }
+
+ }
+ function bindContainer(smVm) {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(smVm, container[0]);
+
+ $('#frmTsw').validate({
+ submitHandler: function () {
+ smVm.saveTsw();
+ },
+ errorPlacement: function (error, element) {
+ if (element.attr("name") == "closeM" || element.attr("name") == "closeH") {
+ $("#closeErrorDiv").html(error);
+ } else if (element.attr("name") == "openM" || element.attr("name") == "openH") {
+ $("#openErrorDiv").html(error);
+ } else {
+ error.insertAfter(element);
+ }
+ }
+ });
+
+ $('#sleepModeForm').validate({
+ submitHandler: function () {
+ smVm.setSleepMode();
+ }
+ });
+
+ $('#wifiRangeForm').validate({
+ submitHandler: function () {
+ smVm.setWifiRange();
+ }
+ });
+
+ }
+ function initialize() {
+ var smVm = new SleepModeViewMode();
+ bindContainer(smVm);
+ }
+ function smShowRes(data) {
+ if (data && data.result == "success") {
+ successOverlay();
+ } else {
+ errorOverlay();
+ }
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("wifi_station_info","underscore jquery knockout set service menu".split(" "),
+ function (_, $, ko, config, service, menu) {
+
+ var stationUtil = {
+ dealElement: function (showEdit, idx) {
+ if (idx != "all") {
+ if (!showEdit) {
+ $("#edit_btn_" + idx + ",#hostname_txt_" + idx).show();
+ $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).hide();
+ } else {
+ $("#edit_btn_" + idx + ",#hostname_txt_" + idx).hide();
+ $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).show();
+ }
+ } else {
+ $("input[id^='hostname_txt_'],a[id^='edit_btn_']").show();
+ $("input[id^='hostname_input_'],a[id^='cancel_btn_'],a[id^='save_btn_']").hide();
+ }
+ },
+ //根据MAC匹配主机名
+ getHostName: function (hostName, mac, hostNameList) {
+ var element_data = _.find(hostNameList, function (element_data) {
+ return element_data.mac == mac;
+ });
+ return element_data ? element_data.hostname : hostName;
+ },
+ //匹配黑名单列表和主机名
+ parseBlackString: function (macStr, hostnameStr) {
+ if (macStr == "") {
+ return [];
+ }
+ var tempMac = macStr.split(';');
+ var tempHostName = hostnameStr.split(';');
+ var result = [];
+ for (var i = 0; i < tempMac.length; i++) {
+ //var obj = {};
+ //obj.hostName = tempHostName[i];
+ //obj.macAddress = tempMac[i];
+ result.push({
+ hostName: tempHostName[i],
+ macAddress: tempMac[i]
+ });
+ }
+ return result;
+ }
+ };
+
+ function staInfoViewMode() {
+ var target = this;
+ var originalData = {
+ user_ip: '',
+ macList: '',
+ ACL_mode: 2, //黑白名单
+ hostnameList: ''
+ };
+ target.showCableDiv = config.PRODUCT_TYPE == 'CPE' && config.RJ45_SUPPORT;
+ target.supportBlock = config.STATION_BLOCK_SUPPORT;
+ var pcMenu = menu.findMenu('#parental_control');
+ target.showPCLink = pcMenu && pcMenu.length > 0 && config.HAS_PARENTAL_CONTROL;
+
+ target.deviceInfo = ko.observableArray([]);
+ target.cableDeviceInfo = ko.observableArray([]);
+ target.blackDevices = ko.observableArray([]);
+ target.blackDevicesMac = ko.computed(function () {
+ return _.map(target.blackDevices(), function (element_data) {
+ return element_data.macAddress;
+ });
+ });
+ target.showBlackDiv = ko.observable(config.HAS_BLACK_AND_WHITE_FILTER ? (originalData.ACL_mode == '2' ? true : false) : config.STATION_BLOCK_SUPPORT);
+
+ ko.computed(function () {
+ target.deviceInfo();
+ target.cableDeviceInfo();
+ target.blackDevices();
+ $("#station_info_div").translate();
+ }).extend({
+ notify: 'always',
+ throttle: 300
+ });
+
+ var hostNameList = service.getHostNameList({}).devices;
+ //获取WiFi已连接设备
+ target.fetchAttachedDevices = function (cb) {
+ service.getCurrentlyAttachedDevicesInfo({}, function (data) {
+ if (editingHostname) {
+ return false;
+ }
+ target.deviceInfo(_.map(data.attachedDevices, function (element_data, idx) {
+ element_data.idx = _.uniqueId('wireless_');
+ element_data.type = 1;
+ element_data.inBlackGroup = config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2' ? false : _.contains(target.blackDevicesMac(), element_data.macAddress);
+ element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);
+ element_data.disableFlag = (config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2') || element_data.inBlackGroup || editingHostname;
+ return element_data;
+ }));
+ if (_.isFunction(cb)) {
+ cb.apply(this);
+ }
+ });
+ };
+ //获取RJ45已连接设备
+ target.fetchAttachedCableDevices = function (cb) {
+ service.getAttachedCableDevices({}, function (data) {
+ if (editingHostname) {
+ return false;
+ }
+ target.cableDeviceInfo(_.map(data.attachedDevices, function (element_data, idx) {
+ element_data.idx = _.uniqueId('cable_');
+ element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);
+ element_data.type = 2;
+ return element_data;
+ }));
+ if (_.isFunction(cb)) {
+ cb.apply(this);
+ }
+ });
+ };
+
+ target.fetchBlacklist = function (cb) {
+ service.getMacFilterInfo({}, function (data) {
+ originalData.ACL_mode = data.ACL_mode;
+ originalData.user_ip = data.user_ip_addr;
+ originalData.hostnameList = data.wifi_hostname_black_list;
+ originalData.macList = data.wifi_mac_black_list;
+ target.showBlackDiv(config.HAS_BLACK_AND_WHITE_FILTER ? (originalData.ACL_mode == '2' ? true : false) : config.STATION_BLOCK_SUPPORT);
+ var blackDevices = stationUtil.parseBlackString(data.wifi_mac_black_list, data.wifi_hostname_black_list);
+ target.blackDevices(_.map(blackDevices, function (element_data, idx) {
+ element_data.idx = _.uniqueId('black_');
+ element_data.type = 3;
+ element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);
+ return element_data;
+ }));
+ if (_.isFunction(cb)) {
+ cb.apply(this);
+ }
+ }, $.noop);
+ };
+ target.fetchBlacklist();
+ target.fetchAttachedDevices();
+ if (target.showCableDiv) {
+ target.fetchAttachedCableDevices();
+ }
+
+ var editingHostname = 0;
+ addInterval(function () {
+ if (editingHostname == 0) {
+ target.fetchAttachedDevices();
+ }
+ }, 3000);
+
+ if (target.showCableDiv) {
+ addInterval(function () {
+ if (editingHostname == 0) {
+ target.fetchAttachedCableDevices();
+ }
+ }, 5000);
+ }
+ //WiFi已连接设备列表中屏蔽按钮事件 入黑名单
+ target.wirelessBlockHandler = stationBlockEvent;
+ //保存主机名事件
+ target.saveHostNameHandler = saveHostNameEvent;
+ //主机名修改按钮点击事件
+ target.editHostNameHandler = function (element_data) {
+ editingHostname++;
+ $("#hostname_input_" + element_data.idx).val(element_data.hostName);
+ stationUtil.dealElement(true, element_data.idx);
+ return false;
+ };
+ //取消编辑主机名事件
+ target.cancelEditHostNameHandler = function (element_data) {
+ stationUtil.dealElement(false, element_data.idx);
+ editingHostname--;
+ };
+ target.cancelAllEditHostNameHandler = function () {
+ stationUtil.dealElement(false, "all");
+ editingHostname = 0;
+ };
+ //从黑名单列表中移除
+ target.blacklistRemoveHandler = function (element_data) {
+ if (originalData.macList.indexOf(element_data.macAddress) == -1) {
+ return false;
+ }
+ if (editingHostname) {
+ target.cancelAllEditHostNameHandler();
+ }
+ showLoading('waiting');
+ var macArr = [];
+ var hostnameArr = [];
+ $.each(target.blackDevices(), function (i, n) {
+ if (n.macAddress != element_data.macAddress) {
+ macArr.push(n.macAddress);
+ hostnameArr.push(n.hostName);
+ }
+ });
+ var params = {
+ ACL_mode: '2', //originalData.ACL_mode
+ macFilteringMode: '2', //originalData.ACL_mode
+ wifi_hostname_black_list: hostnameArr.join(';'),
+ wifi_mac_black_list: macArr.join(';')
+ };
+ target.updateMacFilterList(params);
+ };
+ target.updateMacFilterList = function (params) {
+ service.setMacFilter(params, function (data) {
+ if (data.result == "success") {
+ target.blackDevices([]);
+ target.fetchBlacklist(function () {
+ target.fetchAttachedDevices(function () {
+ successOverlay();
+ });
+ });
+ }
+ }, function () {
+ errorOverlay();
+ });
+ };
+
+ function saveHostNameEvent(element_data) {
+ var $input = $("#hostname_input_" + element_data.idx);
+ var newHostname = $input.val();
+ if (newHostname.indexOf(" ") == 0 || newHostname.lastIndexOf(" ") == (newHostname.length - 1) || /[\*\$\[&:,;<>'"\\`\]¥]{1,32}/.test(newHostname)) {
+ showAlert('device_rename');
+ return false;
+ } else if (newHostname == '') {
+ $(".promptErrorLabel", "#confirm-message-container").text($.i18n.prop("required"));
+ var $closestTD = $input.closest('td').addClass('has-error');
+ addTimeout(function () {
+ $closestTD.removeClass('has-error');
+ }, 5000);
+ showAlert('required');
+ return false;
+ }
+ showLoading('waiting');
+ element_data.hostName = newHostname;
+ service.editHostName({
+ hostname: element_data.hostName,
+ mac: element_data.macAddress
+ }, function () {
+ editingHostname = 0;
+ service.getHostNameList({}, function (data) {
+ hostNameList = data.devices;
+ if (element_data.type == 3) {
+ target.fetchBlacklist(function () {
+ hideLoading();
+ successOverlay();
+ });
+ } else if (element_data.type == 2) {
+ target.fetchAttachedCableDevices(function () {
+ hideLoading();
+ successOverlay();
+ });
+ } else if (element_data.type == 1) {
+ target.fetchAttachedDevices(function () {
+ hideLoading();
+ successOverlay();
+ });
+ }
+ });
+ }, function () {
+ errorOverlay();
+ });
+ }
+
+ function stationBlockEvent(element_data) {
+ if (config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2') {
+ return false;
+ }
+ if (originalData.macList.split(';').length == 10) {
+ showAlert('black_list_max');
+ return false;
+ }
+ if (originalData.macList.indexOf(element_data.macAddress) != -1) {
+ return false;
+ }
+ if (element_data.ipAddress == originalData.user_ip) {
+ showAlert('black_yourself_tip');
+ return false;
+ }
+ if (editingHostname) {
+ target.cancelAllEditHostNameHandler();
+ }
+ showLoading('waiting');
+ var newHostnameList = originalData.hostnameList == '' ? element_data.hostName : element_data.hostName + ';' + originalData.hostnameList;
+ var newMacList = originalData.macList == '' ? element_data.macAddress : element_data.macAddress + ';' + originalData.macList;
+ var params = {
+ ACL_mode: '2',
+ wifi_hostname_black_list: newHostnameList,
+ wifi_mac_black_list: newMacList
+ };
+ target.updateMacFilterList(params);
+ }
+
+ }
+
+ function bindContainer(ws_vm) {
+ var container = $('#container')[0];
+ ko.cleanNode(container);
+ ko.applyBindings(ws_vm, container);
+ }
+ function initialize() {
+ var ws_vm = new staInfoViewMode();
+ bindContainer(ws_vm);
+ }
+
+ return {
+ init: initialize
+ };
+});
+
+define("wifi_wps","underscore jquery knockout set service".split(" "),
+ function (_, $, ko, config, service) {
+
+ var viaWifi = false;
+
+ function WpsViewMode() {
+ var target = this;
+ target.hasMultiSSID = config.HAS_MULTI_SSID;
+ target.hasAPStation = config.AP_STATION_SUPPORT;
+ target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
+ target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
+
+ target.wpsType = ko.observable('');
+ target.wpsPin = ko.observable('');
+
+ var state = getWpsState();
+ target.origin_ap_station_enable = state.ap_station_enable;
+
+ target.wpsFlag = ko.observable(state.wpsFlag);
+ target.authMode = ko.observable(state.authMode);
+
+ target.radioFlag = ko.observable(state.radioFlag);
+ target.encrypType = ko.observable(state.encrypType);
+
+ target.mulOption = ko.observable(paintSSIDOption(state));
+ target.wpsSSID = ko.observable(getSSIDCurrWps(state));
+
+ var infoBasic = service.getWifiBasic();
+ target.wifi_enable = ko.observable(infoBasic.wifi_enable);
+
+ target.isShowSSIDInfoDiv = ko.observable(false);
+ if (config.WIFI_SWITCH_SUPPORT) { //软开关
+ if (infoBasic.wifi_enable == "1") {
+ target.isShowSSIDInfoDiv(true);
+ } else {
+ target.isShowSSIDInfoDiv(false);
+ }
+ } else {
+ target.isShowSSIDInfoDiv(true);
+ }
+ target.multi_ssid_enable = ko.observable(infoBasic.multi_ssid_enable);
+ target.origin_multi_ssid_enable = infoBasic.multi_ssid_enable;
+
+ target.save = wpa_save;
+
+ if (state.wpsFlag != '0') {
+ target.wpsType(state.wpsType == 'PIN' ? 'PIN' : 'PBC');
+ } else {
+ target.wpsType('');
+ }
+
+ target.setMultiSSIDSwitch = function () {
+ if (target.checkSettings("switch")) {
+ return;
+ }
+
+ function wpsSetSwitch() {
+ showLoading('waiting');
+ var wps_param = {};
+ wps_param.m_ssid_enable = target.multi_ssid_enable();
+ if (config.WIFI_SWITCH_SUPPORT) {
+ wps_param.wifiEnabled = target.wifi_enable();
+ }
+ service.setWifiBasicMultiSSIDSwitch(wps_param, function (result) {
+ if (result.result == "success") {
+ if (!viaWifi) {
+ addInterval(wpsReload, 1000);
+ } else {
+ setTimeout(wpsReloadViaWifi, 15000);
+ }
+ } else {
+ errorOverlay();
+ }
+ });
+ }
+
+ var setSwitch = wpsSetSwitch;
+ var state = service.getStatusInfo();
+ if (target.wifi_enable() == "1" && config.HAS_MULTI_SSID) {
+ if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
+ if (!state.wifiStatus) {
+ showConfirm("multi_ssid_enable_confirm", function () {
+ setSwitch();
+ });
+ } else {
+ showConfirm("multi_ssid_enable_confirm2", function () {
+ setSwitch();
+ });
+ }
+ } else {
+ if (!state.wifiStatus) {
+ setSwitch();
+ } else {
+ showConfirm("wifi_disconnect_confirm2", function () {
+ setSwitch();
+ });
+ }
+ }
+ } else {
+ setSwitch();
+ }
+
+ function wpsReload() {
+ var state = service.getWifiBasic();
+ if (state.wifi_enable == target.wifi_enable()) {
+ successOverlay();
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }
+ }
+ function wpsReloadViaWifi() {
+ successOverlay();
+ setTimeout(function () {
+ window.location.reload();
+ }, 1000);
+ clearTimer();
+ clearValidateMsg();
+ service.refreshAPStationStatus();
+ initialize();
+ }
+
+ };
+
+ target.checkSettings = function (ssid) {
+ var state = getWpsState();
+ if (state.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+ return false;
+ };
+
+ function wpa_save() {
+ var state = getWpsState();
+
+ if (state.radioFlag == '0') {
+ showAlert('wps_wifi_off');
+ return;
+ }
+
+ if (state.wpsFlag == '1') {
+ showAlert('wps_on_info');
+ return true;
+ }
+
+ if (target.wpsSSID() == "SSID1") {
+ var res = (state.AuthMode == "OPEN" && state.encrypType == "WEP")
+ || (state.AuthMode == "SHARED" && state.encrypType == "WEP")
+ || (state.AuthMode == "WPAPSK" && state.encrypType == "TKIP")
+ || (state.AuthMode == "WPAPSK" && state.encrypType == "TKIPCCMP")
+ || (state.AuthMode == "WPAPSK" && state.encrypType == "AES")
+ || (state.AuthMode == "WPA2PSK" && state.encrypType == "TKIP")
+ || (state.AuthMode == "WPAPSKWPA2PSK" && state.encrypType == "TKIP")
+ || (state.AuthMode == "WPA3Personal")
+ || (state.AuthMode == "WPA2WPA3");
+ if (res) {
+ showAlert('wps_auth_open');
+ return;
+ }
+ } else {
+ var resm = (state.m_AuthMode == "OPEN" && state.m_encrypType == "WEP")
+ || (state.m_AuthMode == "SHARED" && state.m_encrypType == "WEP")
+ || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "TKIP")
+ || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "TKIPCCMP")
+ || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "AES")
+ || (state.m_AuthMode == "WPA2PSK" && state.m_encrypType == "TKIP")
+ || (state.m_AuthMode == "WPAPSKWPA2PSK" && state.m_encrypType == "TKIP")
+ || (state.m_AuthMode == "WPA3Personal")
+ || (state.m_AuthMode == "WPA2WPA3");
+ if (resm) {
+ showAlert('wps_auth_open');
+ return;
+ }
+ }
+
+ var wpsSSID;
+ var wpsIndex;
+ if (target.wpsSSID() != "SSID1") {
+ wpsSSID = state.multiSSID;
+ wpsIndex = 2;
+ } else {
+ wpsSSID = state.ssid;
+ wpsIndex = 1;
+ }
+
+ var basic = service.getWifiBasic();
+ if (wpsSSID == basic.m_SSID && wpsIndex == 2) {
+ if (basic.m_broadcast == '1') {
+ showAlert('wps_ssid_broadcast_disable');
+ return;
+ }
+ } else if (wpsSSID == basic.SSID && wpsIndex == 1) {
+ if (basic.broadcast == '1') {
+ showAlert('wps_ssid_broadcast_disable');
+ return;
+ }
+ }
+
+ showLoading('waiting');
+ var wps_param = {};
+ wps_param.wpsType = target.wpsType();
+ wps_param.wpsSSID = wpsSSID;
+ wps_param.wpsIndex = wpsIndex;
+ wps_param.wpsPin = getWpsPin(target.wpsPin());
+
+ service.openWps(wps_param, function (result) {
+ if (result.result != "success") {
+ errorOverlay();
+ } else {
+ target.wpsPin('');
+ clearValidateMsg();
+ successOverlay();
+ }
+ });
+ }
+
+ }
+
+ function getWpsPin(value) {
+ if (value.length != 9) {
+ return value;
+ } else {
+ return value.substring(0, 4) + value.substring(5);
+ }
+ }
+
+ function getWpsState() {
+ return service.getWpsInfo();
+ }
+
+ function paintSSIDOption(info) {
+ var show_opt = [];
+ show_opt.push(new Option(info.ssid, "SSID1"));
+ if (info.ssidEnable == "1") {
+ show_opt.push(new Option(info.multiSSID, "SSID2"));
+ }
+ return show_opt;
+ }
+
+ //检查当前是否通过wifi登录webui
+ function checkAccessMode() {
+ service.getParams({
+ nv: 'user_ip_addr'
+ }, function (dataIp) {
+ service.getParams({
+ nv: 'station_list'
+ }, function (dataList) {
+ viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
+ });
+ });
+ }
+ function bindContainer(wpsVm) {
+ var container = $('#container');
+ ko.cleanNode(container[0]);
+ ko.applyBindings(wpsVm, container[0]);
+
+ addTimeout(function () {
+ checkAccessMode();
+ }, 600);
+
+ $('#wpsForm').validate({
+ submitHandler: function () {
+ wpsVm.save();
+ },
+ rules: {
+ txtPin: {
+ "wps_pin_validator": true
+ }
+ }
+ });
+
+ $('#frmWifiSwitch').validate({
+ submitHandler: function () {
+ wpsVm.setMultiSSIDSwitch();
+ }
+ });
+ }
+ function getSSIDCurrWps(info) {
+ if (info.ssid != info.multiSSID) {
+ return info.wpsSSID == info.multiSSID ? "SSID2" : "SSID1";
+ } else {
+ if (info.wifi_wps_index == '2') {
+ return "SSID2";
+ } else {
+ return "SSID1";
+ }
+ }
+ }
+ //视图初始化
+ function initialize() {
+ var wpsVm = new WpsViewMode();
+ bindContainer(wpsVm);
+ }
+
+ return {
+ init: initialize
+ };
+});
+
diff --git a/lynq/R305/ap/app/zte_webui/makefile b/lynq/R305/ap/app/zte_webui/makefile
new file mode 100755
index 0000000..2caeab6
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/makefile
@@ -0,0 +1,61 @@
+include $(zte_app_mak)
+
+all:
+ echo "zte_webui compile do nothing"
+
+clean:
+ echo "zte_webui clean do nothing"
+
+romfs:
+ @mkdir -p $(ROOTFS_DIR)/etc_ro/web
+ @cp -afvp $(APP_DIR)/zte_webui/* $(ROOTFS_DIR)/etc_ro/web
+ find . -type f -name '*.js' | xargs -n1 -I {} java -jar $(YUICOMPRESSOR) {} -o $(ROOTFS_DIR)/etc_ro/web/{}
+ find . -type f -name '*.css' | xargs -n1 -I {} java -jar $(YUICOMPRESSOR) {} -o $(ROOTFS_DIR)/etc_ro/web/{}
+ find . -type f -name '*.html' | xargs -n1 -I {} sed -i 's/^[ \t]*//g' $(ROOTFS_DIR)/etc_ro/web/{}
+ find . -type f -name '*.html' | xargs -n1 -I {} sed -i 's/[ \t]*$$//g' $(ROOTFS_DIR)/etc_ro/web/{}
+ find . -type f -name '*.html' | xargs -n1 -I {} sed -i ":a;N;s/\r//g;ta" $(ROOTFS_DIR)/etc_ro/web/{}
+ find . -type f -name '*.html' | xargs -n1 -I {} sed -i ":a;N;s/\n//g;ta" $(ROOTFS_DIR)/etc_ro/web/{}
+ifeq ($(CONFIG_WEBUI_TYPE),CPE)
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+ -cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+endif
+ifeq ($(CONFIG_WEBUI_TYPE),CPE_SW)
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+ -cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe_sw.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+endif
+
+
+
+ifeq ($(PRJ_IS_MIN), yes)
+ -cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_min.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+ifeq ($(CONFIG_WIFI_MODULE), xr819)
+ -cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_xr819.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+endif
+ifeq ($(CONFIG_WIFI_MODULE), ssv6x5x)
+ -cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_ssv6x5x.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+endif
+endif
+ifeq ($(CONFIG_WIFI_MODULE), aic8800)
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+ -cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_aic8800.js $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+endif
+
+ifneq ($(CONFIG_USE_WEBUI_SECURITY),yes)
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/3rd/crypto-js.js
+ -cp -v $(ROOTFS_DIR)/etc_ro/web/js/ext/crypto-js-null.js $(ROOTFS_DIR)/etc_ro/web/js/3rd/crypto-js.js
+ -sed -i 's/PASSWORD_ENCODE:false,//' $(ROOTFS_DIR)/etc_ro/web/js/ext/set.js
+endif
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/crypto-js-null.js
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_min.js
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_xr819.js
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_ssv6x5x.js
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_aic8800.js
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe.js
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/js/ext/set_cpe_sw.js
+ -rm -v $(ROOTFS_DIR)/etc_ro/web/makefile
+ifeq ($(CONFIG_USE_WEBUI_ZIP),yes)
+ (cd $(ROOTFS_DIR)/etc_ro && zip -r web.zip web)
+ (cd $(ROOTFS_DIR)/etc_ro && rm -rfv web)
+endif
+
+
diff --git a/lynq/R305/ap/app/zte_webui/subpg/adm_others.html b/lynq/R305/ap/app/zte_webui/subpg/adm_others.html
new file mode 100755
index 0000000..1c97648
--- /dev/null
+++ b/lynq/R305/ap/app/zte_webui/subpg/adm_others.html
@@ -0,0 +1,216 @@
+<div id="innerContainer">
+ <div class="row header-row">
+ <div class="col-xs-1">
+ <a href="#main">
+ <img alt="" src="pic/direct-back.png">
+ </a>
+ </div>
+ <div class="col-xs-11">
+ <div class="form-title">
+ <h1 data-trans='advanced_settings'></h1>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-xs-2">
+ <div class="nav_right">
+ <ul>
+ <li><a href="#wlan_sleep" data-trans="sleep_mode"></a></li>
+ <li><a href="#route_set" data-trans="router_setting"></a></li>
+ <li><a href="#filter_main" data-trans="firewall"></a></li>
+ <li data-bind="visible:hasUpdateCheck"><a href="#fota" data-trans="update_settings"></a></li>
+ <li data-bind="visible:hasUssd"><a href="#usat" data-trans="USSD"></a></li>
+ <li data-bind="visible:hasDdns"><a href="#dynamic_dns" data-trans="DDNS"></a></li>
+ <li class="active"><a href="#more" data-trans="others"></a></li>
+ </ul>
+ </div>
+ </div>
+ <div class="col-xs-10">
+ <form id="frmRestoreReset">
+ <div class="form-body">
+ <h3 data-trans="others_restart_reset" class="form-title"></h3>
+ <div class="row form-group">
+ <div data-trans="others_note_info" class="col-xs-12"></div>
+ </div>
+ <div class="row form-group">
+ <div class="col-xs-12 align-right">
+ <input data-trans="restart_button" data-bind="click: restart" type="button" class="btn btn-primary margin-right-20"/>
+ <input data-trans="restore_button" data-bind="visible: currentUserInChildGroup() == false, click: restore" type="button" class="btn btn-primary margin-right-20"/>
+ </div>
+ </div>
+ </div>
+ </form>
+
+ <!-- add by qumengjia for schedule restart start -->
+ <form id="frmScheduleRestart">
+ <div class="form-body">
+ <h3 data-trans="restart_schedule" class="form-title"></h3>
+ <div class="row form-group">
+ <label data-trans="enable_reboot_switch" class="col-xs-4 side-right"></label>
+ <div class="col-xs-8">
+ <div class="row">
+ <div class="col-xs-3">
+ <input id="restartEnable" data-bind="checked: scheduleSetting" type="radio" value="1"/>
+ <label data-trans="enable" for="restartEnable"></label>
+ </div>
+ <div class="col-xs-3">
+ <input id="restartDidable" data-bind="checked: scheduleSetting" type="radio" value="0"/>
+ <label data-trans="disable" for="restartDidable"></label>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div data-bind='visible: scheduleSetting() == "1"' class="row form-group">
+ <label class="col-xs-4 side-right" data-trans='restart_schedule_time'></label>
+ <div class="col-xs-8">
+ <label data-trans="eyeryday" style="display:inline-block; width:auto; padding-right:0"></label>
+ <select id="restartHour" data-bind="options: scr_hours, value: scheduleHour, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select>
+ <label data-trans="hour" for="restartHour" style="display:inline-block; width:auto; padding-right:0"></label>
+ <select id="restartMinute" data-bind="options: scr_minutes, value: scheduleMinute, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select>
+ <label data-trans="minute" for="restartMinute" style="display:inline-block; width:auto; padding-right:0"></label>
+ </div>
+ </div>
+ <div class="form-buttons">
+ <input data-bind="click:scheduleRestart" data-trans="apply" type="submit" formmethod="post" class="btn btn-primary margin-right-20"/>
+ </div>
+ </div>
+ </form>
+ <!-- add by qumengjia for schedule restart end -->
+
+ <form id="frmtrunOffDevice" data-bind="visible: turnOffSupport">
+ <div class="form-body">
+ <h3 data-trans="others_turn_off" class="form-title"></h3>
+ <div class="row form-group">
+ <div class="col-xs-12 align-right">
+ <input data-bind="click: turnoff" data-trans="turnoff_button" type="button" class="btn btn-primary margin-right-20"/>
+ </div>
+ </div>
+ </div>
+ </form>
+
+ <form data-bind="visible: fastbootSupport">
+ <div class="form-body">
+ <h3 class="form-title" data-trans="fastboot_setting"></h3>
+ <div class="row form-group">
+ <label data-trans="fastboot_setting" class="col-xs-4 side-right"></label>
+ <div class="col-xs-8">
+ <div class="row">
+ <div class="col-xs-3">
+ <input id="fastEnable" name="fastboot" data-bind="checked: fastbootSetting, enable: fastbootEnableFlag" type="radio" value="1"/>
+ <label data-trans="enable" for="fastEnable"></label>
+ </div>
+ <div class="col-xs-3">
+ <input id="fastDisable" name="fastboot" data-bind="checked: fastbootSetting, enable: fastbootEnableFlag" type="radio" value="0"/>
+ <label data-trans="disable" for="fastDisable"></label>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row form-group">
+ <div class="col-xs-12" data-trans="fastboot_note"></div>
+ </div>
+ <div class="row form-group">
+ <div class="col-xs-12 align-right">
+ <input data-bind="click: saveFastBoot, enable: fastbootEnableFlag" data-trans="apply" type="button" class="btn btn-primary margin-right-20"/>
+ </div>
+ </div>
+ </div>
+ </form>
+
+
+ <form id="sntpForm" data-bind="visible: SNTPSupport">
+ <div class="form-body">
+ <h3 class="form-title">SNTP</h3>
+ <div class="content">
+ <div class="row form-group">
+ <label class="col-xs-4 side-right" data-trans='local_current_time'></label>
+ <div class="col-xs-8">
+ <span class="span3" data-bind="text: localTime"></span>
+ <span> </span>
+ <span id="weekday" data-bind="text: day"></span>
+ </div>
+ </div>
+ <div class="row form-group">
+ <label class="col-xs-4 side-right" data-trans='time_set_mode' for="sntpSetTimeMode"></label>
+ <div class="col-xs-4">
+ <select id="sntpSetTimeMode" class="form-control" data-transid="time_set_time" data-bind="options: timeSetModes, value: currentMode, optionsText: transOption('time_set_time'), optionsValue: 'value', event:{change: changeSetTimeMode}"></select>
+ </div>
+ </div>
+ <div id="manualSetTime" data-bind="visible: isManualSetTime">
+ <div class="row form-group">
+ <label class="col-xs-4 side-right" data-trans='time_set_time_manual'></label>
+
+ <div class="col-xs-8">
+ <select id="manualYear" data-bind="options: years, value: currentYear, optionsText: 'text', optionsValue: 'value', event:{change: initDateList}" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select>
+ <label data-trans="year" for="manualYear" style="display:inline-block; width:auto; padding-right:0"></label>
+
+ <select id="manualMonth" data-bind="options: months, value: currentMonth, optionsText: 'text', optionsValue: 'value', event: {change: initDateList}" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select>
+ <label data-trans="month" for="manualMonth" style="display:inline-block; width:auto; padding-right:0"></label>
+
+ <select id="manualDate" data-bind="options: dates, value: currentDate, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select>
+ <label data-trans="date" for="manualDate" style="display:inline-block; width:auto; padding-right:0"></label>
+
+ <select id="manualHour" data-bind="options: hours, value: currentHour, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select>
+ <label data-trans="hour" for="manualHour" style="display:inline-block; width:auto; padding-right:0"></label>
+
+ <select id="manualMinute" data-bind="options: minutes, value: currentMinute, optionsText: 'text', optionsValue: 'value'" style="display:inline-block; width:auto; padding-right:5px; padding-left:5px" class="form-control"></select>
+ <label data-trans="minute" for="manualMinute" style="display:inline-block; width:auto; padding-right:0"></label>
+ </div>
+ </div>
+ </div>
+ <div id="autoSntpTime" data-bind="visible: isAutoSntpTime">
+ <div id="sntp_server0" class="row form-group">
+ <label data-trans='stnp_server1' for="sntp_server1_select" class="col-xs-4 side-right"></label>
+ <div class="col-xs-4">
+ <select id="sntp_server1_select" data-bind="options: serverList, value: currentServer0, optionsText: 'text', optionsValue: 'value', event: {change: changeServerSelect}" class="form-control"></select>
+ </div>
+ <div class="col-xs-4">
+ <input id="sntp_other_server0" name="sntp_other_server0" data-bind="value:customServer0, visible:isOther0" type="text" class="required form-control"/>
+ </div>
+ </div>
+ <div id="sntp_server1" class="row form-group">
+ <label class="col-xs-4 side-right" data-trans='stnp_server2' for="stnp_server2_select"></label>
+ <div class="col-xs-4">
+ <select id="stnp_server2_select" data-bind="options: serverList, value: currentServer1, optionsText: 'text', optionsValue: 'value', event: {change: changeServerSelect}" class="form-control"></select>
+ </div>
+ <div class="col-xs-4">
+ <input id="sntp_other_server1" name="sntp_other_server1" data-bind="value:customServer1, visible:isOther1" type="text" class="required form-control"/>
+ </div>
+ </div>
+ <div id="sntp_server2" class="row form-group">
+ <label data-trans='stnp_server3' for="stnp_server3_select" class="col-xs-4 side-right"></label>
+ <div class="col-xs-4">
+ <select id="stnp_server3_select" class="form-control" data-bind="options: serverList, value: currentServer2, optionsText: 'text', optionsValue: 'value', event: {change: changeServerSelect}"></select>
+ </div>
+ <div class="col-xs-4">
+ <input id="sntp_other_server2" name="sntp_other_server2" data-bind="value:customServer2, visible:isOther2" type="text" class="required form-control"/>
+ </div>
+ </div>
+ <div class="row form-group">
+ <label data-trans='time_zone' for="time_zone_select" class="col-xs-4 side-right"></label>
+ <div class="col-xs-4">
+ <select id="time_zone_select" data-bind="options: timeZones, value: currentTimeZone, optionsText: transOption('time_zone'), optionsValue: 'value'" data-transid="time_zone" class="form-control"></select>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ <div class="form-buttons">
+ <input data-bind="" data-trans="apply" type="submit" formmethod="post" class="btn btn-primary margin-right-20"/>
+ </div>
+ </div>
+ </form>
+
+ <div class="form-body">
+ <div class="content margin-top-20 line-height-30">
+ <div class="row">
+ <a href="#pin_mode">
+ <div data-trans="pin_management" class="col-xs-3 arrow-right">
+ </div>
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+</div>
\ No newline at end of file
diff --git a/lynq/R305/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c b/lynq/R305/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
new file mode 100755
index 0000000..ac4d9a5
--- /dev/null
+++ b/lynq/R305/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
@@ -0,0 +1,385 @@
+/*
+ * linux/arch/arm/mach-zx297520v2/pwr_ctrl.c
+ *
+ * Copyright (C) 2013 ZTE-TSP
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/clk.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/io.h>
+
+#include <mach/gpio.h>
+#include <mach/gpio_def.h>
+#include <linux/gpio.h>
+#include <mach/pwr_ctrl.h>
+#include <linux/delay.h>
+#include <mach/pcu.h>
+//++yuwei 20160719
+#include <mach/gpio_cfg.h>
+//++
+
+static unsigned int pwr_buck3v3_init_flag = 0;
+static unsigned int pwr_buck3v3_status = 0;
+
+void pwr_buck3v3_init(void)
+{
+ int ret=0;
+
+ ret=gpio_request(PIN_WIFI_PWR_CTL,"buck3V3");
+ if(ret)
+ BUG();
+ //zx29_gpio_config(ZX29_GPIO_27, GPIO27_GPIO27);
+ zx29_gpio_config(PIN_WIFI_PWR_CTL, PIN_WIFI_PWR_CTL_SEL);
+ gpio_direction_output(PIN_WIFI_PWR_CTL, GPIO_LOW);
+}
+
+void pwr_buck3v3_on(power_buck3v3_id val)
+{
+ if(pwr_buck3v3_init_flag == 0)
+ {
+ pwr_buck3v3_init();
+ pwr_buck3v3_init_flag = 1;
+ mdelay(100);
+ }
+
+ if(pwr_buck3v3_status == 0)
+ {
+ gpio_set_value(PIN_WIFI_PWR_CTL, GPIO_HIGH);
+ }
+ pwr_buck3v3_status |= (1<<val);
+}
+
+void pwr_buck3v3_off(power_buck3v3_id val)
+{
+ pwr_buck3v3_status &= ~(1<<val);
+ if( pwr_buck3v3_status == 0)
+ {
+ gpio_set_value(PIN_WIFI_PWR_CTL, GPIO_LOW);
+ }
+}
+
+//#ifdef CONFIG_RDA5995_WIFI
+#if defined (CONFIG_RDAWFMAC)||defined(CONFIG_RDAWFMAC_MODULE)
+int rda_wifi_init(void)
+{
+ int ret = 0;
+ ret = gpio_request(PIN_WIFI_CHIP_ENABLE,"wifi_chip_enable");
+ if(ret < 0)
+ {
+ printk("request wifi enable gpio failed\n");
+ gpio_free(PIN_WIFI_CHIP_ENABLE);
+ }
+ return ret;
+}
+EXPORT_SYMBOL(rda_wifi_init);
+
+void rda_wifi_deinit(void)
+{
+
+ printk("gpio_free wifi enable gpio \n");
+ gpio_free(PIN_WIFI_CHIP_ENABLE);
+
+}
+EXPORT_SYMBOL(rda_wifi_deinit);
+
+void rda_wifi_enable(int bval)
+{
+ zx29_gpio_config(PIN_WIFI_CHIP_ENABLE, PIN_WIFI_CHIP_ENABLE_SEL);
+ if(bval)
+ {
+ gpio_direction_output(PIN_WIFI_CHIP_ENABLE, GPIO_HIGH);
+ printk("rda_wifi gpio%d success high ##############################\n",PIN_WIFI_CHIP_ENABLE);
+ }
+ else
+ {
+ gpio_direction_output(PIN_WIFI_CHIP_ENABLE, GPIO_LOW);
+ printk("rda_wifi gpio%d success low ##############################\n",PIN_WIFI_CHIP_ENABLE);
+ }
+}
+EXPORT_SYMBOL(rda_wifi_enable);
+#endif
+
+#if defined (CONFIG_ESP8089)||defined(CONFIG_ESP8089_MODULE)
+int esp_wifi_init(void)
+{
+ int ret = 0;
+ ret = gpio_request(PIN_WIFI_PWR_CTL,"wifi_pwr_ctl");
+ if(ret < 0)
+ {
+ printk("request wifi pwr ctl gpio failed, maybe lcd used.\n");
+ gpio_free(PIN_WIFI_PWR_CTL);
+ return 0;
+ }
+
+ ret = gpio_request(PIN_WIFI_CHIP_ENABLE,"wifi_chip_enable");
+ if(ret < 0)
+ {
+ printk("request wifi enable gpio failed\n");
+ gpio_free(PIN_WIFI_CHIP_ENABLE);
+ }
+ return ret;
+}
+EXPORT_SYMBOL(esp_wifi_init);
+
+void esp_wifi_deinit(void)
+{
+ gpio_free(PIN_WIFI_CHIP_ENABLE);
+}
+EXPORT_SYMBOL(esp_wifi_deinit);
+
+void esp_wifi_enable(int bval)
+{
+ zx29_gpio_config(PIN_WIFI_PWR_CTL, PIN_WIFI_PWR_CTL_SEL);
+ if(bval)
+ {
+ gpio_direction_output(PIN_WIFI_PWR_CTL, GPIO_HIGH);
+ printk("esp_wifi gpio%d success high, pwr on ##############################\n",PIN_WIFI_PWR_CTL);
+ }
+
+ zx29_gpio_config(PIN_WIFI_CHIP_ENABLE, PIN_WIFI_CHIP_ENABLE_SEL);
+ if(bval)
+ {
+ gpio_direction_output(PIN_WIFI_CHIP_ENABLE, GPIO_LOW);
+ printk("esp_wifi gpio%d success low, chip enable ##############################\n",PIN_WIFI_CHIP_ENABLE);
+ }
+ else
+ {
+ gpio_direction_output(PIN_WIFI_CHIP_ENABLE, GPIO_HIGH);
+ printk("esp_wifi gpio%d success high, chip disable ##############################\n",PIN_WIFI_CHIP_ENABLE);
+ }
+}
+EXPORT_SYMBOL(esp_wifi_enable);
+#endif
+
+#if defined (CONFIG_XR_WLAN)
+int xr_wifi_init(void)
+{
+ int ret = 0;
+#if 0
+ ret = gpio_request(PIN_WIFI_PWR_CTL,"wifi_pwr_ctl");
+ if(ret < 0)
+ {
+ printk("request wifi pwr ctl gpio failed, maybe lcd used.\n");
+ gpio_free(PIN_WIFI_PWR_CTL);
+ return 0;
+ }
+#endif
+ ret = gpio_request(ZX29_GPIO_123, "wlan_reset");
+ if(ret < 0)
+ {
+ printk("request wifi reset gpio failed\n");
+ gpio_free(ZX29_GPIO_123);
+ }
+ return ret;
+}
+EXPORT_SYMBOL(xr_wifi_init);
+
+void xr_wifi_deinit(void)
+{
+ gpio_free(ZX29_GPIO_123);
+ //io_free(PIN_WIFI_PWR_CTL);
+}
+EXPORT_SYMBOL(xr_wifi_deinit);
+
+void xr_wifi_enable(int bval)
+{
+ //29_gpio_config(PIN_WIFI_PWR_CTL, PIN_WIFI_PWR_CTL_SEL);
+#if 0
+ if(bval)
+ {
+ gpio_direction_output(PIN_WIFI_PWR_CTL, GPIO_HIGH);
+ printk("xr_wifi gpio%d success high, pwr on ##############################\n",PIN_WIFI_PWR_CTL);
+ }
+ else
+ {
+ gpio_direction_output(PIN_WIFI_PWR_CTL, GPIO_LOW);
+ printk("xr_wifi gpio%d success low, pwr down ##############################\n",PIN_WIFI_PWR_CTL);
+ }
+#endif
+
+ zx29_gpio_config(ZX29_GPIO_123, GPIO123_GPIO123);
+ zx29_gpio_pd_pu_set(ZX29_GPIO_123,0);
+ if(bval)
+ {
+ gpio_direction_output(ZX29_GPIO_123, 0);
+ mdelay(50);
+ gpio_direction_output(ZX29_GPIO_123, 1);
+ mdelay(2);
+ gpio_direction_output(ZX29_GPIO_123, 0);
+ mdelay(50);
+ //gpio_direction_output(PIN_WIFI_CHIP_ENABLE, GPIO_LOW);
+ printk("xr_wifi gpio%d success reset, chip enable ##############################\n",ZX29_GPIO_123);
+ }
+ else
+ {
+ gpio_direction_output(ZX29_GPIO_123, 1);
+ printk("xr_wifi gpio%d chip disable ##############################\n",ZX29_GPIO_123);
+ }
+
+}
+EXPORT_SYMBOL(xr_wifi_enable);
+#endif
+
+#if defined (CONFIG_SSV6X5X)
+
+void ssv6x5x_wifi_enable(int bval)
+{
+ if(bval)
+ {
+ gpio_direction_output(PIN_WIFI_CHIP_ENABLE, 0);
+ mdelay(10);
+ gpio_direction_output(PIN_WIFI_CHIP_ENABLE, 1);
+ printk("wifi enable gpio success low%d\n",PIN_WIFI_CHIP_ENABLE);
+ }
+ else
+ {
+ gpio_direction_output(PIN_WIFI_CHIP_ENABLE, 0);
+ printk("ssv6x5x_wifi gpio%d chip disable ##############################\n",PIN_WIFI_CHIP_ENABLE);
+ }
+
+}
+EXPORT_SYMBOL(ssv6x5x_wifi_enable);
+#endif
+
+#if defined (CONFIG_AIC8800)
+
+void aic8800_wifi_enable(int bval)
+{
+ int ret = 0;
+ if(bval)
+ {
+#ifdef CONFIG_AIC8800_MIFI_EN
+ ret=gpio_request(ZX29_GPIO_85,"aic_mifi_en");
+ if(ret){
+ printk("request aic_mifi_en gpio failed\n");
+ gpio_free(ZX29_GPIO_85);
+ }
+ ret=gpio_request(ZX29_GPIO_130,"aic_mifi_power_en");
+ if(ret){
+ printk("request aic_mifi_power_en gpio failed\n");
+ gpio_free(ZX29_GPIO_130);
+ }
+ gpio_direction_output(ZX29_GPIO_85, 1);
+ gpio_direction_output(ZX29_GPIO_130, 1);
+#else
+ ret=gpio_request(ZX29_GPIO_85,"aic_ufi_en");
+ if(ret){
+ printk("request aic_ufi_en gpio failed\n");
+ gpio_free(ZX29_GPIO_85);
+ }
+ ret=gpio_request(ZX29_GPIO_119,"aic_ufi_power_en");
+ if(ret){
+ printk("request aic_ufi_power_en gpio failed\n");
+ gpio_free(ZX29_GPIO_119);
+ }
+ gpio_direction_output(ZX29_GPIO_85, 1);
+ gpio_direction_output(ZX29_GPIO_119, 1);
+#endif
+ mdelay(10);
+ printk("qqq aic en succ.\n");
+ }
+ else
+ {
+#ifdef CONFIG_AIC8800_MIFI_EN
+ gpio_direction_output(ZX29_GPIO_85, 0);
+ gpio_direction_output(ZX29_GPIO_130, 0);
+#else
+ gpio_direction_output(ZX29_GPIO_85, 0);
+ gpio_direction_output(ZX29_GPIO_119, 0);
+#endif
+ printk("qqq aic en fail.\n");
+ }
+
+}
+EXPORT_SYMBOL(aic8800_wifi_enable);
+#endif
+#if defined (CONFIG_AIC8800)
+void aic8800_wifi_disable(int bval)
+{
+ int ret = 0;
+ if(bval)
+ {
+#ifdef CONFIG_AIC8800_MIFI_EN
+ gpio_direction_output(ZX29_GPIO_85, 0);
+ gpio_direction_output(ZX29_GPIO_130, 0);
+#else
+ gpio_direction_output(ZX29_GPIO_85, 0);
+ gpio_direction_output(ZX29_GPIO_119, 0);
+#endif
+ mdelay(50);
+ printk("qqq aic dis succ.\n");
+ }
+ else
+ {
+#ifdef CONFIG_AIC8800_MIFI_EN
+ gpio_direction_output(ZX29_GPIO_85, 1);
+ gpio_direction_output(ZX29_GPIO_130, 1);
+#else
+ gpio_direction_output(ZX29_GPIO_85, 1);
+ gpio_direction_output(ZX29_GPIO_119, 1);
+#endif
+ printk("qqq aic dis fail.\n");
+ }
+}
+EXPORT_SYMBOL(aic8800_wifi_disable);
+#endif
+#if defined (CONFIG_AIC8800)
+void aic8800_wifi_re_enable(int bval)
+{
+ int ret = 0;
+ if(bval)
+ {
+#ifdef CONFIG_AIC8800_MIFI_EN
+ gpio_direction_output(ZX29_GPIO_85, 1);
+ gpio_direction_output(ZX29_GPIO_130, 1);
+#else
+ gpio_direction_output(ZX29_GPIO_85, 1);
+ gpio_direction_output(ZX29_GPIO_119, 1);
+#endif
+ mdelay(50);
+ printk("qqq re enable succ.\n");
+ }
+ else
+ {
+#ifdef CONFIG_AIC8800_MIFI_EN
+ gpio_direction_output(ZX29_GPIO_85, 0);
+ gpio_direction_output(ZX29_GPIO_130, 0);
+#else
+ gpio_direction_output(ZX29_GPIO_85, 0);
+ gpio_direction_output(ZX29_GPIO_119, 0);
+#endif
+ printk("qqq aic dis fail.\n");
+ }
+}
+EXPORT_SYMBOL(aic8800_wifi_re_enable);
+#endif
+
+#ifdef CONFIG_RTL8192CD
+//hess add, called by 8192cd_pwrctrl.c
+unsigned int Get_WiFi_Wakeup_Pin_Num()
+{
+ //return ZX29_GPIO_57;
+ return PIN_WIFI_WAKEUP;
+}
+
+int Get_WiFi_Wakeup_Pin_INT()
+{
+ //return PCU_EX7_INT;
+ return INT_WIFI_WAKEUP;
+}
+
+#endif
+
+
diff --git a/lynq/R305/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.h b/lynq/R305/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.h
new file mode 100755
index 0000000..89c6c65
--- /dev/null
+++ b/lynq/R305/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.h
@@ -0,0 +1,328 @@
+/**
+ ******************************************************************************
+ *
+ * @file rwnx_platorm.h
+ *
+ * Copyright (C) RivieraWaves 2012-2019
+ *
+ ******************************************************************************
+ */
+
+#ifndef _RWNX_PLATFORM_H_
+#define _RWNX_PLATFORM_H_
+
+#include <linux/pci.h>
+#include "lmac_msg.h"
+
+#define AIC_MACCONFIG_NAME "../../etc/aic_macconfig.txt"
+#define RWNX_CONFIG_FW_NAME "rwnx_settings.ini"
+#define RWNX_PHY_CONFIG_TRD_NAME "rwnx_trident.ini"
+#define RWNX_PHY_CONFIG_KARST_NAME "rwnx_karst.ini"
+#define RWNX_AGC_FW_NAME "agcram.bin"
+#define RWNX_LDPC_RAM_NAME "ldpcram.bin"
+#ifdef CONFIG_RWNX_FULLMAC
+#define RWNX_MAC_FW_BASE_NAME "fmacfw"
+#define RWNX_MAC_FW_RF_BASE_NAME "lmacfw_rf.bin"
+#elif defined CONFIG_RWNX_FHOST
+#define RWNX_MAC_FW_BASE_NAME "fhostfw"
+#endif /* CONFIG_RWNX_FULLMAC */
+
+#ifdef CONFIG_RWNX_TL4
+#define RWNX_MAC_FW_NAME RWNX_MAC_FW_BASE_NAME".hex"
+#else
+#define RWNX_MAC_FW_NAME RWNX_MAC_FW_BASE_NAME".ihex"
+#ifdef CONFIG_MCU_INTEGRATED
+#ifdef CONFIG_MCU_MESSAGE
+#define RWNX_MAC_FW_NAME2 RWNX_MAC_FW_BASE_NAME"_8818m_custmsg.bin"
+#else
+#define RWNX_MAC_FW_NAME2 RWNX_MAC_FW_BASE_NAME"_8818m.bin"
+#endif
+#else
+#define RWNX_MAC_FW_NAME2 RWNX_MAC_FW_BASE_NAME".bin"
+#endif
+#endif
+#define RWNX_MAC_CALIB_BASE_NAME_8800DC "fmacfw_calib_8800dc"
+#define RWNX_MAC_CALIB_NAME_8800DC_U02 RWNX_MAC_CALIB_BASE_NAME_8800DC"_u02.bin"
+#define RWNX_MAC_CALIB_NAME_8800DC_H_U02 RWNX_MAC_CALIB_BASE_NAME_8800DC"_h_u02.bin"
+
+#if (defined(CONFIG_DPD) && !defined(CONFIG_FORCE_DPD_CALIB))
+#define FW_DPDRESULT_NAME_8800DC "aic_dpdresult_8800dc.bin"
+#endif
+#ifdef CONFIG_DPD
+#define ROM_FMAC_CALIB_ADDR 0x00130000
+#define FW_PATH_MAX_LEN 200
+int is_file_exist(char* name);
+typedef struct {
+ uint32_t bit_mask[3];
+ uint32_t reserved;
+ uint32_t dpd_high[96];
+ uint32_t dpd_11b[96];
+ uint32_t dpd_low[96];
+ uint32_t idac_11b[48];
+ uint32_t idac_high[48];
+ uint32_t idac_low[48];
+ uint32_t loft_res[18];
+ uint32_t rx_iqim_res[16];
+} rf_misc_ram_t;
+typedef struct {
+ uint32_t bit_mask[4];
+ uint32_t dpd_high[96];
+ uint32_t loft_res[18];
+} rf_misc_ram_lite_t;
+#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
+#define DPD_RESULT_SIZE_8800DC sizeof(rf_misc_ram_lite_t)
+extern rf_misc_ram_lite_t dpd_res;
+#endif
+#ifdef CONFIG_DPD
+#ifndef CONFIG_FORCE_DPD_CALIB
+int aicwf_dpd_result_write_8800dc(void *buf, int buf_len);
+#endif
+#endif
+#define RWNX_MAC_PATCH_BASE_NAME "fmacfw_patch_8800dc"
+#define RWNX_MAC_PATCH_NAME2 RWNX_MAC_PATCH_BASE_NAME".bin"
+#define RWNX_MAC_PATCH_NAME2_U02 RWNX_MAC_PATCH_BASE_NAME"_u02.bin"
+#define RWNX_MAC_PATCH_NAME2_8800DC_H_U02 RWNX_MAC_PATCH_BASE_NAME"_h_u02.bin"
+#define RWNX_MAC_PATCH_TABLE_NAME_8800DC "fmacfw_patch_tbl_8800dc"
+#define RWNX_MAC_PATCH_TABLE_8800DC RWNX_MAC_PATCH_TABLE_NAME_8800DC ".bin"
+#define RWNX_MAC_PATCH_TABLE_8800DC_U02 RWNX_MAC_PATCH_TABLE_NAME_8800DC "_u02.bin"
+#define RWNX_MAC_PATCH_TABLE_8800DC_H_U02 RWNX_MAC_PATCH_TABLE_NAME_8800DC "_h_u02.bin"
+#define RWNX_MAC_RF_PATCH_BASE_NAME "fmacfw_rf_patch"
+#define RWNX_MAC_RF_PATCH_NAME RWNX_MAC_RF_PATCH_BASE_NAME".bin"
+
+
+#define RWNX_FCU_FW_NAME "fcuram.bin"
+
+#define FW_USERCONFIG_NAME "aic_userconfig.txt"
+
+#ifdef CONFIG_VENDOR_SPECIFIED_FW_PATH
+#define VENDOR_SPECIFIED_FW_PATH CONFIG_VENDOR_SPECIFIED_FW_PATH
+#endif
+#ifdef CONFIG_VENDOR_SUBDIR_NAME
+#define VENDOR_SUBDIR_NAME CONFIG_VENDOR_SUBDIR_NAME
+#endif
+#define VENDOR_SPECIFIED_DPD_PATH "/mnt/userdata/etc_rw/wifi"
+
+enum aicbt_patch_table_type {
+ AICBT_PT_INF = 0x00,
+ AICBT_PT_TRAP = 0x1,
+ AICBT_PT_B4,
+ AICBT_PT_BTMODE,
+ AICBT_PT_PWRON,
+ AICBT_PT_AF,
+ AICBT_PT_VER,
+};
+enum aicbt_btport_type {
+ AICBT_BTPORT_NULL,
+ AICBT_BTPORT_MB,
+ AICBT_BTPORT_UART,
+};
+enum aicbt_btmode_type {
+ AICBT_BTMODE_BT_ONLY_SW = 0x0, // bt only mode with switch
+ AICBT_BTMODE_BT_WIFI_COMBO, // wifi/bt combo mode
+ AICBT_BTMODE_BT_ONLY, // bt only mode without switch
+ AICBT_BTMODE_BT_ONLY_TEST, // bt only test mode
+ AICBT_BTMODE_BT_WIFI_COMBO_TEST, // wifi/bt combo test mode
+ AICBT_BTMODE_BT_ONLY_COANT, // bt only mode with no external switch
+ AICBT_MODE_NULL = 0xFF, // invalid value
+};
+enum aicbt_uart_baud_type {
+ AICBT_UART_BAUD_115200 = 115200,
+ AICBT_UART_BAUD_921600 = 921600,
+ AICBT_UART_BAUD_1_5M = 1500000,
+ AICBT_UART_BAUD_3_25M = 3250000,
+};
+enum aicbt_uart_flowctrl_type {
+ AICBT_UART_FLOWCTRL_DISABLE = 0x0, // uart without flow ctrl
+ AICBT_UART_FLOWCTRL_ENABLE, // uart with flow ctrl
+};
+enum aicbsp_cpmode_type {
+ AICBSP_CPMODE_WORK,
+ AICBSP_CPMODE_TEST,
+ AICBSP_CPMODE_MAX,
+};
+enum chip_rev {
+ CHIP_REV_U01 = 1,
+ CHIP_REV_U02 = 3,
+ CHIP_REV_U03 = 7,
+ CHIP_REV_U04 = 7,
+};
+#define RAM_FMAC_FW_ADDR 0x00120000
+#define FW_RAM_ADID_BASE_ADDR 0x00161928
+#define FW_RAM_ADID_BASE_ADDR_U03 0x00161928
+#define FW_RAM_PATCH_BASE_ADDR 0x00100000
+#define RAM_8800DC_U01_ADID_ADDR 0x00101788
+#define RAM_8800DC_U02_ADID_ADDR 0x001017d8
+#define RAM_8800DC_FW_PATCH_ADDR 0x00184000
+#define FW_RESET_START_ADDR 0x40500128
+#define FW_RESET_START_VAL 0x40
+#define FW_ADID_FLAG_ADDR 0x40500150
+#define FW_ADID_FLAG_VAL 0x01
+#define FW_RAM_ADID_BASE_ADDR_8800D80 0x002017E0
+#define FW_RAM_PATCH_BASE_ADDR_8800D80 0x0020B2B0
+#define FW_RAM_ADID_BASE_ADDR_8800D80_U02 0x00201940
+#define FW_RAM_PATCH_BASE_ADDR_8800D80_U02 0x0020b43c
+#define AICBT_PT_TAG "AICBT_PT_TAG"
+#define AICBT_TXPWR_LVL 0x00006020
+#define AICBT_TXPWR_LVL_8800dc 0x00006f2f
+#define AICBT_TXPWR_LVL_8800d80 0x00006f2f
+#define AICBSP_HWINFO_DEFAULT (-1)
+#define AICBSP_CPMODE_DEFAULT AICBSP_CPMODE_WORK
+#define AICBSP_FWLOG_EN_DEFAULT 0
+#define AICBT_BTMODE_DEFAULT_8800d80 AICBT_BTMODE_BT_ONLY_COANT
+#define AICBT_BTMODE_DEFAULT AICBT_BTMODE_BT_WIFI_COMBO
+#define AICBT_BTPORT_DEFAULT AICBT_BTPORT_UART
+#define AICBT_UART_BAUD_DEFAULT AICBT_UART_BAUD_1_5M
+#define AICBT_UART_FC_DEFAULT AICBT_UART_FLOWCTRL_ENABLE
+#define AICBT_LPM_ENABLE_DEFAULT 0
+#define AICBT_TXPWR_LVL_DEFAULT AICBT_TXPWR_LVL
+#define AICBT_TXPWR_LVL_DEFAULT_8800dc AICBT_TXPWR_LVL_8800dc
+#define AICBT_TXPWR_LVL_DEFAULT_8800d80 AICBT_TXPWR_LVL_8800d80
+struct aicbt_patch_table {
+ char *name;
+ uint32_t type;
+ uint32_t *data;
+ uint32_t len;
+ struct aicbt_patch_table *next;
+};
+struct aicbt_info_t {
+ uint32_t btmode;
+ uint32_t btport;
+ uint32_t uart_baud;
+ uint32_t uart_flowctrl;
+ uint32_t lpm_enable;
+ uint32_t txpwr_lvl;
+};
+struct aicbt_patch_info_t {
+ uint32_t info_len;
+ uint32_t adid_addrinf;
+ uint32_t addr_adid;
+ uint32_t patch_addrinf;
+ uint32_t addr_patch;
+ uint32_t reset_addr;
+ uint32_t reset_val;
+ uint32_t adid_flag_addr;
+ uint32_t adid_flag;
+};
+struct aicbsp_firmware {
+ const char *desc;
+ const char *bt_adid;
+ const char *bt_patch;
+ const char *bt_table;
+ const char *wl_fw;
+};
+struct aicbsp_info_t {
+ int hwinfo;
+ int hwinfo_r;
+ uint32_t cpmode;
+ uint32_t chip_rev;
+ bool fwlog_en;
+ uint8_t irqf;
+};
+/**
+ * Type of memory to access (cf rwnx_plat.get_address)
+ *
+ * @RWNX_ADDR_CPU To access memory of the embedded CPU
+ * @RWNX_ADDR_SYSTEM To access memory/registers of one subsystem of the
+ * embedded system
+ *
+ */
+enum rwnx_platform_addr {
+ RWNX_ADDR_CPU,
+ RWNX_ADDR_SYSTEM,
+ RWNX_ADDR_MAX,
+};
+
+struct rwnx_hw;
+
+/**
+ * struct rwnx_plat - Operation pointers for RWNX PCI platform
+ *
+ * @pci_dev: pointer to pci dev
+ * @enabled: Set if embedded platform has been enabled (i.e. fw loaded and
+ * ipc started)
+ * @enable: Configure communication with the fw (i.e. configure the transfers
+ * enable and register interrupt)
+ * @disable: Stop communication with the fw
+ * @deinit: Free all ressources allocated for the embedded platform
+ * @get_address: Return the virtual address to access the requested address on
+ * the platform.
+ * @ack_irq: Acknowledge the irq at link level.
+ * @get_config_reg: Return the list (size + pointer) of registers to restore in
+ * order to reload the platform while keeping the current configuration.
+ *
+ * @priv Private data for the link driver
+ */
+struct rwnx_plat {
+ struct pci_dev *pci_dev;
+
+#ifdef AICWF_SDIO_SUPPORT
+ struct aic_sdio_dev *sdiodev;
+#endif
+
+#ifdef AICWF_USB_SUPPORT
+ struct aic_usb_dev *usbdev;
+#endif
+ bool enabled;
+
+ int (*enable)(struct rwnx_hw *rwnx_hw);
+ int (*disable)(struct rwnx_hw *rwnx_hw);
+ void (*deinit)(struct rwnx_plat *rwnx_plat);
+ u8* (*get_address)(struct rwnx_plat *rwnx_plat, int addr_name,
+ unsigned int offset);
+ void (*ack_irq)(struct rwnx_plat *rwnx_plat);
+ int (*get_config_reg)(struct rwnx_plat *rwnx_plat, const u32 **list);
+
+ u8 priv[0] __aligned(sizeof(void *));
+};
+
+#define RWNX_ADDR(plat, base, offset) \
+ plat->get_address(plat, base, offset)
+
+#define RWNX_REG_READ(plat, base, offset) \
+ readl(plat->get_address(plat, base, offset))
+
+#define RWNX_REG_WRITE(val, plat, base, offset) \
+ writel(val, plat->get_address(plat, base, offset))
+
+typedef struct
+{
+ u8_l enable;
+ u8_l xtal_cap;
+ u8_l xtal_cap_fine;
+
+} xtal_cap_conf_t;
+
+extern struct rwnx_plat *g_rwnx_plat;
+
+int rwnx_platform_init(struct rwnx_plat *rwnx_plat, void **platform_data);
+void rwnx_platform_deinit(struct rwnx_hw *rwnx_hw);
+
+int rwnx_platform_on(struct rwnx_hw *rwnx_hw, void *config);
+void rwnx_platform_off(struct rwnx_hw *rwnx_hw, void **config);
+
+int rwnx_platform_register_drv(void);
+void rwnx_platform_unregister_drv(void);
+
+#ifdef CONFIG_LOAD_USERCONFIG
+void get_userconfig_txpwr_lvl(txpwr_lvl_conf_t *txpwr_lvl);
+void get_userconfig_txpwr_lvl_v2_in_fdrv(txpwr_lvl_conf_v2_t *txpwr_lvl_v2);
+void get_userconfig_txpwr_loss(txpwr_loss_conf_t *txpwr_loss);
+void get_userconfig_txpwr_ofst(txpwr_ofst_conf_t *txpwr_ofst);
+void get_userconfig_xtal_cap(xtal_cap_conf_t *xtal_cap);
+void set_txpwr_loss_ofst(s8_l value);
+#ifdef CONFIG_SET_AP_PS
+int get_userconfig_set_ap_ps_lvl(ap_ps_conf_t *ap_ps_lvl);
+#endif
+#endif
+int aicwf_patch_table_load(struct rwnx_hw *rwnx_hw, char *filename);
+int rwnx_load_firmware(u32 **fw_buf, const char *name, struct device *device);
+extern struct device *rwnx_platform_get_dev(struct rwnx_plat *rwnx_plat);
+
+static inline unsigned int rwnx_platform_get_irq(struct rwnx_plat *rwnx_plat)
+{
+ return rwnx_plat->pci_dev->irq;
+}
+int aicwf_misc_ram_init_8800dc(struct rwnx_hw *rwnx_hw);
+int aicwf_plat_patch_load_8800dc(struct rwnx_hw *rwnx_hw);
+
+#endif /* _RWNX_PLATFORM_H_ */
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/build/config.mk b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/build/config.mk
new file mode 100755
index 0000000..ea49eed
--- /dev/null
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/build/config.mk
@@ -0,0 +1,118 @@
+############################################################################
+#
+# Makefile -- Top level linux makefile.
+#
+############################################################################
+
+export CONFIG_WIFI_MODULE=aic8800
+export CONFIG_WIFI_FUNCTION=apsta
+#just for realtek
+export CONFIG_WIFI_SINGLEAP=no
+
+export CONFIG_SIGN_IMAGE=yes
+export CONFIG_USE_WEBUI=yes
+#export CONFIG_USE_WEBUI_ZIP=yes
+export CONFIG_MMI_LCD=no
+
+export THUMB := yes
+export USE_CPPS_KO := no
+export MODEM_TYPE := lte_only
+
+export PRJ_IS_MIN := yes
+
+#rootfs type:ubifs jffs2 squashfs
+export ROOT_FS_TYPE=jffs2
+
+#squashfs block size in KB, only for squashfs
+export SQUASHFS_BLOCK_KB=256
+
+#userdata type:ubifs jffs2
+export USERDATA_FS_TYPE=jffs2
+
+export LARGEFILE_SPLIT_ENABLE := yes
+export SPLIT_BLOCK_SIZE := 256K
+#lzma compress dictionary size in KB
+export LZMA_DICT=512
+
+#libstdc++.so.6 for gps app
+export USE_LIBSTDCPP := no
+
+#yes is ttf font, other value is bitmap font
+export USE_TTF_FONT = no
+
+# pagesize 2K and block size 128K default
+export PAGESIZE=0x800
+export ERASEBLOCK=0x8000
+
+# yes is debug mode,other value is release mode.
+export GLOBAL_DEBUG=no
+
+# custom macro for lib and app
+CUSTOM_MACRO += -DAPP_OS_LINUX=1
+CUSTOM_MACRO += -DAPP_OS_TYPE=APP_OS_LINUX
+CUSTOM_MACRO += -DFOTA_RB_DL
+
+CUSTOM_MACRO += -DPRODUCT_MIFI_CPE=0
+CUSTOM_MACRO += -DPRODUCT_PHONE=1
+CUSTOM_MACRO += -DPRODUCT_DATACARD=2
+CUSTOM_MACRO += -DPRODUCT_TYPE=PRODUCT_MIFI_CPE
+
+ifeq ($(CONFIG_MMI_LCD),no)
+CUSTOM_MACRO += -DDISABLE_LCD
+endif
+
+ifeq ($(USE_TTF_FONT),yes)
+CUSTOM_MACRO += -DENABLE_TTF_FONT
+endif
+
+CUSTOM_MACRO += -DHAVE_MODEM_IN_CORE
+#CUSTOM_MACRO += -D_USE_BL
+CUSTOM_MACRO += -D_USE_VOLTE
+CUSTOM_MACRO += -D_USE_CODEC_TI3100
+# fotaÉý¼¶°üÏÂÔØÍêÊÇ·ñÐèÒªÓû§È·ÈϺóÔÙÉý¼¶¿ª¹Ø
+export ENABLE_FOTA_UPG_USR_CONFIRM=yes
+
+# fotaÉý¼¶°üÏÂÔØÍêÊÇ·ñÐèÒª¸úAT CTRL½»»¥
+export ENABLE_FOTA_AT_MSG=yes
+
+# fotaÖÜÆÚ¼ì²âRTC¼ÆÊ±ÆôÓÿª¹Ø
+export FOTA_POLLING_USE_RTC=no
+
+#fotaÏÂÔØ¿âʹÓùãÉý(gs)\ redbend (rb)
+export ENABLE_FOTA_DM_LIB=gs
+
+#enable new call module
+export ENABLE_NEW_CC=no
+ifeq ($(ENABLE_NEW_CC),yes)
+CUSTOM_MACRO += -DUSE_NEW_CC
+endif
+#¿ØÖÆATCTLÏÂphoneĿ¼ÖеĴúÂëÊÇ·ñ²ÎÓë±àÒë
+export ENABLE_PHONECODE_IN_ATCTL=yes
+
+#¿ØÖÆÊÇ·ñʹÓÃÓïÒôÓëÉãÏñÍ·
+export USE_VOICE_SUPPORT := no
+#control delete other fota_dm file
+export CONFIG_USER_SINGLE_DM=gs
+
+#¿ØÖÆÊÇ·ñʹÓûìÒô
+export USE_MIXDATA_SUPPORT=no
+
+export USE_L1G := no
+export USE_RAT_TDS := no
+export USE_FOTA := yes
+#CUSTOM_MACRO += -DFOTA_DISABLE=1
+
+export USE_REMOVE_COMMENT := yes
+CUSTOM_MACRO += -DPRODUCT_NOT_USE_RTC
+
+# y for yes, n for no, keep same format with kernel configuration
+export CONFIG_MIN_8M_VERSION := y
+CUSTOM_MACRO += -DCONFIG_MIN_8M_VERSION=y
+
+#ÅäÖÃΪLTEµ¥Ä£°æ±¾
+export USE_L1G := no
+export USE_RAT_TDS := no
+export USE_RAT_WCDMA := no
+export USE_RAT_LTE := yes
+export USE_DPRAM := no
+export USE_TEAKAUD := no
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/config/normal/config_app.mk b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/config/normal/config_app.mk
new file mode 100755
index 0000000..e144a69
--- /dev/null
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/config/normal/config_app.mk
@@ -0,0 +1,91 @@
+
+zte_app := busybox
+
+ifeq ($(USE_FOTA),yes)
+zte_app += busybox_recovery fota_upi
+endif
+
+zte_app += fs_check zte_log_agent\
+ dnsmasq \
+ Script \
+ zte_amt \
+ zte_webui clatd cwmp
+
+#yes only when klocwork static analysis
+ifneq ($(KW_SKIP),yes)
+zte_app += iproute2 iptables c-ares
+endif
+
+ifneq ($(CONFIG_WIFI_FUNCTION)), )
+ifeq ($(findstring sta,$(CONFIG_WIFI_FUNCTION)), sta)
+ifneq ($(KW_SKIP),yes)
+ifneq ($(MK_SDK_VERSION),yes)
+ifeq ($(CONFIG_WIFI_MODULE), ssv6x5x)
+#zte_app += wpa_supplicant-2.6
+endif
+ifeq ($(CONFIG_WIFI_MODULE), aic8800)
+zte_app += wpa_supplicant-2.10
+endif
+endif
+endif
+endif
+
+ifeq ($(findstring ap,$(CONFIG_WIFI_FUNCTION)), ap)
+
+ifeq ($(CONFIG_WIFI_MODULE), xr819)
+ifneq ($(KW_SKIP),yes)
+ifneq ($(MK_SDK_VERSION),yes)
+zte_app += hostapd-2.6
+endif
+endif
+endif
+
+ifeq ($(CONFIG_WIFI_MODULE), ssv6x5x)
+ifneq ($(KW_SKIP),yes)
+ifneq ($(MK_SDK_VERSION),yes)
+zte_app += hostapd-2.6
+endif
+endif
+endif
+
+ifeq ($(CONFIG_WIFI_MODULE), aic8800)
+ifneq ($(KW_SKIP),yes)
+ifneq ($(MK_SDK_VERSION),yes)
+zte_app += hostapd-2.10
+endif
+endif
+endif
+
+endif
+
+#zte_app += wlan
+endif
+
+ifeq ($(CONFIG_USE_WEBUI),yes)
+zte_app += goahead
+endif
+zte_app += zte_ufi
+ifneq ($(MK_SDK_VERSION),yes)
+zte_app += cfg_tool zte_arp_proxy zte_ipv6_addr_conver zte_ipv6_slaac zte_ndp
+ifneq ($(KW_SKIP),yes)
+zte_app += zte_volte adb dhcp6 radvd-2.14
+endif
+endif
+
+#for app/zte_mainctrl&Script
+export CONFIG_USER_ZTE_APP=y
+
+#for app/iptables
+export CONFIG_USER_IPTABLES_IPTABLES=y
+export CONFIG_USER_IPTABLES_IP6TABLES=y
+
+#for app/iproute2
+export CONFIG_USER_IPROUTE2_TC_TC=y
+export CONFIG_USER_IPROUTE2_IP_RTACCT=y
+export CONFIG_USER_IPROUTE2_IP_IFCFG=y
+export CONFIG_USER_IPROUTE2_IP_IP=y
+export CONFIG_USER_IPROUTE2_IP_ROUTEF=y
+export CONFIG_USER_IPROUTE2_IP_ROUTEL=y
+export CONFIG_USER_IPROUTE2_IP_RTMON=y
+
+export CONFIG_USER_FOTA_OPEN_SOURCE=n
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/config/normal/config_lib.mk b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/config/normal/config_lib.mk
new file mode 100755
index 0000000..f9deda4
--- /dev/null
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/config/normal/config_lib.mk
@@ -0,0 +1,33 @@
+
+zte_lib := libvoice libtinyalsa libsoftap \
+libatutils libatext libcpnv libamt libkey
+
+ifeq ($(USE_FOTA),yes)
+zte_lib += libzte_dmapp
+endif
+
+#yes only when klocwork static analysis
+ifneq ($(KW_SKIP),yes)
+zte_lib += libsqlite libssl libnl libcurl
+
+ifeq ($(USE_FOTA),yes)
+zte_lib += liblzma
+endif
+
+endif
+
+ifneq ($(CONFIG_WIFI_MODULE),)
+zte_lib += libwlan_interface
+endif
+
+ifneq ($(MK_SDK_VERSION),yes)
+zte_lib += libsoft_timer libnvram libzte_pbm
+
+ifeq ($(USE_FOTA),yes)
+zte_lib += libdmgr libupi
+endif
+endif
+
+ifeq ($(USE_MIXDATA_SUPPORT),yes)
+zte_lib += libaudiomix
+endif
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/config/db/netprovider.db b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/config/db/netprovider.db
new file mode 100755
index 0000000..17bcdf2
--- /dev/null
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/config/db/netprovider.db
Binary files differ
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_sys
new file mode 100755
index 0000000..60a827d
--- /dev/null
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_sys
@@ -0,0 +1,403 @@
+
+######SOFTAPרÓà START###################################
+check_roam=yes
+gsm_signalbar0_low=0
+gsm_signalbar0_high=0
+gsm_signalbar1_low=1
+gsm_signalbar1_high=2
+gsm_signalbar2_low=3
+gsm_signalbar2_high=6
+gsm_signalbar3_low=7
+gsm_signalbar3_high=9
+gsm_signalbar4_low=10
+gsm_signalbar4_high=12
+gsm_signalbar5_low=13
+gsm_signalbar5_high=31
+wcdma_signalbar0_low=0
+wcdma_signalbar0_high=0
+wcdma_signalbar1_low=1
+wcdma_signalbar1_high=8
+wcdma_signalbar2_low=9
+wcdma_signalbar2_high=16
+wcdma_signalbar3_low=17
+wcdma_signalbar3_high=22
+wcdma_signalbar4_low=23
+wcdma_signalbar4_high=28
+wcdma_signalbar5_low=29
+wcdma_signalbar5_high=91
+tds_signalbar0_low=0
+tds_signalbar0_high=0
+tds_signalbar1_low=1
+tds_signalbar1_high=8
+tds_signalbar2_low=9
+tds_signalbar2_high=16
+tds_signalbar3_low=17
+tds_signalbar3_high=22
+tds_signalbar4_low=23
+tds_signalbar4_high=28
+tds_signalbar5_low=29
+tds_signalbar5_high=91
+lte_signalbar0_low=0
+lte_signalbar0_high=0
+lte_signalbar1_low=1
+lte_signalbar1_high=25
+lte_signalbar2_low=26
+lte_signalbar2_high=32
+lte_signalbar3_low=33
+lte_signalbar3_high=38
+lte_signalbar4_low=39
+lte_signalbar4_high=44
+lte_signalbar5_low=45
+lte_signalbar5_high=97
+need_cops_number_format=yes
+need_display_searching_status=yes
+need_restart_when_sim_insert=no
+need_support_pb=yes
+need_support_sms=yes
+network_need_gsm=yes
+network_need_tds=yes
+product_model=MF910W
+roam_setting_option=on
+use_lock_net=no
+network_category_based_on=act
+admin_user=admin
+appKeyMobile=A100000853
+Brand=DEMO
+hostName=dm.wo.com.cn
+Intype=DEMO
+Manuf=
+Model=
+portNum=6001
+registerDmType=0
+secsTime=1
+versionPrevious=
+wa_version=
+OSVersion=1
+OS=TOS
+urlMobile=
+DNS_proxy=
+dnsmasqfile=/var/log/dnsmasq.log
+dnsmasqfileSize=1024
+lan_domain_Enabled=1
+auto_connect_when_limited=no
+is_traffic_aline_on=no
+is_traffic_alining=no
+is_traffic_limit_on=no
+keep_online_when_limited=no
+traffic_sms_number=0
+update_type=mifi_fota
+
+fota_device_type=mifi
+fota_models=ZTE7520V3
+fota_oem=ZTE
+fota_platform=ZX297520
+fota_dm_vendor=rs
+fota_token_rs=8msgzdxxftrtys0irnuifh7o
+fota_product_id=1549891427
+fota_product_secret=f631eba30dc94546ad3f1cd38327af32
+fota_app_version=2
+fota_network_type=WIFI
+fota_token_zx=7CBE016400F65621740A04E742E6FB12
+fota_dl_url_zx=
+fota_chk_url_zx=
+fota_reg_url_zx=
+fota_report_dlr_url_zx=
+fota_report_upgr_url_zx=
+fota_report_sales_url_zx=
+fota_token_gs=97a53ee9f45adfe53c762a72f83f6f43
+fota_dl_url_gs=
+fota_chk_url_gs=
+fota_reg_url_gs=
+fota_report_dlr_url_gs=
+fota_report_upgr_url_gs=
+fota_report_sales_url_gs=
+fota_update_space_threshold=200
+Login=admin
+Password=
+sntp_server_count=3
+MAX_Station_num=32
+MAX_Station_num_bak=0
+MAX_Access_num_bbak=0
+MAX_Chip_Capability=32
+wifi_key_gen_type=MAC
+wifi_key_len=8
+wifi_key_only_digit=y
+wifi_lte_intr=1
+wifi_ssid_gen_with_mac_lastbyte=6
+wifi_key_gen_with_mac_lastbyte=8
+wifi_mac_num=2
+wifiwan=wlan0-vxd
+wifiwan_mode=dhcp
+idle_time="600"
+product_type=1
+errnofile=/usr/netlog/errno.log
+errnofileSize=1024
+hotplugfile=/usr/netlog/hotplug.log
+hotplugfileSize=1024
+mynetlinkfile=/usr/netlog/mynetlink.log
+mynetlinkfileSize=1024
+telnetd_enable=n
+print_level=2
+syslog_level=4
+telog_path=/dev/ttyS1
+skb_debug=
+seclog_switch=
+################SOFTAPרÓà END#####################################
+
+######USB¶Ë¿ÚÅäÖÃ#######
+
+##########usb/rj45µÈÈȰβåÏà¹ØÂ·¾¶##############
+#rj45³õʼ״̬·¾¶
+rj45_plugstate_path=/sys/kernel/eth_debug/eth_state
+#usbÍø¿ÚÃû·¾¶
+usb_name_path=/sys/dwc_usb/usbconfig/netname
+#usb¸÷Íø¿Ú״̬·¾¶
+usb_plugstate_path=/sys/dwc_usb/usbconfig/
+################################################
+
+#ÅäÖÃÊÇ·ñÓйâÅÌ
+cdrom_state=1
+#cdromµÚ¶þ½×¶Îö¾Ù£º0Ϊ²»ÐèҪö¾Ù£¬1ΪÐèҪö¾ÙÇÒÐèÒª¹ÒÔØ½éÖÊ£¬2Ϊ²»ÐèÒª¹ÒÔØ½éÖÊ#
+need_support_cdrom_step2=0
+
+#ÅäÖÃWindowsÏÂÍø¿¨ÀàÐÍ
+select_type=select_rndis
+
+####
+#ÅäÖÃÑз¢Ä£Ê½usbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_debug=diag,adb,serial
+
+#ÅäÖÃÓû§Ä£Ê½usbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_user=
+
+#ÅäÖÃÉú²úģʽusbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_factory=serial,diag
+
+#ÅäÖÃAMTģʽusbÉ豸¶Ë¿Ú×éºÏ
+usb_devices_amt=serial,diag
+
+#ÅäÖÃÑз¢Ä£Ê½acm´®¿Ú¸öÊý
+usb_acm_num_debug=0
+
+#ÅäÖÃÑз¢Ä£Ê½serial´®¿Ú¸öÊý
+usb_serial_num_debug=2
+
+#ÅäÖÃÓû§Ä£Ê½acm´®¿Ú¸öÊý
+usb_acm_num_user=0
+
+#ÅäÖÃÓû§Ä£Ê½serial´®¿Ú¸öÊý
+usb_serial_num_user=0
+
+#ÅäÖÃÉú²úģʽacm´®¿Ú¸öÊý
+usb_acm_num_factory=0
+
+#ÅäÖÃÉú²úģʽserial´®¿Ú¸öÊý
+usb_serial_num_factory=1
+
+#ÅäÖÃAMTģʽacm´®¿Ú¸öÊý
+usb_acm_num_amt=0
+
+#ÅäÖÃAMTģʽserial´®¿Ú¸öÊý
+usb_serial_num_amt=2
+
+#wangzhen
+#ÅäÖÃdebugģʽmass_storageµÄlunµÄģʽ
+usb_lun_type_debug=
+
+#ÅäÖÃuserģʽmass_storageµÄlunµÄģʽ
+usb_lun_type_user=
+
+#ÅäÖÃcdromģʽmass_storageµÄlunµÄģʽ
+usb_lun_type_cdrom=
+###
+
+#ÅäÖÃÑз¢Ä£Ê½Íø¿ÚΪNDISʱÉ豸µÄPID
+PID_TSP_NDIS=0581
+###
+
+#ÅäÖÃÑз¢Ä£Ê½Íø¿ÚΪRNDISʱÉ豸µÄPID
+PID_TSP_RNDIS=0581
+
+#ÅäÖÃÑз¢Ä£Ê½Íø¿ÚΪECMʱÉ豸µÄPID
+PID_TSP_ECM=0581
+
+#ÅäÖÃÑз¢Ä£Ê½Ò쳣ʱÉ豸µÄPID
+PID_TEST=ff00
+
+#ÅäÖÃÑÛͼģʽʱÉ豸µÄPID
+PID_YT=0580
+
+#ÅäÖÃÑз¢Ä£Ê½¹âÅÌCDROMµÄPID
+PID_TSP_CDROM=0548
+
+#####
+
+#ÅäÖÃÓû§Ä£Ê½Ä£Ê½¹âÅÌCDROMµÄPID
+PID_USER_CDROM=1225
+
+#####
+#######
+#ÅäÖÃÓû§Ä£Ê½Íø¿ÚΪRNDISʱÉ豸µÄPID
+PID_USER_RNDIS=1557
+
+#ÅäÖÃÓû§Ä£Ê½Íø¿ÚΪECMʱÉ豸µÄPID
+PID_USER_ECM=1557
+
+#ÅäÖÃÓû§Ä£Ê½Íø¿ÚΪNDISʱÉ豸µÄPID
+PID_USER_NDIS=1557
+
+#ÅäÖÃÓû§Ä£Ê½Ã»ÓÐÍø¿ÚʱÉ豸µÄPID
+PID_USER_NOVNIC=0580
+######
+
+#ÅäÖÃËÀ»útrapʱÉ豸µÄPID
+PID_TRAP=0197
+
+#ÅäÖÃÉú²úģʽʱÉ豸µÄPID
+PID_FACTORY=0534
+
+#ÅäÖÃAMTģʽʱÉ豸µÄPID
+PID_AMT=0201
+
+#ÅäÖùػú³äµçʱÉ豸µÄPID
+PID_FASTPOWEROFF=2004
+
+#ÅäÖÃÉ豸µÄVID
+VID_TSP=19D2
+
+#ÅäÖÃÉ豸µÄiSerial×Ö·û´®
+SERIAL_TSP=1234567890ABCDEF
+
+#ÅäÖÃÑз¢Ä£Ê½É豸µÄReleaseID
+RELEASEID_TSP=0100
+
+#ÅäÖÃÓû§Ä£Ê½É豸µÄReleaseID
+RELEASEID_USER=0101
+
+#ÅäÖÃÉ豸µÄmanufacturer×Ö·û´®
+MANUFACTURER_TSP=DEMO,Incorporated
+
+#ÅäÖÃÉ豸µÄproduct×Ö·û´®
+PRODUCT_TSP=DEMO Mobile Boardband
+
+#ÅäÖÃÉ豸µÄconfig×Ö·û´®
+CONFIG_TSP=DEMO Configuration
+
+#cdrom lunµÄvendor×Ö·û´®
+VENDOR_MS_CDROM=DEMO
+
+#cdrom lunµÄproduct×Ö·û´®
+PRODUCT_MS_CDROM=USB SCSI CD-ROM
+
+#cdrom lunµÄrelease×Ö·û´®
+RELEASE_MS_CDROM=2.31
+
+#cdrom lunµÄinquiry×Ö·û´®
+INQUIRY_MS_CDROM=DEMO USB SCSI CD-ROM 2.31
+#mmc lunµÄvendor×Ö·û´®
+VENDOR_MS_MMC=DEMO
+
+#mmc lunµÄproduct×Ö·û´®
+PRODUCT_MS_MMC=MMC Storage
+
+#mmc lunµÄrelease×Ö·û´®
+RELEASE_MS_MMC=2.31
+
+#SD½éÖÊ·¾¶
+usb_tcard_lun_path=/dev/mmcblk0
+
+#mmc lunµÄinquiry×Ö·û´®
+INQUIRY_MS_MMC=DEMO MMC Storage 2.31
+
+#ÅäÖÃECMÍø¿¨¸öÊý
+ECM_NUM=1
+
+#ÅäÖÃRNDISÍø¿¨×î´ó×é°üÊý
+RNDIS_PKT_NUM=10
+
+
+###²¨ÌØÂÊ×ÔÊÊÓ¦¿ª¹Ø###
+self_adaption_port=
+###ijЩ¶Ë¿Ú²»ÐèÒªÏòÓ¦ÓÃÉϱ¨¶Ë¿Ú×¼±¸ºÃÏûÏ¢###
+notify_forbiden_ports=
+
+######USB¶Ë¿ÚÅäÖÃEND#######
+
+######CP²àNVÅäÖÃÐÅÏ¢#######
+#ÄÚ²¿Èí¼þ°æ±¾ºÅ
+zversion=K318V1.0.0B03
+#ÍⲿÈí¼þ°æ±¾ºÅ
+zcgmr=DEMO_V1.0.0B03
+#Ó²¼þ°æ±¾ºÅ
+zhver=V0.1
+#ÄÚ²¿»úÐÍ
+zcgmm=K318
+#Íⲿ»úÐÍ
+zcgmw=K318
+#³§ÉÌÐÅÏ¢
+zcgmi=DEMO
+#SSIDºÅ
+zssid=0
+#WifiKeyµÄÖµ
+zwifikey=0
+#ËøÍø×î´ó½âËø´ÎÊý£¬ËøÍøÄ£¿éʹÓÃ
+zunlocktimes=3
+#°æ±¾Ä£Ê½ÀàÐÍ£¬Õý³£°æ±¾/¹Ò²à°æ±¾
+zversionmode=0
+#ÖÇÄܶÌÐŹ¦ÄÜ¿ª¹Ø
+zisms=0
+#DM¹¦ÄÜ¿ª¹Ø,0:¹Ø±Õ£¬1ÒÆ¶¯£¬2ÁªÍ¨£¬3µçÐÅ
+zdmreg=0
+#ÁªÍ¨DM ×¢²á¿ª»úµÈ´ýʱ¼ä, 1~60 ÓÐЧ£¬µ¥Î»·ÖÖÓ£¬ÆäËûÊýÖµ: ÎÞЧֵ
+zdmregtime=0
+#×Ô¶¯ËÑÍø·½Ê½ÍøÂç½ÓÈë´ÎÐò
+auto_acqorder=
+#¹¤¾ßlog ´æÈ¡
+zcat_mode=
+#ÕÕÏà»úͼƬ·Ö±æÂÊÏÔʾ¿ØÖÆ
+zcamera_interprolation=1
+######CP²àNVÅäÖÃÐÅÏ¢END#######
+
+#for volte
+MTNET_TEST=0
+NSIOT_TEST=0
+amrw=1
+cvmod_ims=3
+EM_CALL_SUPPORT=0
+EMCALL_TO_NORMAL=0
+IMS_APN=
+IMS_CONFURI=
+IMS_URI_TYPE=0
+IMS_REG_EXPIRES=600000
+IMS_REG_SUB_EXPIRES=600000
+NET_IMS_CAP=0
+UDP_THRESH=1300
+IPSEC_DISABLE=0
+PRECONDTION_NOT_SUPPORT=0
+WAIT_RPT_TIME=1000
+OCT_ALGN_AMR=0
+SMS_OVER_IP=1
+IMS_USER_AGENT=
+BSF_PORT=8080
+XCAP_PORT=80
+UT_APN=
+380_THEN_CSFB=0
+DTMF_RFC4733=0
+DIALOG_FORK=0
+DATA_CENTRIC=0
+not_supp_hmac_sha1_96=0
+not_supp_hmac_md5_96=0
+not_supp_des_ede3_cbc=0
+not_supp_aes_cbc=0
+IPV4_PCSCF_ADDR=
+IPV6_PCSCF_ADDR=
+IMS_KOREA_TEST=0
+PCSCF_TEST_ENABLE=0
+G_IMS_CMGF=0
+IMS_SMS_URI_TYPE=0
+IMS_CC_URI_TYPE=0
+T3396_SUPPORT=0
+T3396_CAUSE_REASON=8,27,32,33
+T3396_DURATION=720
+T3396_COUNTS=3
+#for volte end
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_user b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
new file mode 100755
index 0000000..49477df
--- /dev/null
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -0,0 +1,483 @@
+apn_auto_config=CMCC($)cmnet($)manual($)*99#($)pap($)($)($)IP($)auto($)($)auto($)($)
+APN_config0=Default($)Default($)manual($)($)($)($)($)IP($)auto($)($)auto($)($)
+APN_config1=
+APN_config2=
+APN_config3=
+APN_config4=
+APN_config5=
+APN_config6=
+APN_config7=
+APN_config8=
+APN_config9=
+apn_index=0
+apn_mode=auto
+at_snap_flag=3
+at_wifi_mac=0
+auto_apn_index=0
+cid_reserved=0
+clear_pb_when_restore=no
+clear_sms_when_restore=no
+default_apn=3gnet
+ipv6_APN_config1=
+ipv6_APN_config2=
+ipv6_APN_config3=
+ipv6_APN_config4=
+ipv6_APN_config5=
+ipv6_APN_config6=
+ipv6_APN_config7=
+ipv6_APN_config8=
+ipv6_APN_config9=
+m_profile_name=Internux
+need_init_modem=yes
+net_select=NETWORK_auto
+pdp_type=IP
+ppp_apn=
+max_reconnect_time=3000000
+pppd_auth=noauth
+ppp_auth_mode=none
+ppp_passwd=
+ppp_pdp_type=
+ppp_username=
+ipv6_ppp_auth_mode=none
+ipv6_ppp_passwd=
+ipv6_ppp_username=
+pre_mode=
+prefer_dns_manual=0.0.0.0
+standby_dns_manual=0.0.0.0
+wan_apn=internet
+wan_dial=
+cta_test=0
+safecare_enbale=0
+safecare_hostname=mob.3gcare.cn
+safecare_registed_imei=
+safecare_registed_iccid=
+safecare_contimestart1=
+safecare_contimestart2=
+safecare_contimestart3=
+safecare_contimestop1=
+safecare_contimestop2=
+safecare_contimestop3=
+safecare_contimeinterval=
+safecare_mobsite=http://mob.3gcare.cn
+safecare_chatsite=
+safecare_platno=
+safecare_mobilenumber=
+safecare_version=
+ethwan_dns_mode=auto
+pswan_dns_mode=auto
+wifiwan_dns_mode=auto
+ethwan_ipv6_dns_mode=auto
+wifiwan_ipv6_dns_mode=auto
+pswan_ipv6_dns_mode=auto
+admin_Password=Pass1234
+psw_changed=1
+alg_ftp_enable=0
+alg_sip_enable=0
+blc_wan_auto_mode=AUTO_PPP
+blc_wan_mode=AUTO
+br_ipchange_flag=
+br_node=usblan0
+clat_fake_subnet=192.0.168.0
+clat_frag_collect_timeout=300
+clat_local_mapping_timeout=300
+clat_mapping_record_timeout=3000
+clat_query_server_port=1464
+DefaultFirewallPolicy=0
+dev_coexist=0
+dhcpDns=192.168.0.1
+dhcpEnabled=1
+dhcpEnd=192.168.0.200
+dhcpLease_hour=24
+dhcpStart=192.168.0.100
+dhcpv6stateEnabled=0
+dhcpv6statelessEnabled=1
+dhcpv6statePdEnabled=0
+dial_mode=auto_dial
+DMZEnable=0
+DMZIPAddress=
+dns_extern=
+ipv6_dns_extern=
+eth_act_type=
+eth_type=wan
+ethlan=
+ethwan=
+ethwan_dialmode=auto
+ethwan_mode=auto
+ethwan_priority=3
+fast_usb=usblan0
+fastnat_level=2
+IPPortFilterEnable=0
+IPPortFilterRules_0=
+IPPortFilterRules_1=
+IPPortFilterRules_2=
+IPPortFilterRules_3=
+IPPortFilterRules_4=
+IPPortFilterRules_5=
+IPPortFilterRules_6=
+IPPortFilterRules_7=
+IPPortFilterRules_8=
+IPPortFilterRules_9=
+IPPortFilterRulesv6_0=
+IPPortFilterRulesv6_1=
+IPPortFilterRulesv6_2=
+IPPortFilterRulesv6_3=
+IPPortFilterRulesv6_4=
+IPPortFilterRulesv6_5=
+IPPortFilterRulesv6_6=
+IPPortFilterRulesv6_7=
+IPPortFilterRulesv6_8=
+IPPortFilterRulesv6_9=
+ipv4_fake_subnet=192.0.0.0
+ipv6_fake_subnet=2016::1
+lan_ipaddr=192.168.0.1
+lan_name=br0
+lan_netmask=255.255.255.0
+LanEnable=1
+mac_ip_list=
+mgmt_quicken_power_on=0
+mtu=1400
+natenable=
+dosenable=0
+need_jilian=1
+nofast_port=21+22+23+25+53+67+68+69+110+115+123+443+500+1352+1723+1990+1991+1992+1993+1994+1995+1996+1997+1998+4500+5060
+nv_save_interval=300
+path_conf=/etc_rw
+path_ro=/etc_ro
+path_log=/var/log/
+path_sh=/sbin
+path_tmp=/tmp
+permit_gw=
+permit_ip6=
+permit_nm=255.255.255.0
+PortForwardEnable=0
+PortForwardRules_0=
+PortForwardRules_1=
+PortForwardRules_2=
+PortForwardRules_3=
+PortForwardRules_4=
+PortForwardRules_5=
+PortForwardRules_6=
+PortForwardRules_7=
+PortForwardRules_8=
+PortForwardRules_9=
+PortMapEnable=0
+PortMapRules_0=
+PortMapRules_1=
+PortMapRules_2=
+PortMapRules_3=
+PortMapRules_4=
+PortMapRules_5=
+PortMapRules_6=
+PortMapRules_7=
+PortMapRules_8=
+PortMapRules_9=
+ppp_name=ppp0
+pppoe_password=
+pppoe_username=
+ps_ext1=usblan0
+ps_ext2=usblan0
+ps_ext3=usblan0
+ps_ext4=usblan0
+ps_ext5=usblan0
+ps_ext6=usblan0
+ps_ext7=usblan0
+ps_ext8=usblan0
+pswan=wan
+pswan_mode=pdp
+pswan_priority=1
+RemoteManagement=0
+rj45_plugstate_path=/sys/kernel/eth_debug/eth_state
+rootdev_friendlyname=DEMO-UPnP
+rootdev_manufacturer=DEMO
+rootdev_modeldes=XXX
+rootdev_modelname=XXX
+os_url=http://www.demo.com
+serialnumber=See-IMEI
+static_dhcp_enable=1
+static_ethwan_gw=
+static_ethwan_ip=
+static_ethwan_nm=
+static_ethwan_pridns=
+static_ethwan_secdns=
+static_wifiwan_ipaddr=
+static_wifiwan_netmask=
+static_wifiwan_gateway=
+wifiwan_pridns_manual=
+wifiwan_secdns_manual=
+static_wan_gateway=0.0.0.0
+static_wan_ipaddr=0.0.0.0
+static_wan_netmask=0.0.0.0
+static_wan_primary_dns=0.0.0.0
+static_wan_secondary_dns=0.0.0.0
+swlanstr=sw0_lan
+swvlan=sw0
+swwanstr=sw0_wan
+tc_downlink=
+tc_uplink=
+tc_local=1310720
+tc_enable=0
+time_limited=
+time_to_2000_when_restore=yes
+upnpEnabled=0
+usblan=usblan0
+WANPingFilter=0
+websURLFilters=
+wifiwan_priority=2
+DDNS=
+DDNS_Enable=0
+DDNSAccount=
+DDNSPassword=
+DDNSProvider=
+iccidPrevious=
+imeiPrevious=
+registerFlag=0
+registeredRound=
+secsEveryRound=1
+secsEveryTime=1
+regver=4.0
+meid=
+uetype=1
+LocalDomain=m.home
+data_volume_alert_percent=
+data_volume_limit_size=
+data_volume_limit_switch=0
+data_volume_limit_unit=0
+flux_day_total=0
+flux_last_day=
+flux_last_month=
+flux_last_year=
+flux_month_total=0
+flux_set_day=
+flux_set_month=
+flux_set_year=
+monthly_rx_bytes=0
+monthly_time=0
+monthly_tx_bytes=0
+MonthlyConTime_Last=
+dm_nextpollingtime=
+fota_allowRoamingUpdate=0
+fota_dl_pkg_size=0
+fota_update_flag=
+fota_updateIntervalDay=15
+fota_upgrade_result=
+fota_version_delta_id=
+fota_version_delta_url=
+fota_pkg_total_size=0
+fota_version_file_size=
+fota_version_md5sum=
+fota_version_name=
+fota_need_user_confirm_update=0
+fota_need_user_confirm_download=1
+fota_version_force_install=0
+polling_nexttime=0
+pwron_auto_check=1
+fota_updateMode=1
+fota_test_mode=0
+fota_pkg_downloaded=0
+fota_upgrade_result_internal=
+mmi_battery_voltage_line=3090+3300+3450+3490+3510+3540+3550+3570+3580+3600+3620+3650+3670+3710+3740+3780+3850+3900+3950+4000+4060
+mmi_fast_poweron=
+mmi_led_mode=sleep_mode
+mmi_new_sms_blink_flag=1
+mmi_show_pagetab=page1+page2+page3
+mmi_showmode=led
+mmi_task_tab=net_task+ctrl_task+wifi_task+traffic_task+key_task+tip_task+tipwps_task+tipnetconnect_task+wificode_task+ssid_task+sms_task
+mmi_temp_voltage_line=948+1199+1694+1736
+mmi_use_protect=
+mmi_use_wifi_usernum=1
+leak_full_panic=
+leak_list_max=
+leak_set_flag=
+monitor_period=300
+netinf_flag=
+skb_all_max=
+skb_data_max=
+skb_fromcp_max=
+skb_max_fail=
+skb_max_panic=
+skb_size_max=
+skb_tocp_max=
+sntp_default_ip=134.170.185.211;131.107.13.100;202.112.31.197;202.112.29.82;202.112.10.36;ntp.gwadar.cn;ntp-sz.chl.la;dns.sjtu.edu.cn;news.neu.edu.cn;dns1.synet.edu.cn;time-nw.nist.gov;pool.ntp.org;europe.pool.ntp.org
+sntp_dst_enable=0
+sntp_other_server0=
+sntp_other_server1=
+sntp_other_server2=
+sntp_server0=time-nw.nist.gov
+sntp_server1=pool.ntp.org
+sntp_server2=europe.pool.ntp.org
+sntp_sync_select_interval_time=30
+sntp_time_set_mode=auto
+sntp_timezone=CST-8
+sntp_timezone_index=0
+assert_errno=
+comm_logsize=16384
+cr_inner_version=V1.0.0B08
+cr_version=V1.0.0B01
+hw_version=PCBMF29S2V1.0.0
+TURNOFF_CHR_NUM=
+watchdog_app=0
+HTTP_SHARE_FILE=
+HTTP_SHARE_STATUS=
+HTTP_SHARE_WR_AUTH=readWrite
+ipv6_pdp_type=
+ipv6_wan_apn=
+Language=zh-cn
+manual_time_day=
+manual_time_hour=
+manual_time_minute=
+manual_time_month=
+manual_time_second=
+manual_time_year=
+sdcard_mode_option=0
+AccessControlList0=
+AccessPolicy0=0
+ACL_mode=0
+AuthMode=WPA2PSK
+Channel=0
+wifi_acs_num=8
+closeEnable=0
+closeTime=
+CountryCode=CN
+DefaultKeyID=0
+DtimPeriod=1
+EncrypType=AES
+EX_APLIST=
+EX_APLIST1=
+EX_AuthMode=
+EX_DefaultKeyID=
+EX_EncrypType=
+EX_mac=
+EX_SSID1=CPE_
+EX_WEPKEY=
+EX_wifi_profile=
+EX_WPAPSK1=
+FragThreshold=2346
+HideSSID=0
+HT_GI=1
+Key1Str1=12345
+Key2Str1=
+Key3Str1=
+Key4Str1=
+Key1Type=1
+Key2Type=
+Key3Type=
+Key4Type=
+m_AuthMode=WPA2PSK
+m_DefaultKeyID=
+m_EncrypType=AES
+m_HideSSID=0
+m_Key1Str1=1234
+m_Key2Str1=
+m_Key3Str1=
+m_Key4Str1=
+m_Key1Type=1
+m_Key2Type=
+m_Key3Type=
+m_Key4Type=
+m_MAX_Access_num=0
+m_NoForwarding=
+m_show_qrcode_flag=0
+m_SSID=CPE_
+m_ssid_enable=0
+m_wapiType=
+m_wifi_mac=901D45692A5C
+m_WPAPSK1_aes=
+m_WPAPSK1_encode=MTIzNDU2Nzg=
+MAX_Access_num=32
+MAX_Access_num_bak=32
+NoForwarding=0
+openEnable=0
+openTime=
+operater_ap=
+RekeyInterval=3600
+RTSThreshold=2347
+show_qrcode_flag=0
+Sleep_interval=10
+ssid_write_flag=0
+SSID1=CPE_
+tsw_sleep_time_hour=
+tsw_sleep_time_min=
+tsw_wake_time_hour=
+tsw_wake_time_min=
+wapiType=
+wifi_force_40m=1
+wifi_11n_cap=1
+wifi_band=b
+wifi_coverage=long_mode
+wifi_hostname_black_list=
+wifi_hostname_white_list=
+wifi_mac=901D45692A5B
+wifi_mac_black_list=
+wifi_mac_white_list=
+wifi_profile=
+wifi_profile1=
+wifi_profile2=
+wifi_profile3=
+wifi_profile4=
+wifi_profile5=
+wifi_profile6=
+wifi_profile7=
+wifi_profile8=
+wifi_profile9=
+wifi_profile_num=0
+wifi_root_dir=
+wifi_sta_connection=0
+wifi_wps_index=1
+wifiEnabled=1
+wifilan=wlan0-va0
+wifilan2=wlan0-va1
+mac_wlan0=
+wifi_ft=
+wifi_coupling=
+WirelessMode=6
+WPAPSK1_aes=
+WPAPSK1_encode=MTIzNDU2Nzg=
+wps_mode=
+WPS_SSID=
+WscModeOption=0
+monitor_apps=
+at_netdog=
+autorspchannel_list=all
+soctime_switch=0
+uart_control=0
+uart_ctstrs_enable=
+special_cmd_list=$MYNETREAD
+##为入网入库芯片认证版本添加 begin
+atcmd_stream1=AT+ZSET="w_instrument",1
+atcmd_stream2=AT^SYSCONFIG=24,0,1,2
+atcmd_stream3=AT+ZSET="csiiot",2
+atcmd_stream4=AT+ZSET="dlparaflg",0
+atcmd_stream5=AT+ZSET="MTNET_TEST",1;AT+ZGAAT=0;AT+ZSET="CMCC_TEST",1;AT+ZSET="LTE_INFO",6348;AT+ZSET="VOICE_SUPPORT",1;AT+ZSET="FDD_RELEASE",7;AT+ZSET="LTE_RELEASE",1;AT+ZSET="UE_PS_RELEASE",5;AT+ZSET="QOS_RELEASE",4;AT+ZSET="TEBS_THRESHOLD",0
+atcmd_stream6=AT+ZSET="MTNET_TEST",1;AT+ZGAAT=0;AT+ZSET="LTE_INFO",6348;AT+ZSET="VOICE_SUPPORT",1;AT+ZSET="FDD_RELEASE",7;AT+ZSET="LTE_RELEASE",1;AT+ZSET="UE_PS_RELEASE",5;AT+ZSET="QOS_RELEASE",4;AT+ZSET="TEBS_THRESHOLD",0;AT+ZSET="IGNORE_SECURITY_SUPPORT",0;AT+ZSET="csifilter",0;AT+ZSET="csrhobandflg",0;AT+ZSET="dlparaflg",1;AT+ZSET="csiup",1;AT+ZSET="rfparaflag",0,0,1,0;AT+ZSET="csiiot",1;AT+ZSET="EXCEPT_RESET",0;AT+ZSET="ISIM_SUPPORT",1;AT+ZIMSTEST="MTNET_TEST",1;AT+ZSET="MANUAL_SEARCH",0
+##为入网入库芯片认证版本添加 end
+#for audio ctrl
+audio_priority=0123
+customer_type=sdk_min
+debug_mode=
+cpIndCmdList=+ZMMI+ZURDY+ZUSLOT+ZICCID^MODE+ZPBIC+ZMSRI+CREG+CEREG+CGREG+CGEV
+zephyr_filter_ip=
+wait_timeout=2
+sntp_sync_time=1
+sntp_static_server0=time-nw.nist.gov
+sntp_static_server1=pool.ntp.org
+sntp_static_server2=europe.pool.ntp.org
+vsim_bin_path=/mnt/userdata/vSim.bin
+webv6_enable=
+lan_ipv6addr=fe80::1
+sms_vp=
+at_select_timeout=
+mtnet_test_mcc=
+at_atv=
+at_atq=
+at_at_d=
+base_ip_on_mac=0
+quick_dial=1
+xlat_enable=0
+#for schedule_restart start
+schedule_restart_enable=0
+schedule_restart_option=everyday
+schedule_restart_day=0
+schedule_restart_hour=0
+schedule_restart_minute=0
+schedule_restart_weekday=Mon
+#for schedule_restart end
\ No newline at end of file
diff --git a/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/device.xml b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/device.xml
new file mode 100755
index 0000000..fc4d0ad
--- /dev/null
+++ b/lynq/R305/ap/project/zx297520v3/prj_cpe_min/fs/normal/rootfs/etc_ro/device.xml
@@ -0,0 +1,338 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cwmp>
+ <model>
+ <object name="InternetGatewayDevice">
+ <param name="DeviceSummary" get_func="TRF_Get_DeviceSummary"/>
+ <param name="LANDeviceNumberOfEntries" get_func="TRF_Get_LANDeviceNumberOfEntries"/>
+ <param name="WANDeviceNumberOfEntries" get_func="TRF_Get_WANDeviceNumberOfEntries"/>
+ <object name="DeviceInfo">
+ <param name="SpecVersion" type="s64" get_func="get_igd_di_specversion"/>
+ <param name="HardwareVersion" type="s64" get_func="get_igd_di_hardwareversion" set_func="set_igd_di_hardwareversion"/>
+ <param name="SoftwareVersion" type="s64" get_func="get_igd_di_softwareversion" set_func="set_igd_di_softwareversion"/>
+ <param name="ProvisioningCode" get_func="get_igd_di_provisioningcode" />
+ <param name="Manufacturer" get_func="get_igd_di_manufacturer"/>
+ <param name="ManufacturerOUI" get_func="get_igd_di_manufactureroui"/>
+ <param name="ProductClass" get_func="get_igd_di_productclass"/>
+ <param name="SerialNumber" get_func="get_igd_di_serialnumber"/>
+ <object name="VendorConfigFile" rw="0">
+ <Parameter name="Name" rw="0" type="s64" get_func="get_igd_di_vc_name"/>
+ <Parameter name="Version" rw="0" type="s16" get_func="get_igd_di_vc_version"/>
+ <Parameter name="Date" rw="0" valueType="dt" get_func="get_igd_di_vc_date"/>
+ <Parameter name="Description" rw="0" type="s256" get_func="get_igd_di_vc_description"/>
+ </object>
+ </object>
+ <object name="ManagementServer">
+ <param name="ConnectionRequestURL" noti_rw="2" type="s256" get_func="get_igd_ms_connectionrequesturl"/>
+ <param name="ConnectionRequestUsername" rw="1" noti_rw="2" type="s256" get_func="get_igd_ms_connectionrequestusername" set_func="set_igd_ms_connectionrequestusername" notify_func="notify_igd_ms_connectionrequestusername" />
+ <param name="ConnectionRequestPassword" rw="1" noti_rw="2" type="s256" get_func="get_igd_ms_connectionrequestpassword" set_func="set_igd_ms_connectionrequestpassword"/>
+ <param name="Username" rw="1" noti_rw="0" type="s256" get_func="get_igd_ms_username" set_func="set_igd_ms_username"/>
+ <param name="Password" rw="1" noti_rw="0" type="s256" get_func="get_igd_ms_password" set_func="set_igd_ms_password"/>
+ <param name="URL" noti_rw="0" rw="1" type="s256" get_func="get_igd_ms_url" set_func="set_igd_ms_url"/>
+ <param name="PeriodicInformEnable" rw="1" noti_rw="0" type="bool" get_func="get_igd_ms_PeriodicInformEnable" set_func="set_igd_ms_PeriodicInformEnable"/>
+ <param name="PeriodicInformInterval" rw="1" noti_rw="0" type="uint" get_func="get_igd_ms_PeriodicInformInterval" set_func="set_igd_ms_PeriodicInformInterval"/>
+ <param name="PeriodicInformTime" type="dt" get_func="" set_func=""/>
+ <param name="ParameterKey" rw="1" type="s32" get_func="get_igd_ms_parameterkey" set_func="set_igd_ms_parameterkey"/>
+ <param name="UDPConnectionRequestAddress" get_func="" set_func=""/>
+ <param name="UDPConnectionRequestAddressNotificationLimit" get_func=""/>
+ <param name="STUNEnable" rw="1" type="bool" get_func="get_igd_ms_STUNEnable" set_func="set_igd_ms_STUNEnable"/>
+ <param name="STUNServerAddress" rw="1" get_func="get_igd_ms_stunserveraddress" set_func="set_igd_ms_stunserveraddress"/>
+ <param name="STUNServerPort" rw="1" get_func="get_igd_ms_stunserverport" set_func="set_igd_ms_stunserverport"/>
+ <param name="STUNUsername" rw="1" get_func="get_igd_ms_stunusername" set_func="set_igd_ms_stunusername"/>
+ <param name="STUNPassword" rw="1" get_func="get_igd_ms_stunpassword" set_func="set_igd_ms_stunpassword"/>
+ <param name="STUNMaximumKeepAlivePeriod" rw="1" type="s" get_func="get_igd_ms_stunmaximumkeepaliveperiod" set_func="set_igd_ms_stunmaximumkeepaliveperiod"/>
+ <param name="STUNMinimumKeepAlivePeriod" rw="1" type="s" get_func="get_igd_ms_stunminimumkeepaliveperiod" set_func="set_igd_ms_stunminimumkeepaliveperiod"/>
+ <param name="NATDetected" rw="1" type="s" get_func="get_igd_ms_natdetected" set_func="set_igd_ms_natdetected"/>
+ </object>
+ <object name="Time" >
+ <param name="NTPServer0" rw="1" type="s64" get_func="get_igd_time_ntpserver0" set_func="set_igd_time_ntpserver0"/>
+ <param name="NTPServer1" rw="1" type="s64" get_func="get_igd_time_ntpserver1" set_func="set_igd_time_ntpserver1"/>
+ <param name="NTPServer2" rw="1" type="s64" get_func="get_igd_time_ntpserver2" set_func="set_igd_time_ntpserver2"/>
+ <param name="CurrentLocalTime" rw="0" type="dt" get_func="get_igd_time_currentlocaltime"/>
+ <param name="LocalTimeZone" rw="0" type="s6" get_func="get_igd_time_localtimezone"/>
+ <param name="LocalTimeZoneName" rw="0" type="s64" get_func="get_igd_time_localtimezonename"/>
+ <param name="DaylightSavingsUsed" rw="0" type="bool"/>
+ <param name="DaylightSavingsStart" rw="0" type="dt"/>
+ <param name="DaylightSavingsEnd" rw="0" type="dt"/>
+ </object>
+ <object name="WANDevice" rw="1" refresh_func="refresh_igd_wandevice">
+ <object name="{i}">
+ <param name="WANConnectionNumberOfEntries" rw="0" type="uint"/>
+ <object name="WANCommonInterfaceConfig" rw="0">
+ <param name="EnableForInternet" rw="0" type="bool"/>
+ <param name="WANAccessType" rw="0" type="s"/>
+ <param name="PhysicalLinkStatus" rw="0" type="s"/>
+ <param name="TotalBytesSent" rw="0" type="uint"/>
+ <param name="TotalBytesReceived" rw="0" type="uint"/>
+ <param name="TotalPacketsSent" rw="0" type="uint"/>
+ <param name="TotalPacketsReceived" rw="0" type="uint"/>
+ </object>
+ <object name="COM_WANInterfaceConfig" rw="0" refresh_func="refresh_igd_wd_comwaninterfaceconfig">
+ <object name="{i}">
+ <param name="NetworkMode" rw="0" type="s"/>
+ <param name="InterfaceType" rw="0" type="s"/>
+ <object name="Stats" rw="0">
+ <param name="COM_PLMNID" rw="0" type="s6"/>
+ <param name="COM_RAT" rw="0" type="uint"/>
+ <param name="COM_2GRSSI" rw="0" type="int"/>
+ <param name="COM_3GRSSI" rw="0" type="int"/>
+ <param name="COM_3GRSCP" rw="0" type="int"/>
+ <param name="COM_3GEcNo" rw="0" type="int"/>
+ <param name="COM_LTERSSI" rw="0" type="int"/>
+ <param name="COM_LTERSRP" rw="0" type="int"/>
+ <param name="COM_LTERSRQ" rw="0" type="int"/>
+ <param name="COM_LTEBandWidth" rw="0" type="uint"/>
+ <param name="COM_CellID" rw="0" type="uint"/>
+ <param name="COM_LAC" rw="0" type="uint"/>
+ <param name="COM_ARFCN" rw="0" type="s64"/>
+ <param name="COM_OnlineTime" rw="0" type="uint"/>
+ <param name="COM_TotalOnlineTime" rw="0" type="uint"/>
+ <param name="COM_DownRate" rw="0" type="uint"/>
+ <param name="COM_UpRate" rw="0" type="uint"/>
+ <param name="COM_DownVolume" rw="0" type="uint"/>
+ <param name="COM_UpVolume" rw="0" type="uint"/>
+ <param name="COM_TotalDownVolume" rw="0" type="uint"/>
+ <param name="COM_TotalUpVolume" rw="0" type="uint"/>
+ </object>
+ </object>
+ </object>
+ <object name="WANEthernetInterfaceConfig" rw="0" refresh_func="refresh_igd_wd_wanetherinterfaceconfig">
+ <object name="{i}">
+ <param name="Status" rw="0" type="s"/>
+ <param name="MACAddress" rw="0" type="s"/>
+ <object name="Stats" rw="0">
+ <param name="BytesSent" rw="0" type="uint"/>
+ <param name="BytesReceived" rw="0" type="uint"/>
+ <param name="PacketsSent" rw="0" type="uint"/>
+ <param name="PacketsReceived" rw="0" type="uint"/>
+ </object>
+ </object>
+ </object>
+ <object name="WANConnectionDevice" rw="1" refresh_func="refresh_igd_wd_wanconnectiondevice">
+ <object name="{i}">
+ <param name="WANIPConnectionNumberOfEntries" rw="0" type="uint"/>
+ <param name="WANPPPConnectionNumberOfEntries" rw="0" type="uint"/>
+ <object name="COM_WANLinkConfig" rw="0">
+ <param name="ProfileName" rw="0" type="s"/>
+ <param name="APN" rw="0" type="s128"/>
+ <param name="PDPType" rw="0" type="uint"/>
+ <param name="AuthenticationType" rw="0" type="uint"/>
+ <param name="Username" rw="0" type="s64"/>
+ <param name="Password" rw="0" type="s64"/>
+ <param name="PrimaryDNS" rw="0" type="s64"/>
+ <param name="SecondaryDNS" rw="0" type="s64"/>
+ <param name="MTU" rw="0" type="uint"/>
+ <param name="MSS" rw="0" type="uint"/>
+ </object>
+ <object name="COM_WANEthernetLinkConfig" rw="0">
+ <param name="ConnectionMode" rw="0" type="s"/>
+ <param name="Username" rw="0" type="s64"/>
+ <param name="Password" rw="0" type="s64"/>
+ <param name="MTU" rw="0" type="uint"/>
+ <param name="MSS" rw="0" type="uint"/>
+ </object>
+ <object name="WANIPConnection" rw="0" refresh_func="refresh_igd_wd_wcd_wanipconnection">
+ <object name="{i}">
+ <param name="Enable" rw="0" type="bool" get_func="get_igd_wd_wcd_wic_enable"/>
+ <param name="ConnectionStatus" rw="0" valueType="string" len="16"/>
+ <param name="PossibleConnectionTypes" rw="0" type="s"/>
+ <param name="ConnectionType" rw="0" type="s"/>
+ <param name="Name" rw="0" type="s256"/>
+ <param name="Uptime" rw="0" type="uint"/>
+ <param name="LastConnectionError" rw="0" type="s"/>
+ <param name="AutoDisconnectTime" rw="0" type="uint"/>
+ <param name="IdleDisconnectTime" rw="0" type="uint"/>
+ <param name="WarnDisconnectDelay" rw="0" type="uint"/>
+ <param name="RSIPAvailable" rw="0" type="bool"/>
+ <param name="NATEnabled" rw="0" type="bool"/>
+ <param name="AddressingType" rw="0" type="s"/>
+ <param name="ExternalIPAddress" rw="0" type="s"/>
+ <param name="SubnetMask" rw="0" type="s"/>
+ <param name="DefaultGateway" rw="0" type="s32"/>
+ <param name="DNSServers" rw="0" type="s64"/>
+ <param name="ConnectionTrigger" rw="0" type="s"/>
+ <param name="RouteProtocolRx" rw="0" type="s"/>
+ <param name="ShapingRate" rw="0" type="int"/>
+ <param name="ShapingBurstSize" rw="0" type="uint"/>
+ <param name="PortMappingNumberOfEntries" rw="0" type="uint"/>
+ <param name="COM_IPv6IPAddress" rw="0" type="s"/>
+ <param name="COM_IPv6AddressingType" rw="0" type="s"/>
+ <param name="COM_IPv6DNSEnable" rw="0" type="bool"/>
+ <param name="COM_IPv6DNSOverrideAllowed" rw="0" type="bool"/>
+ <param name="COM_IPv6DNSServers" rw="0" type="s"/>
+ <param name="COM_IPv6PrefixOrigin" rw="0" type="s32"/>
+ <param name="COM_IPv6Prefix" rw="0" type="s32"/>
+ <param name="COM_DefaultIPv6Gateway" type="s64"/>
+ <param name="RegisterNetworkType" rw="0" type="s32"/>
+ <param name="CellID" rw="0" valueType="string" len="16"/>
+ <param name="RSRP" rw="0" valueType="string" len="8" get_func="get_igd_wd_wcd_wic_rsrp"/>
+ <param name="RSRQ" rw="0" valueType="string" len="8"/>
+ <param name="RSSI" rw="0" valueType="string" len="8" get_func="get_igd_wd_wcd_wic_rssi"/>
+ <param name="SINR" rw="0" valueType="string" len="8"/>
+ </object>
+ </object>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object name="IPPingDiagnostics">
+ <param name="DiagnosticsState" rw="0" get_func="" set_func=""/>
+ <param name="Interface" rw="0" get_func="" set_func=""/>
+ <param name="Host" rw="0" get_func="" set_func=""/>
+ <param name="NumberOfRepetitions" rw="0" get_func="" set_func=""/>
+ <param name="Timeout" rw="0" get_func="" set_func=""/>
+ <param name="DataBlockSize" rw="0" get_func="" set_func=""/>
+ <param name="DSCP" rw="0" get_func="" set_func=""/>
+ <param name="SuccessCount" get_func=""/>
+ <param name="FailureCount" get_func=""/>
+ <param name="AverageResponseTime" get_func=""/>
+ <param name="MinimumResponseTime" get_func=""/>
+ <param name="MaximumResponseTime" get_func=""/>
+ </object>
+ <object name="TraceRouteDiagnostics">
+ <param name="DiagnosticsState" rw="0" get_func="" set_func=""/>
+ <param name="Interface" rw="0" get_func="" set_func=""/>
+ <param name="Host" rw="0" get_func="" set_func=""/>
+ <param name="NumberOfTries" rw="0" get_func="" set_func=""/>
+ <param name="Timeout" rw="0" get_func="" set_func=""/>
+ <param name="DataBlockSize" rw="0" get_func="" set_func=""/>
+ <param name="DSCP" rw="0" get_func="" set_func=""/>
+ <param name="MaxHopCount" rw="0" get_func="" set_func=""/>
+ <param name="ResponseTime" get_func=""/>
+ <param name="RouteHopsNumberOfEntries" get_func=""/>
+ <object name="RouteHops" refresh_func="refresh_igd_TraceRouteDiagnostics_RouteHops">
+ <object name="{i}">
+ <param name="HopHost" get_func=""/>
+ <param name="HopHostAddress" get_func=""/>
+ <param name="HopErrorCode" get_func=""/>
+ <param name="HopRTTimes" get_func=""/>
+ </object>
+ </object>
+ </object>
+ <object name="LANDevice" refresh_func="refresh_igd_landevice">
+ <object name="{i}">
+ <param name="LANEthernetInterfaceNumberOfEntries" type="uint" get_func="" set_func=""/>
+ <param name="LANWLANConfigurationNumberOfEntries" type="uint" get_func="" set_func=""/>
+ <object name="LANHostConfigManagement" rw="0">
+ <param name="DHCPServerEnable" rw="0" type="bool"/>
+ <param name="MinAddress" rw="0" type="s"/>
+ <param name="MaxAddress" rw="0" type="s"/>
+ <param name="ReservedAddresses" type="s256"/>
+ <param name="SubnetMask" rw="0" type="s"/>
+ <param name="DNSServers" type="s64"/>
+ <param name="DomainName" type="s64"/>
+ <param name="IPRouters" rw="0" type="s64"/>
+ <param name="DHCPLeaseTime" rw="0" valueType="int"/>
+ <param name="UseAllocatedWAN" type="s"/>
+ <param name="AssociatedConnection" type="s256"/>
+ <param name="PassthroughLease" type="uint"/>
+ <param name="PassthroughMACAddress" type="s"/>
+ <param name="AllowedMACAddresses" type="s512"/>
+ <param name="IPInterfaceNumberOfEntries" type="uint"/>
+ <param name="DHCPStaticAddressNumberOfEntries" type="uint"/>
+ <object name="IPInterface" refresh_func="refresh_igd_ld_lhcm_ipinterface">
+ <object name="{i}">
+ <param name="Enable" rw="0" type="bool"/>
+ <param name="IPInterfaceIPAddress" rw="1" type="s" get_func="get_igd_ld_ipinterfaceipaddress" set_func="set_igd_ld_ipinterfaceipaddress"/>
+ <param name="IPInterfaceSubnetMask" rw="1" type="s" get_func="get_igd_ld_ipinterfacesubnetMask" set_func="set_igd_ld_ipinterfacesubnetMask" />
+ <param name="IPInterfaceAddressingType" rw="0" type="s" get_func=""/>
+ <object name="COM_IPv6Address" >
+ <param name="LocalAddress" type="s64"/>
+ </object>
+ </object>
+ </object>
+ <object name="DHCPStaticAddress" refresh_func="refresh_igd_ld_lhcm_dhcpstaticaddress">
+ <object name="{i}">
+ <param name="Chaddr" rw="0" type="s"/>
+ <param name="Yiaddr" rw="0" type="s"/>
+ </object>
+ </object>
+ </object>
+ <object name="Hosts" >
+ <param name="HostNumberOfEntries" rw="0" type="uint"/>
+ <object name="Host" rw="0">
+ <param name="IPAddress" rw="0" type="s"/>
+ <param name="MACAddress" rw="0" type="s"/>
+ <param name="HostName" rw="0" type="s64"/>
+ <param name="InterfaceType" rw="0" type="s64"/>
+ <param name="Active" rw="0" type="bool"/>
+ </object>
+ </object>
+ <object name="LANEthernetInterfaceConfig" refresh_func="refresh_igd_ld_lanethernetinterfaceconfig" >
+ <object name="{i}">
+ <param name="Enable" rw="0" type="bool"/>
+ <param name="Status" rw="0" type="s"/>
+ <param name="MACAddress" rw="0" type="s"/>
+ <object name="Stats" rw="0">
+ <param name="BytesSent" rw="0" type="uint"/>
+ <param name="BytesReceived" rw="0" type="uint"/>
+ <param name="PacketsSent" rw="0" type="uint"/>
+ <param name="PacketsReceived" rw="0" type="uint"/>
+ </object>
+ </object>
+ </object>
+ <object name="WLANConfiguration" rw="0" refresh_func="refresh_igd_ld_wlanconfiguration">
+ <object name="{i}">
+ <param name="Enable" rw="0" type="bool"/>
+ <param name="Status" type="s64"/>
+ <param name="BSSID" rw="0" type="s64"/>
+ <param name="Channel" rw="0" type="uint"/>
+ <param name="AutoChannelEnable" rw="0" type="bool"/>
+ <param name="SSID" rw="0" type="s64" get_func="get_igd_ld_wc_ssid"/>
+ <param name="Standard" rw="0" type="s64"/>
+ <param name="EncryptionMode" rw="0" type="s64"/>
+ <param name="AuthenticationMode" rw="0" type="s64"/>
+ <param name="MaxSTAs" rw="0" type="uint"/>
+ <param name="Powerlevel" rw="0" type="uint"/>
+ <param name="Band" rw="0" type="s64"/>
+ <param name="Bandwidth" rw="0" type="s64"/>
+ <param name="RegulatoryDomain" type="s64"/>
+ <param name="BasicDataTransmitRates" type="s64"/>
+ <param name="OperationalDataTransmitRates" type="s64"/>
+ <param name="PossibleDataTransmitRates" type="s64"/>
+ <param name="SSIDAdvertisementEnabled" rw="0" type="bool"/>
+ <param name="RadioEnabled" type="bool"/>
+ <param name="TransmitPowerSupported" type="s64"/>
+ <param name="TransmitPower" type="uint"/>
+ <param name="AutoRateFallBackEnabled" type="bool"/>
+ <param name="WMMEnable" type="bool"/>
+ <param name="TotalBytesSent" type="uint"/>
+ <param name="TotalBytesReceived" type="uint"/>
+ <param name="TotalPacketsSent" type="uint"/>
+ <param name="TotalPacketsReceived" type="uint"/>
+ <param name="TotalAssociations" rw="0" type="uint"/>
+ <object name="WEPKey" refresh_func="refresh_igd_ld_wc_wepkey" >
+ <object name="{i}">
+ <param name="WEPKey" rw="0" type="s64"/>
+ </object>
+ </object>
+ <object name="PreSharedKey" refresh_func="refresh_igd_ld_wc_presharekey" >
+ <object name="{i}">
+ <param name="PreSharedKey" rw="0" type="s64"/>
+ <param name="KeyPassphrase" rw="0" type="s64"/>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object name="COM_RouterAdvertisement" >
+ <param name="Enable" rw="0" type="bool"/>
+ <param name="Prefix" rw="0" type="s32"/>
+ <param name="PreferredLifetime" rw="0" valueType="int"/>
+ <param name="ValidLifetime" rw="0" valueType="int"/>
+ <param name="MaxRtrAdvInterval" rw="0" type="uint"/>
+ <param name="MinRtrAdvInterval" rw="0" type="uint"/>
+ <param name="AdvManagedFlag" rw="0" type="bool"/>
+ <param name="AdvOtherConfigFlag" rw="0" type="bool"/>
+ <param name="IPv6DNSServers" rw="0" type="s"/>
+ </object>
+ </object>
+ </object>
+ </object>
+ </model>
+ <inform>
+ <paramlist>
+ <param name=""/>
+ </paramlist>
+ </inform>
+ <rpc>
+ </rpc>
+</cwmp>