void QGenieSmartnetworkThread::doCmdTMOption( const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<1) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameters"; return; } int iret; QString sret; bool btemp; const QDomNode &node=doFunc(reqlist[0],"DeviceConfig","GetTrafficMeterEnabled" ,&iret,&sret); if(iret !=0) { retlist<<QString::number(iret)<<sret<<"when get enable state"; return; } QDomElement elem=node.firstChild().toElement(); if((elem.attribute("NewTrafficMeterEnable").toInt(&btemp)==1) &&btemp) { const QDomNode node1=doFunc(reqlist[0],"DeviceConfig","GetTrafficMeterOptions" ,&iret,&sret); elem=node1.firstChild().toElement(); if(iret !=0) { retlist<<QString::number(iret)<<sret; return; } const char *cTMParas[]= { "NewControlOption" ,"NewMonthlyLimit" ,"RestartHour" ,"RestartMinute" ,"RestartDay" }; retlist<<"000"<<"1"; for(int i=0;i<sizeof(cTMParas)/sizeof(cTMParas[0]);i++) { retlist<<elem.attribute(cTMParas[i]); } } else { retlist<<"000"<<"0"; } }
void QGenieSmartnetworkThread::doCmdTMStatistics( const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<1) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameters"; return; } int iret; QString sret; const QDomNode &node=doFunc(reqlist[0],"DeviceConfig","GetTrafficMeterStatistics" ,&iret,&sret); if(iret!=0) { retlist<<QString::number(iret)<<sret; return; } QDomElement elem=node.firstChild().toElement(); retlist<<"000"; const char *cTMParas[]= { "NewTodayConnectionTime","NewTodayUpload","NewTodayDownload", "NewYesterdayConnectionTime","NewYesterdayUpload","NewYesterdayDownload", "NewWeekConnectionTime","NewWeekUpload","NewWeekDownload", "NewMonthConnectionTime","NewMonthUpload","NewMonthDownload", "NewLastMonthConnectionTime","NewLastMonthUpload","NewLastMonthDownload" }; for(int i=0;i<sizeof(cTMParas)/sizeof(cTMParas[0]);i++) { retlist<< elem.attribute(cTMParas[i]) ; } }
void QGenieSmartnetworkThread::doCmdFirmware(const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<1) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameters"; return; } int iret; QString sret; const QDomNode &node=doFunc(reqlist[0],"DeviceInfo","GetInfo" ,&iret,&sret); if(iret!=0) { retlist<<QString::number(iret)<<sret; return; } QDomElement elem=node.firstChild().toElement(); retlist<<"000"; retlist<< elem.attribute("Firmwareversion") ; const QDomNode node1=doFunc(reqlist[0],"WLANConfiguration","Is5GSupported" ,&iret,&sret); if(!iret) { retlist.clear(); retlist<<QString::number(iret)<<sret; return; } elem=node1.firstChild().toElement(); QString _5GState="0"; bool btemp1; int is5GSupported=elem.attribute("New5GSupported").toInt(&btemp1); if(btemp1 && (is5GSupported==1)) { const quint32 wireless5G=(1<<0); const quint32 gacc5G=(1<<1); _5GState=QString::number(wireless5G|gacc5G); } retlist<<_5GState ; }
void QGenieSmartnetworkThread::doCmdGet5GGaccInfo(const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<1) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameter"; return; } // QMap<QString,QString> paras; int iret; QString sret; const QDomNode node=doFunc(reqlist[0],"WLANConfiguration","Get5GGuestAccessEnabled" ,&iret,&sret); QDomElement elem=node.firstChild().toElement(); if(iret !=0) { retlist<<QString::number(iret)<<sret; return; } QString senabled=elem.attribute("NewGuestAccessEnabled"); const QDomNode &node1=doFunc(reqlist[0],"WLANConfiguration","Get5GGuestAccessNetworkInfo" ,&iret,&sret); if(iret !=0) { retlist<<QString::number(iret)<<sret; return; } elem=node1.firstChild().toElement(); retlist<<"000"<<senabled; const char *cParas[]={ "NewSSID" ,"NewSecurityMode" ,"NewKey" }; for(int i=0;i<sizeof(cParas)/sizeof(cParas[0]);i++) { retlist<<elem.attribute(cParas[i]); } }
void descendAndDo(DIR *dir, char *fromDirName, char *toDirName, char *baseSrcName, char *baseFromName, char *baseToName, int allowAppend, char *archiveExtension, int doFunc()) { struct dirent *dp; char fromName[MAXPATHLEN]; char toName[MAXPATHLEN]; struct stat st; while ((dp = readdir(dir)) != NULL) { sprintf(fromName,"%s/%s",fromDirName,dp->d_name); sprintf(toName,"%s/%s",toDirName,dp->d_name); if (strcmp(dp->d_name,".") && strcmp(dp->d_name,"..")) { stat(fromName,&st); if (st.st_mode & S_IFDIR) { DIR *childdir; //printf(" is a directory\n"); if ((childdir = opendir(fromName)) == NULL) { fprintf(stderr,"Error: Couldn't open directory %s\n",fromName); exit(1); } if (!doFunc(fromName,toName,baseSrcName,baseToName, allowAppend,archiveExtension)) { fprintf(stderr,"Error: Failed executing doFunc\n"); exit(1); } /* Recurse here */ descendAndDo(childdir,fromName,toName,baseSrcName,baseFromName, baseToName,allowAppend,archiveExtension,doFunc); } else { if (!doFunc(fromName,toName,baseSrcName,baseToName, allowAppend,archiveExtension)) { fprintf(stderr,"Error: Failed executing doFunc\n"); exit(1); } } } } (void)closedir(dir); }
void QGenieSmartnetworkThread::doCmdTMSetEnable( const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<2) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameters"; return; } int iret; QString sret; QMap<QString,QString> paras; paras.insert("NewTrafficMeterEnable",reqlist[1]); doFunc(reqlist[0],"DeviceConfig","EnableTrafficMeter" ,&iret,&sret,paras); retlist<<QString::number(iret)<<sret; }
void evalStackPush(Stack *s, token val) { if(prefs.display.postfix) printf("\t%s\n", val); switch(tokenType(val)) { case function: { //token res; //operand = (token)stackPop(s); if (doFunc(s, val) < 0) return; //stackPush(s, res); } break; case expop: case multop: case addop: { if(stackSize(s) >= 2) { // Pop two operands // Evaluate if (doOp(s, val) < 0) return; // Push result //stackPush(s, res); } else { stackPush(s, val); } } break; case value: { stackPush(s, val); } break; default: break; } }
void QGenieSmartnetworkThread::doCmdIs5GOk(const QStringList &reqlist, QStringList &retlist) { retlist.clear(); int iret; QString sret; const QDomNode &node=doFunc(reqlist[0],"WLANConfiguration","Is5GSupported" ,&iret,&sret); if(iret!=0) { retlist<<QString::number(iret)<<sret; return; } QDomElement elem=node.firstChild().toElement(); retlist<<"000"; retlist<< elem.attribute("New5GSupported") ; }
void QGenieSmartnetworkThread::doCmdSetWireless( const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<5) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameter"; return; } QMap<QString,QString> paras; paras.insert("NewSSID",reqlist[1]); paras.insert("NewRegion",reqlist[2]); paras.insert("NewChannel",reqlist[3]); paras.insert("NewWirelessMode",reqlist[4]); bool bSecure=false; if(reqlist.count()>6 && reqlist[6]!="" && (0!=reqlist[5].compare("none",Qt::CaseInsensitive))) { bSecure=true; Q_ASSERT( (0==reqlist[5].compare("WPA-PSK/WPA2-PSK",Qt::CaseInsensitive)) ||(0==reqlist[5].compare("WPA2-PSK",Qt::CaseInsensitive)) ); paras.insert("NewWPAEncryptionModes",reqlist[5]); paras.insert("NewWPAPassphrase",reqlist[6]); } int iret; QString sret; /*const QDomNode &node=*/doFunc(reqlist[0] ,"WLANConfiguration" ,bSecure?"SetWLANWPAPSKByPassphrase":"SetWLANNoSecurity" ,&iret,&sret ,paras); retlist<<QString::number(iret)<<sret; }
void QGenieSmartnetworkThread::doCmdTMSetOption( const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<6) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameters"; return; } int iret; QString sret; QMap<QString,QString> paras; paras.insert("NewControlOption", reqlist[1]); paras.insert("NewMonthlyLimit", reqlist[2]); paras.insert("RestartHour", reqlist[3]); paras.insert("RestartMinute", reqlist[4]); paras.insert("RestartDay", reqlist[5]); doFunc(reqlist[0],"DeviceConfig","SetTrafficMeterOptions" ,&iret,&sret,paras); retlist<<QString::number(iret)<<sret; }
void QGenieSmartnetworkThread::doCmdAttachDevice(const QStringList &reqlist, QStringList &retlist) { retlist.clear(); if(reqlist.count()<1) { retlist<<"-1"<<"lack parameter"; return; } QMap<QString,QString> paras; int iret; QString sret; const QDomNode &node=doFunc(reqlist[0] ,"DeviceInfo" ,"GetAttachDevice" ,&iret,&sret ,paras); if(iret!=0) { retlist<<QString::number(iret)<<sret; return; } QDomElement elem=node.firstChild().toElement(); retlist<<elem.attribute("_responseCode"); QString stemp=elem.attribute("NewAttachDevice"); if(stemp.isEmpty()) { retlist<<"0"<<"0"; } else { //7@1;192.168.1.2;geines-Mac-mini;28:37:37:12:09:2F;wireless;54;86;Allow@2;192.168.1.6;xgywz-PC;00:1D:0F:33:08:1C;wireless;54;87;Allow@3;192.168.1.10;Android_359836041571187;A8:26:D9:CB:2E:A4;wireless;54;79;Allow@4;192.168.1.11;Android_357710047293728;64:A7:69:3F:E6:E9;wireless;54;67;Allow@5;192.168.1.14;android_8eb092bb95e89cf;C8:AA:21:80:A8:F1;wireless;54;87;Allow@6;192.168.1.15;--;28:37:37:12:C6:9D;wireless;54;86;Allow@7;192.168.1.29;PC2011110909BPO;14:E6:E4:06:F8:E8;wireless;54;92;Allow QRegExp reg("@\\d+;"); QStringList slist=stemp.split(reg); qDebug()<<slist; int c=slist.count(); if(c<1) { retlist<<"0"<<"0"; } else { retlist<<"0"; for(int i=0;i<c;i++) { QStringList ssublist=slist[i].split(";"); int cc=ssublist.count(); for(int j=0;j<cc;j++) { retlist<<ssublist[j]; } if(1==i) { retlist.insert(2,QString::number(cc)); } } } } }
void QGenieSmartnetworkThread::doCmdSet5GGaccInfo(const QStringList &reqlist, QStringList &retlist) { retlist.clear(); const int c=reqlist.count(); if(c<2) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameter"; return; } int iret; QString sret; QMap<QString,QString> paras; const QDomNode &node=doFunc(reqlist[0],"WLANConfiguration","Get5GGuestAccessEnabled" ,&iret,&sret); QDomElement elem=node.firstChild().toElement(); bool btemp; int ienabled=elem.attribute("NewGuestAccessEnabled").toInt(&btemp); if(iret!=0 ||!btemp ||(ienabled!=0 && ienabled!=1)) { retlist<<((iret!=0)?QString::number(ienabled):"-30")<<sret; return; } if(reqlist[1]=="0") { if(ienabled !=0) { int itemp; QString stemp; paras.clear(); paras.insert("NewGuestAccessEnabled","0"); /*const QDomNode &node1=*/doFunc(reqlist[0],"WLANConfiguration","Set5GGuestAccessEnabled" ,&itemp,&stemp,paras); retlist<<QString::number(itemp)<<stemp; return; } else { retlist<<"000"<<"already disabled"; } } else { if(c<5) { retlist<<QString::number(FE_LACK_PARAMETER)<<"lack parameters 2"; return; } int itemp; QString stemp; paras.clear(); paras.clear(); paras.insert("NewSSID",reqlist[2]); paras.insert("NewSecurityMode",reqlist[3]); paras.insert("NewKey1",reqlist[4]); paras.insert("NewKey2","0"); paras.insert("NewKey3","0"); paras.insert("NewGuestAccessEnabled",reqlist[1]); /* const QDomNode &node2=*/doFunc(reqlist[0],"WLANConfiguration" ,"Set5GGuestAccessEnabled2" ,&itemp,&stemp,paras); retlist<<QString::number(itemp); return; } }
void QGenieSmartnetworkThread::doCmdGet5GInfo(const QStringList &reqlist, QStringList &retlist) { QDomElement elem; retlist.clear(); int c=reqlist.count(); if(c<1) { retlist<<QString::number(FE_LACK_PARAMETER)<<"not enough parameters"; return; } int itemp; QString stemp; const QDomNode &_node=doFunc(reqlist[0],"WLANConfiguration","Get5GInfo" ,&itemp,&stemp); if(itemp!=0 ) { retlist<<QString::number(itemp)<<stemp; return; } elem=_node.firstChild().toElement(); const char *cParas[]={ "NewSSID","NewRegion","NewChannel","NewWirelessMode","NewWLANMACAddress" }; for(int i=0;i<sizeof(cParas)/sizeof(cParas[0]);i++) { retlist<<elem.attribute(cParas[i]); } ////////////////////////////////////////////////// ////////////////////////////////////////////////// QString secure_mode=elem.attribute("NewBasicEncryptionModes"); QString secure_wep=elem.attribute("NewWEPAuthType"); if((0==secure_mode.compare("wep",Qt::CaseInsensitive)) ||(0==secure_mode.compare("wep64",Qt::CaseInsensitive)) || (0==secure_mode.compare("wep128",Qt::CaseInsensitive)) // || (0==secure_mode.compare("WPA2-PSK[AES]",Qt::CaseInsensitive)) ) { const QDomNode &_node0=doFunc(reqlist[0],"WLANConfiguration","Get5GWEPSecurityKeys" ,&itemp,&stemp); if(itemp!=0) { retlist.clear(); retlist<<QString::number(itemp)<<stemp; return; } elem=_node0.firstChild().toElement(); retlist.insert(0,elem.attribute("_responseCode")); retlist<<secure_mode<<elem.attribute("NewWEPKey"); } else if( (0==secure_mode.compare("wpa2-psk",Qt::CaseInsensitive)) || (0==secure_mode.compare("wpa-psk/wpa2-psk",Qt::CaseInsensitive)) || (0==secure_mode.compare("wpa-psk",Qt::CaseInsensitive)) || (0==secure_mode.compare("mixed wpa",Qt::CaseInsensitive)) ) { const QDomNode &_node1=doFunc(reqlist[0],"WLANConfiguration","Get5GWPASecurityKeys" ,&itemp,&stemp); if(itemp!=0) { retlist.clear(); retlist<<QString::number(itemp)<<stemp; return; } elem=_node1.firstChild().toElement(); retlist.insert(0,elem.attribute("_responseCode")); retlist<<secure_mode<<secure_wep<<elem.attribute("NewWPAPassphrase"); } else { retlist.insert(0,"000"); retlist<<"None"<<""<<""; } }
bool SVT_Soap::doFunc(const char *host, const char *module, const char *method ,const QMap<QString,QString> *paras,QMap<QString,QString> *retmap) { return doFunc(QString(host),QString(module),QString(method),paras,retmap); }