Subversion Repositories OpenInventory

Rev

Rev 241 | Rev 243 | 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)
{
    process.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(){




    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) {;}
    exec();
   // quit();
}

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-çàïðîñà
}