Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 247 → Rev 248

/trunk/DBViewer/database.cpp
1009,8 → 1009,13
i++;
wmiProcess.start(program);
*/
MainWindow::getWmiVideoGard(tr("192.168.0.101"), tr("admin"), tr("samba"));
 
TWmiVideoCard vCard;
 
vCard = MainWindow::getWmiVideoGard(tr("192.168.0.135"), tr("Àäìèíèñòðàòîð"), tr("Patr10t"));
int i;
i++;
 
}
 
 
/trunk/DBViewer/mainwindow.cpp
1821,11 → 1821,12
TWmiVideoCard MainWindow::getWmiVideoGard(QString host, QString user_name, QString password){
TWmiVideoCard result;
bool ok;
QString ansver_string;
// wmiThread.moveToThread(&wmiThread);
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("select * from Win32_ComputerSystem"));
wmiThread.setWmiString(tr("select Name, AdapterCompatibility, AdapterRAM, VideoProcessor from Win32_VideoController"));
wmiThread.start(QThread::NormalPriority);
//for (;;) {if (wmiThread.isStopped()) break;}
int t;
1834,6 → 1835,33
 
ok = wmiThread.wait(10000);
if (ok){
QTextDocument * wmiDoc = ui->textEdit_2->document();
QTextCursor * wmiCursor;
QStringList split_new_line; //
QStringList fields_list; //â ýòîì ñïèñêå ñîõðàíèì ïîëÿ
QStringList values_list; //à â ýòîì ñïèñêå - çíà÷åíèÿ
wmiCursor = new QTextCursor(wmiDoc);
ansver_string = wmiThread.resultString();
wmiCursor->insertText(ansver_string);
split_new_line = ansver_string.split("\n", QString::SkipEmptyParts); // ðàçáèâàåíì îòâåò íà ñòðîêè
if(split_new_line.count()>2) {
QString tmp_str;
tmp_str = split_new_line.at(1);
fields_list = tmp_str.split("|");
tmp_str = split_new_line.at(2);
values_list = tmp_str.split("|");
int index_tmp;
index_tmp = fields_list.indexOf(tr("AdapterCompatibility")); // ïðîèçâîäèòåëü
if (index_tmp!=-1) result.manufacturer = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("Name")); // íàçâàíèå âèäåîêàðòû
if (index_tmp!=-1) result.name = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("VideoProcessor")); // ìîäåëü
if (index_tmp!=-1) result.model = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("AdapterRAM")); // ìîäåëü
if (index_tmp!=-1) result.video_ram = QVariant(values_list.at(index_tmp)).asInt();
return result;
}
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò
int m;
m++;
}
/trunk/DBViewer/mainwindow.h
55,6 → 55,7
QString name; // íàçâàíèå âèäåîêàðòû
QString manufacturer; // ïðîèçâîäèòåëü
QString model;
int video_ram;
 
} TWmiVideoCard;
 
/trunk/DBViewer/wmithread.cpp
24,9 → 24,9
// connect(&woker, SIGNAL(workEnd()), this, SLOT(wokerIsStopped()));
connect(&woker, SIGNAL(workEnd()), &loop, SLOT(quit()));
 
/*
 
QString query_string;
error = false; //ñáðîñèì ôëàã îøèáêè
// error = false; //ñáðîñèì ôëàã îøèáêè
query_string = tr("wmic -U ");
query_string.append(user_name);
query_string.append(tr("%"));
37,15 → 37,15
query_string.append(wmi_string);
query_string.append(tr("\""));
// process.start(query_string);
process.start("ls\n");
// process.start("ls\n");
// while (!stopped) {;}
 
*/
 
 
woker.setProcessString(query_string);
woker.startProcess();
 
loop.exec();
p_buffer = woker.workBuffer();
}
 
void WmiThread::stop(){
/trunk/DBViewer/wmithread.h
26,8 → 26,15
return stopped;
mutex.unlock();
 
};
}
void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;}
QString resultString(){
QTextCodec *codec = QTextCodec::codecForName("cp1251");
QTextCodec *codecUTF = QTextCodec::codecForName("utf8");
QTextCodec::setCodecForTr(codecUTF);
return QString(tr(p_buffer));
QTextCodec::setCodecForTr(codec);
}
volatile bool stopped;
private:
 
/trunk/DBViewer/woker.h
12,15 → 12,16
Q_OBJECT
public:
explicit Woker(QObject *parent = 0);
void startProcess(){work_process.start("ls\n");}
void startProcess(){work_process.start(process_string);}
void setProcessString(QString new_string){process_string = new_string;};
QByteArray workBuffer(){return work_buffer;}
 
private:
QProcess work_process;
QByteArray work_buffer; //здесь будем хранить данные, считанные из стандартного потока для чтения (процесса)
volatile bool * pstoped; //óêàçàòåëü íà ïåðåìåííóþ stopped ðîäèòåëüñêîãî êëàññà (ïîòîêà)
QString process_string; //ñòðîêà áóäåò ñîäåðæàòü òåêñò çàïðîñà (êîìàíäó)
 
 
 
signals:
void workEnd();
public slots: