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 #include <QTimer> 1 #include <QTimer>
2 #include <unistd.h> 2 #include <unistd.h>
  3 +#include <QProcess>
3 #include "fileprocessdlg.h" 4 #include "fileprocessdlg.h"
4 #include "ui_fileprocessdlg.h" 5 #include "ui_fileprocessdlg.h"
5 #include "fileprocessor.h" 6 #include "fileprocessor.h"
@@ -37,7 +38,7 @@ void ProgramCopyWorker::workerMain(){ @@ -37,7 +38,7 @@ void ProgramCopyWorker::workerMain(){
37 QStringList strdirlist; 38 QStringList strdirlist;
38 QString srcFilepath; 39 QString srcFilepath;
39 QString destFilePath; 40 QString destFilePath;
40 - bool m_bRst=true; 41 + bool bRst=true;
41 42
42 //make destination folder 43 //make destination folder
43 QDir destdir(m_strDestDir); 44 QDir destdir(m_strDestDir);
@@ -60,9 +61,10 @@ void ProgramCopyWorker::workerMain(){ @@ -60,9 +61,10 @@ void ProgramCopyWorker::workerMain(){
60 qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize; 61 qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize;
61 if(nTotalFileSize <=0 ){ 62 if(nTotalFileSize <=0 ){
62 emit errorFired("SIZE ERROR "); 63 emit errorFired("SIZE ERROR ");
63 - QThread::currentThread()->msleep(5000);  
64 - emit finished(); 64 + QThread::currentThread()->msleep(1000);
  65 + bRst = false;
65 emit progressed(0,0); 66 emit progressed(0,0);
  67 + emit finished();
66 return; 68 return;
67 } 69 }
68 70
@@ -80,7 +82,7 @@ void ProgramCopyWorker::workerMain(){ @@ -80,7 +82,7 @@ void ProgramCopyWorker::workerMain(){
80 } 82 }
81 if(QFile::copy(srcFilepath,destFilePath)==false){ 83 if(QFile::copy(srcFilepath,destFilePath)==false){
82 qDebug() << srcFilepath << " file copy fail!"; 84 qDebug() << srcFilepath << " file copy fail!";
83 - m_bRst = false; 85 + bRst = false;
84 emit errorFired(finfo.fileName()); 86 emit errorFired(finfo.fileName());
85 QThread::currentThread()->msleep(5000); 87 QThread::currentThread()->msleep(5000);
86 break; 88 break;
@@ -99,14 +101,14 @@ void ProgramCopyWorker::workerMain(){ @@ -99,14 +101,14 @@ void ProgramCopyWorker::workerMain(){
99 101
100 qDebug() << "File List Copy Finished"; 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 foreach(QString srcpath, m_arrSrcDirList){ 105 foreach(QString srcpath, m_arrSrcDirList){
104 qDebug() << "src dir : " << srcpath; 106 qDebug() << "src dir : " << srcpath;
105 107
106 QDir srcdir(srcpath); 108 QDir srcdir(srcpath);
107 if(srcdir.exists() == false){ 109 if(srcdir.exists() == false){
108 qDebug() << "Source Dir is not exist"; 110 qDebug() << "Source Dir is not exist";
109 - m_bRst = false; 111 + bRst = false;
110 emit errorFired("DIR not exist"); 112 emit errorFired("DIR not exist");
111 QThread::currentThread()->msleep(5000); 113 QThread::currentThread()->msleep(5000);
112 break; 114 break;
@@ -133,7 +135,7 @@ void ProgramCopyWorker::workerMain(){ @@ -133,7 +135,7 @@ void ProgramCopyWorker::workerMain(){
133 srcFilepath = finfo.absoluteFilePath(); 135 srcFilepath = finfo.absoluteFilePath();
134 destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName()); 136 destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName());
135 if(QFile::copy(srcFilepath, destFilePath)==false){ 137 if(QFile::copy(srcFilepath, destFilePath)==false){
136 - m_bRst = false; 138 + bRst = false;
137 emit errorFired(finfo.fileName()); 139 emit errorFired(finfo.fileName());
138 qDebug() << srcFilepath << " file copy fail!"; 140 qDebug() << srcFilepath << " file copy fail!";
139 QThread::currentThread()->msleep(5000); 141 QThread::currentThread()->msleep(5000);
@@ -151,7 +153,7 @@ void ProgramCopyWorker::workerMain(){ @@ -151,7 +153,7 @@ void ProgramCopyWorker::workerMain(){
151 } 153 }
152 //QThread::currentThread()->msleep(100); 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 strdirlist.clear(); 158 strdirlist.clear();
157 if(QThread::currentThread()->isInterruptionRequested()) break; 159 if(QThread::currentThread()->isInterruptionRequested()) break;
@@ -159,7 +161,7 @@ void ProgramCopyWorker::workerMain(){ @@ -159,7 +161,7 @@ void ProgramCopyWorker::workerMain(){
159 } 161 }
160 qDebug() << "File Copy Complete! SRC File Size = " << nTotalFileSize << "DEST File Size = " << nCpyFileSize; 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 foreach(QString strinfo, m_arrSrcFileList){ 165 foreach(QString strinfo, m_arrSrcFileList){
164 QString filepath = strinfo.left(strinfo.indexOf(',',0)+1); 166 QString filepath = strinfo.left(strinfo.indexOf(',',0)+1);
165 QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1)); 167 QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1));
@@ -253,6 +255,9 @@ FileProcessDlg::FileProcessDlg(QWidget *parent, ConfigType type, bool isDown) : @@ -253,6 +255,9 @@ FileProcessDlg::FileProcessDlg(QWidget *parent, ConfigType type, bool isDown) :
253 this->setFocus(); 255 this->setFocus();
254 ui->ctrBtnCancel->setFocus(); 256 ui->ctrBtnCancel->setFocus();
255 257
  258 + m_bRst = true;
  259 + m_nCfgtype = type;
  260 +
256 ui->ctrWjProcess->setMinimum(0); 261 ui->ctrWjProcess->setMinimum(0);
257 ui->ctrWjProcess->setMaximum(100); 262 ui->ctrWjProcess->setMaximum(100);
258 263
@@ -584,12 +589,71 @@ void FileProcessDlg::programDownload(){ @@ -584,12 +589,71 @@ void FileProcessDlg::programDownload(){
584 } 589 }
585 590
586 void FileProcessDlg::onProgressFinished(){ 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 ui->ctrLbRemainTime->setText(tr("완료")); 650 ui->ctrLbRemainTime->setText(tr("완료"));
588 QTimer::singleShot(1000,this, SLOT(close())); 651 QTimer::singleShot(1000,this, SLOT(close()));
589 } 652 }
590 653
591 void FileProcessDlg::onErrorFired(QString Desc) 654 void FileProcessDlg::onErrorFired(QString Desc)
592 { 655 {
  656 + m_bRst = false;
593 ui->ctrLbRemainTime->setText(QString("%1 %2").arg(Desc).arg(tr("에러 발생으로 종료합니다."))); 657 ui->ctrLbRemainTime->setText(QString("%1 %2").arg(Desc).arg(tr("에러 발생으로 종료합니다.")));
594 //QTimer::singleShot(1000,this, SLOT(close())); 658 //QTimer::singleShot(1000,this, SLOT(close()));
595 } 659 }
@@ -614,6 +678,9 @@ void FileProcessDlg::programUpload(){ @@ -614,6 +678,9 @@ void FileProcessDlg::programUpload(){
614 QString strDescPath; 678 QString strDescPath;
615 QString strSrcPath; 679 QString strSrcPath;
616 680
  681 +
  682 +
  683 +
617 if(FileProcessor::detectUSB(strSrcPath)){ 684 if(FileProcessor::detectUSB(strSrcPath)){
618 worker.addSrcFile(QString("%1/prime/superdaemon,/prime").arg(strSrcPath)); 685 worker.addSrcFile(QString("%1/prime/superdaemon,/prime").arg(strSrcPath));
619 worker.addSrcFile(QString("%1/prime/superdaemon.ini,/prime").arg(strSrcPath)); 686 worker.addSrcFile(QString("%1/prime/superdaemon.ini,/prime").arg(strSrcPath));
app/gui/oven_control/fileprocessdlg.h
@@ -82,6 +82,7 @@ private: @@ -82,6 +82,7 @@ private:
82 ConfigType m_nCfgtype; 82 ConfigType m_nCfgtype;
83 QThread programCopyThd; 83 QThread programCopyThd;
84 ProgramCopyWorker worker; 84 ProgramCopyWorker worker;
  85 + bool m_bRst;
85 }; 86 };
86 87
87 #endif // FILEPROCESSDLG_H 88 #endif // FILEPROCESSDLG_H