Commit 9a0a0882edb130d9d272386a108933144cd286d0

Authored by 고영탁
1 parent fd95b2247a
Exists in master and in 2 other branches fhd, fhd-demo

쿡북 파일 압축 암호화 기능 추가

app/gui/oven_control/fileprocessdlg.cpp
1 1 #include <QTimer>
2 2 #include <unistd.h>
  3 +#include <QProcess>
3 4 #include "fileprocessdlg.h"
4 5 #include "ui_fileprocessdlg.h"
5 6 #include "fileprocessor.h"
... ... @@ -37,7 +38,7 @@ void ProgramCopyWorker::workerMain(){
37 38 QStringList strdirlist;
38 39 QString srcFilepath;
39 40 QString destFilePath;
40   - bool m_bRst=true;
  41 + bool bRst=true;
41 42  
42 43 //make destination folder
43 44 QDir destdir(m_strDestDir);
... ... @@ -60,9 +61,10 @@ void ProgramCopyWorker::workerMain(){
60 61 qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize;
61 62 if(nTotalFileSize <=0 ){
62 63 emit errorFired("SIZE ERROR ");
63   - QThread::currentThread()->msleep(5000);
64   - emit finished();
  64 + QThread::currentThread()->msleep(1000);
  65 + bRst = false;
65 66 emit progressed(0,0);
  67 + emit finished();
66 68 return;
67 69 }
68 70  
... ... @@ -80,7 +82,7 @@ void ProgramCopyWorker::workerMain(){
80 82 }
81 83 if(QFile::copy(srcFilepath,destFilePath)==false){
82 84 qDebug() << srcFilepath << " file copy fail!";
83   - m_bRst = false;
  85 + bRst = false;
84 86 emit errorFired(finfo.fileName());
85 87 QThread::currentThread()->msleep(5000);
86 88 break;
... ... @@ -99,14 +101,14 @@ void ProgramCopyWorker::workerMain(){
99 101  
100 102 qDebug() << "File List Copy Finished";
101 103  
102   - if(QThread::currentThread()->isInterruptionRequested() == false || m_bRst == false){
  104 + if(QThread::currentThread()->isInterruptionRequested() == false || bRst == false){
103 105 foreach(QString srcpath, m_arrSrcDirList){
104 106 qDebug() << "src dir : " << srcpath;
105 107  
106 108 QDir srcdir(srcpath);
107 109 if(srcdir.exists() == false){
108 110 qDebug() << "Source Dir is not exist";
109   - m_bRst = false;
  111 + bRst = false;
110 112 emit errorFired("DIR not exist");
111 113 QThread::currentThread()->msleep(5000);
112 114 break;
... ... @@ -133,7 +135,7 @@ void ProgramCopyWorker::workerMain(){
133 135 srcFilepath = finfo.absoluteFilePath();
134 136 destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName());
135 137 if(QFile::copy(srcFilepath, destFilePath)==false){
136   - m_bRst = false;
  138 + bRst = false;
137 139 emit errorFired(finfo.fileName());
138 140 qDebug() << srcFilepath << " file copy fail!";
139 141 QThread::currentThread()->msleep(5000);
... ... @@ -151,7 +153,7 @@ void ProgramCopyWorker::workerMain(){
151 153 }
152 154 //QThread::currentThread()->msleep(100);
153 155 }
154   - if(QThread::currentThread()->isInterruptionRequested() || m_bRst == false) break;
  156 + if(QThread::currentThread()->isInterruptionRequested() || bRst == false) break;
155 157 }
156 158 strdirlist.clear();
157 159 if(QThread::currentThread()->isInterruptionRequested()) break;
... ... @@ -159,7 +161,7 @@ void ProgramCopyWorker::workerMain(){
159 161 }
160 162 qDebug() << "File Copy Complete! SRC File Size = " << nTotalFileSize << "DEST File Size = " << nCpyFileSize;
161 163  
162   - if(QThread::currentThread()->isInterruptionRequested() || m_bRst == false){
  164 + if(QThread::currentThread()->isInterruptionRequested() || bRst == false){
163 165 foreach(QString strinfo, m_arrSrcFileList){
164 166 QString filepath = strinfo.left(strinfo.indexOf(',',0)+1);
165 167 QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1));
... ... @@ -253,6 +255,9 @@ FileProcessDlg::FileProcessDlg(QWidget *parent, ConfigType type, bool isDown) :
253 255 this->setFocus();
254 256 ui->ctrBtnCancel->setFocus();
255 257  
  258 + m_bRst = true;
  259 + m_nCfgtype = type;
  260 +
256 261 ui->ctrWjProcess->setMinimum(0);
257 262 ui->ctrWjProcess->setMaximum(100);
258 263  
... ... @@ -584,12 +589,71 @@ void FileProcessDlg::programDownload(){
584 589 }
585 590  
586 591 void FileProcessDlg::onProgressFinished(){
  592 + QString strDescPath;
  593 + QString strZipCmd;
  594 + m_bRst = true;
  595 + QProcess process;
  596 +
  597 + FileProcessor::detectUSB(strDescPath);
  598 +
  599 + strZipCmd = QString("sh -c \"unzip -P 1234 %1/prime/prime.zip -d /prime\"").arg(strDescPath);
  600 + QFileInfo info(QString("%1/prime/prime.zip").arg(strDescPath));
  601 +
  602 +
  603 + QDir cookbooksrc("/prime/cookbook");
  604 + QDir cookBookback("/prime/cookbook_back");
  605 + QDir multibooksrc("/prime/multi");
  606 + QDir multibookback("/prime/multi_back");
  607 +
  608 + qDebug() << info.absoluteFilePath();
  609 +
  610 + if(m_nCfgtype == config_program_upload && m_bRst && info.exists()==true){
  611 + if(cookbooksrc.exists()){
  612 + if(cookBookback.exists()){
  613 + process.start("sh -c \"rm -r /prime/cookbook_back\"");
  614 + process.waitForFinished();
  615 + process.start("sync");
  616 + process.waitForFinished();
  617 + }
  618 + qDebug() << "cook book exists";
  619 + process.start("sh -c \"mv /prime/cookbook /prime/cookbook_back\"");
  620 + process.waitForFinished();
  621 + process.start("sync");
  622 + process.waitForFinished();
  623 + }
  624 +
  625 + if(multibooksrc.exists()){
  626 + if(multibookback.exists()){
  627 + process.start("sh -c \"rm -r /prime/multi_back\"");
  628 + process.waitForFinished();
  629 + process.start("sync");
  630 + process.waitForFinished();
  631 + }
  632 + qDebug() << "multi book exists";
  633 + process.start("sh -c \"mv /prime/multi /prime/multi_back\"");
  634 + process.waitForFinished();
  635 + process.start("sync");
  636 + process.waitForFinished();
  637 + }
  638 +
  639 + qDebug() << "cook book upload";
  640 + qDebug() << QTime::currentTime();
  641 +
  642 + process.start(strZipCmd);
  643 + if(process.waitForFinished(120000)==false){
  644 + ui->ctrLbRemainTime->setText("Cook book copy fail");
  645 + }
  646 + process.start("sync");
  647 + process.waitForFinished();
  648 + qDebug() << QTime::currentTime();
  649 + }
587 650 ui->ctrLbRemainTime->setText(tr("완료"));
588 651 QTimer::singleShot(1000,this, SLOT(close()));
589 652 }
590 653  
591 654 void FileProcessDlg::onErrorFired(QString Desc)
592 655 {
  656 + m_bRst = false;
593 657 ui->ctrLbRemainTime->setText(QString("%1 %2").arg(Desc).arg(tr("에러 발생으로 종료합니다.")));
594 658 //QTimer::singleShot(1000,this, SLOT(close()));
595 659 }
... ... @@ -614,6 +678,9 @@ void FileProcessDlg::programUpload(){
614 678 QString strDescPath;
615 679 QString strSrcPath;
616 680  
  681 +
  682 +
  683 +
617 684 if(FileProcessor::detectUSB(strSrcPath)){
618 685 worker.addSrcFile(QString("%1/prime/superdaemon,/prime").arg(strSrcPath));
619 686 worker.addSrcFile(QString("%1/prime/superdaemon.ini,/prime").arg(strSrcPath));
... ...
app/gui/oven_control/fileprocessdlg.h
... ... @@ -82,6 +82,7 @@ private:
82 82 ConfigType m_nCfgtype;
83 83 QThread programCopyThd;
84 84 ProgramCopyWorker worker;
  85 + bool m_bRst;
85 86 };
86 87  
87 88 #endif // FILEPROCESSDLG_H
... ...