Subversion Repositories OpenInventory

Rev

Rev 243 | Rev 247 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#include "wmithread.h"

WmiThread::WmiThread(QObject *parent) :
    QThread(parent)
{
  //  woker.moveToThread(this);
    mutex.lock();
    stopped = false;
    mutex.unlock();

 //   connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
 //   connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));



}

void WmiThread::run(){


   QEventLoop * loop = new QEventLoop();
    Woker woker; // îáúåêò äëÿ ðàáîòû â òåëå ïîòîêà

    // connect(&woker, SIGNAL(workEnd()), this, SLOT(wokerIsStopped()));
connect(&woker, SIGNAL(workEnd()), loop, SLOT(quit()));

/*
    QString query_string;
    error = false; //ñáðîñèì ôëàã îøèáêè
    query_string = tr("wmic -U ");
    query_string.append(user_name);
    query_string.append(tr("%"));
    query_string.append(password);
    query_string.append(tr(" //"));
    query_string.append(host);
    query_string.append(tr(" \""));
    query_string.append(wmi_string);
    query_string.append(tr("\""));
    // process.start(query_string);
    process.start("ls\n");
//    while (!stopped) {;}

*/



    woker.startProcess();

    loop->exec();
}

void WmiThread::stop(){
      mutex.lock();
      stopped = true;
      mutex.unlock();
}

void WmiThread::readStandartProcessOutput(){
p_buffer = process.readAllStandardOutput();
 qDebug() << QString(p_buffer);
mutex.lock();
stopped = true;
mutex.unlock();
process.close();
exit();
}

void WmiThread::readStandartProcessError(){
p_buffer = process.readAllStandardError();
error = true; // åñëè îøèáêà, óñòàíîâèì ôëàã îøèáêè âûïîëíåíèÿ WMI-çàïðîñà
}


void WmiThread::wokerIsStopped(){
exit();
}