Skip to content

Commit

Permalink
new path to the chip database file
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbigmdm committed Feb 8, 2024
1 parent 21423b0 commit d0e22b8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
19 changes: 10 additions & 9 deletions IMSProg_editor/ezp_chip_editor.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the IMSProg_Editor project.
*
* Copyright (C) 2023 Mikhail Medvedev (e-ink-reader@yandex.ru)
* Copyright (C) 2023-2024 Mikhail Medvedev (e-ink-reader@yandex.ru)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,10 +41,11 @@ void MainWindow::on_actionOpen_triggered()
char txtBuf[0x30];
int i, j, recNo, dataPoz, dataSize, chipSize, blockSize, delay, rowCount;
unsigned char chipSizeCode, chipID, manCode, tmpBuf;
defaultPath = QDir::homePath() + "/.local/share/imsprog/";
ui->statusBar->showMessage(tr("Open the file"));
fileName = QFileDialog::getOpenFileName(this,
QString(tr("Open the file")),
"/etc/imsprog",
defaultPath,
"Data Images (*.Dat);;All files (*.*)");
ui->statusBar->showMessage(tr("Current file: ") + fileName);
QFile file(fileName);
Expand Down Expand Up @@ -470,8 +471,8 @@ void MainWindow::on_actionSave_triggered()
//Saving Qbytearray to file
ui->statusBar->showMessage("Saving file");
fileName = QFileDialog::getSaveFileName(this,
QString::fromUtf8("Открыть файл"),
QDir::currentPath(),
QString::fromUtf8("Saving file"),
defaultPath,
"Data Images (*.Dat);;All files (*.*)");
ui->statusBar->showMessage("Current file: " + fileName);
QFile file(fileName);
Expand Down Expand Up @@ -682,7 +683,7 @@ void MainWindow::on_actionExport_to_CSV_triggered()
ui->statusBar->showMessage(tr("Saving file"));
fileName = QFileDialog::getSaveFileName(this,
QString(tr("Save file")),
QDir::currentPath(),
QDir::homePath(),
"Data Images (*.csv);;All files (*.*)");
ui->statusBar->showMessage(tr("Current file: ") + fileName);
QFile file(fileName);
Expand Down Expand Up @@ -720,8 +721,8 @@ void MainWindow::on_actionExport_to_CSV_2_triggered()
ui->statusBar->showMessage("Saving file");
fileName = QFileDialog::getSaveFileName(this,
QString(tr("Open the file")),
QDir::currentPath(),
"Data Images (*.csv);;All files (*.*)");
QDir::homePath(),
"Comma-Separated Values (*.csv);;All files (*.*)");
ui->statusBar->showMessage(tr("Current file: ") + fileName);
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) return;
Expand All @@ -741,8 +742,8 @@ void MainWindow::on_actionImport_from_CSV_triggered()
ui->statusBar->showMessage(tr("Opening file"));
fileName = QFileDialog::getOpenFileName(this,
QString(tr("Open the file")),
QDir::currentPath(),
"Data Images (*.csv);;All files (*.*)");
QDir::homePath(),
"Comma-Separated Values (*.csv);;All files (*.*)");
ui->statusBar->showMessage(tr("Current file: ") + fileName);
QFile file(fileName);
QByteArray data;
Expand Down
1 change: 1 addition & 0 deletions IMSProg_editor/ezp_chip_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MainWindow : public QMainWindow
QString chipVCC;
};
chip_data chips[2000];
QString defaultPath;
QString bytePrint(unsigned char z);
QString sizeConvert(int a);
unsigned char dualDigitToByte(QString q, int poz);
Expand Down
10 changes: 4 additions & 6 deletions IMSProg_programmer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set(CMAKE_AUTOUIC ON)

project(IMSProg LANGUAGES C CXX)

set(USER_HOME_DIRECTORY $ENV{HOME})

# Set the CMAKE_INSTALL_PREFIX to /usr if not specified
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "The default install prefix" FORCE)
Expand All @@ -24,11 +26,6 @@ if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
endif()

# Set the CMAKE_INSTALL_SYSCONFDIR to /etc if not specified
if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR)
set(CMAKE_INSTALL_SYSCONFDIR "/etc" CACHE PATH "read-only single-machine data (etc)")
endif()

# Set the CMAKE_INSTALL_LIBDIR to /lib if not specified
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "/lib" CACHE PATH "read-only single-machine data (lib)")
Expand Down Expand Up @@ -129,7 +126,8 @@ target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${LibUSB_LIBRARIES})
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/IMSProg64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/database/IMSProg.Dat" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/imsprog")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/database/IMSProg.Dat" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/imsprog")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/database/IMSProg.Dat" DESTINATION "${USER_HOME_DIRECTORY}/.local/share/imsprog/")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/99-CH341.rules" DESTINATION "${UDEVDIR}/rules.d")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/language/chipProgrammer_ru_RU.qm" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/imsprog")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/language/chipProgrammer_es_ES.qm" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/imsprog")
Expand Down
2 changes: 1 addition & 1 deletion IMSProg_programmer/dialogabout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DialogAbout::DialogAbout(QWidget *parent) :
ui->label_7->setTextFormat(Qt::RichText);
ui->label_7->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->label_7->setOpenExternalLinks(true);
ui->label_8->setText("V1.1.11");
ui->label_8->setText("V1.2.1");
}

DialogAbout::~DialogAbout()
Expand Down
11 changes: 9 additions & 2 deletions IMSProg_programmer/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->progressBar->setValue(0);
ui->comboBox_name->addItems({""});
ui->comboBox_man->addItems({""});
//ui->comboBox_vcc->addItems({ " ", "3.3 V", "1.8 V", "5.0 V"});

ui->comboBox_vcc->addItem(" ", 0);
ui->comboBox_vcc->addItem("3.3 V", 1);
ui->comboBox_vcc->addItem("1.8 V", 2);
Expand Down Expand Up @@ -1300,9 +1300,16 @@ void MainWindow::on_actionChip_info_triggered()
void MainWindow::progInit()
{
int index2;
QString datFileNameMain = QDir::homePath() + "/.local/share/imsprog/IMSProg.Dat";
QString datFileNameReserve = "/usr/share/imsprog/IMSProg.Dat";
QString currentDatFilePath = "";
//opening chip database file
ui->statusBar->showMessage(tr("Opening DAT file"));
QFile datfile("/etc/imsprog/IMSProg.Dat");

if (QFileInfo(datFileNameMain).exists()) currentDatFilePath = datFileNameMain;
else if (QFileInfo(datFileNameReserve).exists()) currentDatFilePath = datFileNameReserve;

QFile datfile(currentDatFilePath);
QByteArray dataChips;
if (!datfile.open(QIODevice::ReadOnly))
{
Expand Down
6 changes: 3 additions & 3 deletions IMSProg_programmer/other/IMSProg_database_update
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash
IMSPROG_DB_URL=https://antenna-dvb-t2.ru/dl_all/IMSProg.Dat
PASSWORD=$(zenity --password)
cd /tmp
wget ${IMSPROG_DB_URL}
cd /etc
mkdir -p imsprog
file=/etc/imsprog/IMSProg.Dat
file=~/.local/share/imsprog/IMSProg.Dat
oldsize=$(wc -c <"$file")
let oldrec=oldsize/68-1
echo $PASSWORD | sudo -S cp /tmp/IMSProg.Dat /etc/imsprog/
rm -rf ~/.local/share/imsprog/IMSProg.Dat
cp /tmp/IMSProg.Dat ~/.local/share/imsprog/
rm -rf /tmp/IMSProg.Dat
newsize=$(wc -c <"$file")
let newrec=newsize/68-1
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ sudo apt update
- Ver. 1.1.9 - Increased speed of program operation at the moment of chip type change.
- Ver. 1.1.10 - Fixed program crash on chip size mismatch with INTEL hex file size.
- Ver. 1.1.11 - Added support for ASUS CAP files.
- Ver. 1.1.12 - Minor changes to Debian packaging

This comment has been minimized.

Copy link
@Fantu

Fantu Feb 8, 2024

Collaborator

@bigbigmdm 1.1.12 is not a change to Debian packaging but to udev rule (21423b0) that affected everyone and is not related to packaging
It is useful to reduce permissions for better security

- Ver. 1.2.1 - New path to the chip database file. Now there is no need for root permissions to change and update the file.

This comment has been minimized.

Copy link
@Fantu

Fantu Feb 8, 2024

Collaborator

@bigbigmdm the path change from /etc to /usr/share for the default .dat is relevant and it is a good idea to specify it in detail both in the changelogs and in the release notes you will make
or perhaps with more details in the release notes


## Project structure

Expand All @@ -302,7 +304,8 @@ IMSProg /usr/bin
IMSProg_editor /usr/bin
IMSProg_programmer/other/IMSProg_database_update /usr/bin
IMSProg_programmer/database/IMSProg.Dat /etc/imsprog
IMSProg_programmer/database/IMSProg.Dat /usr/share/imsprog
~/.local/share/imsprog
IMSProg_programmer/other/99-CH341.rules /lib/udev/rules.d
Expand Down

0 comments on commit d0e22b8

Please sign in to comment.