From f49a451be52c89d5c5b51603101c116e155bf6c3 Mon Sep 17 00:00:00 2001 From: splenectom Date: Mon, 7 Oct 2019 15:19:10 +0300 Subject: [PATCH] Comment updater. Not needed. --- config/gerber_translator.ini | 30 ---- main.cpp | 30 ++-- updater.cpp | 282 +++++++++++++++++------------------ updater.h | 20 +-- 4 files changed, 166 insertions(+), 196 deletions(-) delete mode 100644 config/gerber_translator.ini diff --git a/config/gerber_translator.ini b/config/gerber_translator.ini deleted file mode 100644 index 51feb56..0000000 --- a/config/gerber_translator.ini +++ /dev/null @@ -1,30 +0,0 @@ -open_path=/home/sergey/qtprojects/gerber_examples/[gerbers]/6-USK.04-58.100[695.1040.02]/Gerber -save_path=/home/sergey/qtprojects/temp -image_format=png -dpi=150 -quick_translation=off -open_folder_after_processing=on -image_size=by_outline -default_image_width=100 -default_image_height=100 -default_dx=0 -default_dy=0 -opacity_mode=off -opacity_value=0.8 -frame_thickness=1 - -% Comments: -% open_path = [default open path] -% save_path = [default save path] -% image_format = [bmp][png] -% dpi = [resolution] -% quick_translation = [on][off] -% open_folder_after_processing = [on][off] -% image_size = [by_outline][by_ini] -% default_image_width = [default board width] -% default_image_height = [default board height] -% default_dx = [default board origin offset] -% default_dy = [default board origin offset] -% opacity_mode = [on][off] -% opacity_value = [opacity - real from 0 to 1] -% frame_thickness = [thickness of fields around the image in mm] \ No newline at end of file diff --git a/main.cpp b/main.cpp index 7e96dff..43705e9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,5 @@ #include "controller.h" -#include "updater.h" +//#include "updater.h" #include #include #include @@ -8,20 +8,20 @@ int main(int argc, char *argv[]) { - // запуск апдейта - int was_update_succesfull = 0; - was_update_succesfull = update(); - switch (was_update_succesfull) { - case -1:{ - qDebug()<< "Failed to update the current version of the program! The old version will be launched..."; - } break; - case 1:{ - qDebug()<< "Current version will be updated!"; - } return 1; - case 2:{ - qDebug()<< "No update required!"; - } break; - } + +// int was_update_succesfull = 0; +// was_update_succesfull = update(); +// switch (was_update_succesfull) { +// case -1:{ +// qDebug()<< "Failed to update the current version of the program! The old version will be launched..."; +// } break; +// case 1:{ +// qDebug()<< "Current version will be updated!"; +// } return 1; +// case 2:{ +// qDebug()<< "No update required!"; +// } break; +// } QApplication a(argc, argv); diff --git a/updater.cpp b/updater.cpp index 924954f..b927387 100644 --- a/updater.cpp +++ b/updater.cpp @@ -1,151 +1,151 @@ -#include "updater.h" +//#include "updater.h" -int update(){ +//int update(){ - int local_version=0; - int actual_version=0; - QString platform="windows"; - QString bit="64"; - QString extension=""; +// int local_version=0; +// int actual_version=0; +// QString platform="windows"; +// QString bit="64"; +// QString extension=""; - QString local_ver_file_name; //(not full path) - QString local_version_text=""; // - QString local_app_name; //local application path (not full path) - QFileInfo local_app; // - QString updater_name; //updater path (not full path) - QFileInfo updater; // - QString actual_path; //path to actual versions - QString actual_ver_file_name; //absolute path for actual version file - QString actual_version_text=""; // - QString actual_app_path; //absolute path for actual version of application +// QString local_ver_file_name; //(not full path) +// QString local_version_text=""; // +// QString local_app_name; //local application path (not full path) +// QFileInfo local_app; // +// QString updater_name; //updater path (not full path) +// QFileInfo updater; // +// QString actual_path; //path to actual versions +// QString actual_ver_file_name; //absolute path for actual version file +// QString actual_version_text=""; // +// QString actual_app_path; //absolute path for actual version of application - qDebug()<<"Checking updates..."; - local_ver_file_name = "gt_version"; - QFile loc_version_file(local_ver_file_name); - if(!loc_version_file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can not open local version file!"; - return -1; - } - while (!loc_version_file.atEnd()){ - QByteArray str = loc_version_file.readLine().trimmed(); - // read local version - if (str.contains("version")){ - local_version_text = str.right(str.size()-(str.indexOf('=')+1)); - bool ok; - QString lvt_without_point = local_version_text; - lvt_without_point.remove('.'); - local_version = lvt_without_point.toInt(&ok); - if ((local_version == 0)||(!ok)) { - qDebug()<<"Can not read [version] from local version file!"; - loc_version_file.close(); - return -1; - } - } - // read platform - if (str.contains("platform")){ - platform = str.right(str.size()-(str.indexOf('=')+1)); - if (platform=="windows"){ - extension = ".exe"; - } - else if (platform=="linux") { - extension.clear(); - } - else { - qDebug()<<"Can not read [platform] from local version file!"; - loc_version_file.close(); - return -1; - } - } - // read bit - if (str.contains("bit")){ - bit = str.right(str.size()-(str.indexOf('=')+1)); - if (bit.isEmpty()){ - qDebug()<<"Can not read [bit] from local version file!"; - loc_version_file.close(); - return -1; - } - } - } - loc_version_file.close(); +// qDebug()<<"Checking updates..."; +// local_ver_file_name = "gt_version"; +// QFile loc_version_file(local_ver_file_name); +// if(!loc_version_file.open(QIODevice::ReadOnly | QIODevice::Text)){ +// qDebug()<<"Can not open local version file!"; +// return -1; +// } +// while (!loc_version_file.atEnd()){ +// QByteArray str = loc_version_file.readLine().trimmed(); +// // read local version +// if (str.contains("version")){ +// local_version_text = str.right(str.size()-(str.indexOf('=')+1)); +// bool ok; +// QString lvt_without_point = local_version_text; +// lvt_without_point.remove('.'); +// local_version = lvt_without_point.toInt(&ok); +// if ((local_version == 0)||(!ok)) { +// qDebug()<<"Can not read [version] from local version file!"; +// loc_version_file.close(); +// return -1; +// } +// } +// // read platform +// if (str.contains("platform")){ +// platform = str.right(str.size()-(str.indexOf('=')+1)); +// if (platform=="windows"){ +// extension = ".exe"; +// } +// else if (platform=="linux") { +// extension.clear(); +// } +// else { +// qDebug()<<"Can not read [platform] from local version file!"; +// loc_version_file.close(); +// return -1; +// } +// } +// // read bit +// if (str.contains("bit")){ +// bit = str.right(str.size()-(str.indexOf('=')+1)); +// if (bit.isEmpty()){ +// qDebug()<<"Can not read [bit] from local version file!"; +// loc_version_file.close(); +// return -1; +// } +// } +// } +// loc_version_file.close(); - local_app_name = "gerber_translator" + extension; - updater_name = "gt_u" + extension; - updater.setFile(updater_name); - if (!updater.exists()){ - qDebug()<<"Updater gt_u not found!"; - return -1; - } +// local_app_name = "gerber_translator" + extension; +// updater_name = "gt_u" + extension; +// updater.setFile(updater_name); +// if (!updater.exists()){ +// qDebug()<<"Updater gt_u not found!"; +// return -1; +// } - // reading path with acual versions - QFile path_file("path"); - if(!path_file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can not open path file!"; - return -1; - } - while (!path_file.atEnd()){ - actual_path = path_file.readLine().trimmed(); - } - if (actual_path.isEmpty()){ - path_file.close(); - qDebug()<<"Failed to determine the path to the actual version!"; - return -1; - } +// // reading path with acual versions +// QFile path_file("path"); +// if(!path_file.open(QIODevice::ReadOnly | QIODevice::Text)){ +// qDebug()<<"Can not open path file!"; +// return -1; +// } +// while (!path_file.atEnd()){ +// actual_path = path_file.readLine().trimmed(); +// } +// if (actual_path.isEmpty()){ +// path_file.close(); +// qDebug()<<"Failed to determine the path to the actual version!"; +// return -1; +// } - // creating actual paths - QString platform_folder_name; - QString bit_folder_name; - platform_folder_name = "/" + platform; - bit_folder_name = "/gerber_translator_" + bit; - actual_path.append(platform_folder_name); - actual_path.append(bit_folder_name); - actual_ver_file_name = actual_path + "/gt_version"; - actual_app_path = actual_path + "/gerber_translator" + extension; - path_file.close(); +// // creating actual paths +// QString platform_folder_name; +// QString bit_folder_name; +// platform_folder_name = "/" + platform; +// bit_folder_name = "/gerber_translator_" + bit; +// actual_path.append(platform_folder_name); +// actual_path.append(bit_folder_name); +// actual_ver_file_name = actual_path + "/gt_version"; +// actual_app_path = actual_path + "/gerber_translator" + extension; +// path_file.close(); - QFile act_version_file(actual_ver_file_name); +// QFile act_version_file(actual_ver_file_name); - if(!act_version_file.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug()<<"Can not open actual version file!"; - return -1; - } - while (!act_version_file.atEnd()){ - QByteArray str = act_version_file.readLine().trimmed(); - // read version - if (str.contains("version")){ - actual_version_text = str.right(str.size()-(str.indexOf('=')+1)); - bool ok; - QString avt_without_point = actual_version_text; - avt_without_point.remove('.'); - actual_version = avt_without_point.toInt(&ok); - if ((actual_version == 0)||(!ok)) { - qDebug()<<"Can not read acual version from actual version file!"; - act_version_file.close(); - return -1; - } - } - } - act_version_file.close(); +// if(!act_version_file.open(QIODevice::ReadOnly | QIODevice::Text)){ +// qDebug()<<"Can not open actual version file!"; +// return -1; +// } +// while (!act_version_file.atEnd()){ +// QByteArray str = act_version_file.readLine().trimmed(); +// // read version +// if (str.contains("version")){ +// actual_version_text = str.right(str.size()-(str.indexOf('=')+1)); +// bool ok; +// QString avt_without_point = actual_version_text; +// avt_without_point.remove('.'); +// actual_version = avt_without_point.toInt(&ok); +// if ((actual_version == 0)||(!ok)) { +// qDebug()<<"Can not read acual version from actual version file!"; +// act_version_file.close(); +// return -1; +// } +// } +// } +// act_version_file.close(); - // compare versions - if (actual_version>local_version){ - //argv[1] - local version path - //argv[2] - actual version string - //argv[3] - local application path - //argv[4] - actual application path - QStringList arguments; - arguments.append(local_ver_file_name); // - arguments.append(actual_version_text); // - arguments.append(local_app_name); // - arguments.append(actual_app_path); //absolute path - // run updater - QProcess updater_process(nullptr); - updater_process.startDetached(updater.absoluteFilePath(), arguments); - // exit - return 1; - } - else if (actual_version==local_version){ - return 2; //app is up to date - } - qDebug()<<"Error! Local version > Actual version!"; - return -1; -} +// // compare versions +// if (actual_version>local_version){ +// //argv[1] - local version path +// //argv[2] - actual version string +// //argv[3] - local application path +// //argv[4] - actual application path +// QStringList arguments; +// arguments.append(local_ver_file_name); // +// arguments.append(actual_version_text); // +// arguments.append(local_app_name); // +// arguments.append(actual_app_path); //absolute path +// // run updater +// QProcess updater_process(nullptr); +// updater_process.startDetached(updater.absoluteFilePath(), arguments); +// // exit +// return 1; +// } +// else if (actual_version==local_version){ +// return 2; //app is up to date +// } +// qDebug()<<"Error! Local version > Actual version!"; +// return -1; +//} diff --git a/updater.h b/updater.h index 9e2b768..91e3567 100644 --- a/updater.h +++ b/updater.h @@ -1,13 +1,13 @@ -#ifndef UPDATER_H -#define UPDATER_H +//#ifndef UPDATER_H +//#define UPDATER_H -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include -//main function -int update(); +////main function +//int update(); -#endif // UPDATER_H +//#endif // UPDATER_H