void MainWindow::checkStatus() { int a[4] = {0,0,0,0}; int tempI = 0, i=0, tempI2 = 0; QDateTime TimeNow; QString dateUNIXNow; QSettings *GlobalSettings = new QSettings("/root/.WiFiHostapdAP/WiFi_Hostapd_AP.conf",QSettings::NativeFormat); // создание нового объекта bool starting = true; bool test; QString temp_QT; qDebug() << "Testing AP... "; //////////////////////////////////////////////////////////////////////////////////////////// // Активирована ли точка доступа? //////////////////////////////////////////////////////////////////////////////////////////// // точка доступа активирована, если // 1. Статус устройства //////////////////////////////////////////////////////////////////////////////////////////// CheckProcess IFace(1,GlobalSettings->value("AP/Iface", "wlan0").toString()); if(!IFace.init()) { starting=false; a[0]=0; qDebug() << "DEVICE - " << "OFF"; } else { qDebug() << "DEVICE - " << "ON"; a[0]=1; } // 2. Статус DNSMASQ //////////////////////////////////////////////////////////////////////////////////////////// CheckProcess DNSMASQcheck("dnsmasq"); test = DNSMASQcheck.init(); if(test) { qDebug() << "DNSMASQ - " << "ON"; a[1]=1; } else { starting=false; a[1]=0; qDebug() << "DNSMASQ - " << "OFF"; } // 3. Статус Hostapd //////////////////////////////////////////////////////////////////////////////////////////// CheckProcess HOSTAPDcheck("hostapd"); test = HOSTAPDcheck.init(); if(!test) { starting=false; a[2]=0; qDebug() << "HOSTAPD - " << "OFF"; } else { qDebug() << "HOSTAPD - " << "ON"; a[2]=1; } // 4. Статус IP Forwarding //////////////////////////////////////////////////////////////////////////////////////////// CheckProcess IPForwarding(2, ""); if(!IPForwarding.init()) { starting=false; a[3]=0; qDebug() << "IP FORWARDING - " << "OFF"; } else { qDebug() << "IP FORWARDING - " << "ON"; a[3]=1; } //////////////////////////////////////////////////////////////////////////////////////////// if(starting==true) { ui->identificator->setText(tr("<h3><font color=\"green\">Активировано</font></h3>")); ui->StatusIcon->setPixmap(QPixmap(":/pic/icons/dialog-ok-apply.png")); ui->Activate->setEnabled(false); ui->Disactive->setEnabled(true); qDebug() << "AP IS RUNNING \n"; dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t()); LogSystemAppend(QString("%1|%2|%3|%4").arg(tr("Programm"), dateUNIXNow, tr("AP online"), QString("0"))); } else { ui->identificator->setText(tr("<h3><font color=\"red\">Отключена</font></h3>")); ui->StatusIcon->setPixmap(QPixmap(":/pic/icons/dialog-close.png")); ui->Activate->setEnabled(true); ui->Disactive->setEnabled(false); qDebug() << "AP IS NOT RUNNING\n"; //////////////////////////////////////////////////////////////////////////////////////////// // Выясняем, что не так //////////////////////////////////////////////////////////////////////////////////////////// for(i=0;i<4;i++) if(a[i]==0) tempI++; // Считаем, сколько пунктов не активны temp_QT.clear(); temp_QT = tr("AP offline because "); if(a[0]==0) { temp_QT.append(tr("network interface is down")); tempI2++; if(tempI>tempI2) temp_QT.append(tr(" and ")); } if(a[1]==0) { temp_QT.append(tr("DNSMASQ offline")); tempI2++; if(tempI>tempI2) temp_QT.append(tr(" and ")); } if(a[2]==0) { temp_QT.append(tr("Hostapd offline")); tempI2++; if(tempI>tempI2) temp_QT.append(tr(" and ")); } if(a[3]==0) { temp_QT.append(tr("IP Forward disabled")); } temp_QT.append(tr(".")); dateUNIXNow = QString::number(TimeNow.currentDateTime().toTime_t()); LogSystemAppend(QString("%1|%2|%3|%4").arg(tr("Programm"), dateUNIXNow, temp_QT, QString("0"))); } //////////////////////////////////////////////////////////////////////////////////////////// delete GlobalSettings; }
bool CBaseToolApp::Connect( const CreateInterfaceFn* pFactories, const size_t uiNumFactories ) { if( !LoadAndCheckInterfaces( pFactories, uiNumFactories, IFace( ICVARSYSTEM_NAME, g_pCVar, "CVar System" ), IFace( IFILESYSTEM_NAME, m_pFileSystem, "File System" ), IFace( ISOUNDSYSTEM_NAME, m_pSoundSystem, "Sound System" ), IFace( IRENDERERLIBRARY_NAME, m_pRendererLib, "Render Library" ), IFace( IRENDERCONTEXT_NAME, g_pRenderContext, "Render Context" ), IFace( ISTUDIOMODELRENDERER_NAME, g_pStudioMdlRenderer, "StudioModel Renderer" ) ) ) { return false; } g_pSoundSystem = m_pSoundSystem; if( !g_pCVar->Initialize() ) { FatalError( "Failed to initialize CVar system!\n" ); return false; } //Connect Core lib cvars first. ConnectCoreCVars( g_pCVar ); cvar::ConnectCVars(); if( !m_pFileSystem->Initialize() ) { FatalError( "Failed to initialize file system!\n" ); return false; } if( !InitOpenGL() ) { return false; } if( !m_pRendererLib->Connect( pFactories, uiNumFactories ) ) { FatalError( "Failed to connect renderer!\n" ); return false; } if( !g_pStudioMdlRenderer->Initialize() ) { FatalError( "Failed to initialize StudioModel renderer!\n" ); return false; } if( !m_pSoundSystem->Connect( pFactories, uiNumFactories ) ) { FatalError( "Failed to connect sound system!\n" ); return false; } if( !m_pSoundSystem->Initialize() ) { FatalError( "Failed to initialize sound system!\n" ); return false; } return true; }