同步主线3.2.0.1-0k.14版本刻录代码;解决部分界面的双标题栏

This commit is contained in:
wangchenglong 2023-04-12 11:07:01 +08:00
parent 2b2715d3fe
commit 806bb9a1c0
145 changed files with 10415 additions and 2462 deletions

View File

@ -12,13 +12,16 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O0 -Wall")
find_package(Qt5 COMPONENTS Widgets DBus X11Extras REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(KF5WindowSystem)
pkg_check_modules(KYSDKQTWIDGETS_PKG kysdk-qtwidgets)
pkg_check_modules(GLIB2 glib-2.0)
pkg_check_modules(KYSDKSYSINFO_PKG kysdk-sysinfo)
pkg_check_modules(KYSDKWAYLANDHELPER_PKG kysdk-waylandhelper)
add_executable(kylin-burner
@ -32,6 +35,8 @@ add_executable(kylin-burner
src/frame/configuration.h
src/frame/signals.cpp
src/frame/signals.h
src/frame/auditlog.h
src/frame/auditlog.cpp
src/po/translation.h
src/view/mainwindow.cpp
src/view/mainwindow.h
@ -48,6 +53,10 @@ add_executable(kylin-burner
src/view/burnimageisoitem.cpp
src/view/burnimageisoitem.h
src/view/burnimageisoitem.ui
src/view/components/clicklabel.h
src/view/components/clicklabel.cpp
src/view/components/iconlabel.h
src/view/components/iconlabel.cpp
src/view/copyimage.cpp
src/view/copyimage.h
src/view/copyimage.ui
@ -60,12 +69,18 @@ add_executable(kylin-burner
src/view/input.cpp
src/view/input.h
src/view/input.ui
src/view/inputchange.cpp
src/view/inputchange.h
src/view/inputchange.ui
src/view/progress.cpp
src/view/progress.h
src/view/progress.ui
src/view/tips.cpp
src/view/tips.h
src/view/tips.ui
src/view/tipschange.cpp
src/view/tipschange.h
src/view/tipschange.ui
src/view/tip_burnresult.cpp
src/view/tip_burnresult.h
src/view/tip_burnresult.ui
@ -81,6 +96,8 @@ add_executable(kylin-burner
src/view/viewfilterfiles.cpp
src/view/viewfilterfiles.h
src/view/viewfilterfiles.ui
src/view/multiselectfiledialog.h
src/view/multiselectfiledialog.cpp
src/view/multiselectionfiledialog.cpp
src/view/multiselectionfiledialog.h
src/view/kybaboutdialog.cpp
@ -103,6 +120,8 @@ add_executable(kylin-burner
src/model/monitorcdrom.h
src/model/menufactory.cpp
src/model/menufactory.h
src/model/diroptutils.cpp
src/model/diroptutils.h
src/data/datacdrom.cpp
src/data/datacdrom.h
src/data/datafile.cpp
@ -111,6 +130,10 @@ add_executable(kylin-burner
src/data/datadirectory.h
src/data/datasetting.cpp
src/data/datasetting.h
src/data/iso9660.cpp
src/data/iso9660.h
src/data/iso9660backend.cpp
src/data/iso9660backend.h
src/process/processbasic.cpp
src/process/processbasic.h
src/process/processearse.cpp
@ -140,6 +163,13 @@ add_executable(kylin-burner
src/status-fix/discscsi.cpp
src/status-fix/discread.h
src/status-fix/discread.cpp
src/libisofs/rock.h
src/libisofs/bswap.h
src/libisofs/el_torito.h
src/libisofs/isofs.cpp
src/libisofs/isofs.h
src/libisofs/iso_fs.h
)
#,runtime path
@ -148,16 +178,22 @@ set_target_properties(kylin-burner PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
#all_target
add_custom_target(MO-FILE
ALL
COMMAND "msgfmt" ${CMAKE_CURRENT_SOURCE_DIR}"/src/po/kylin-burner.po"
"-o" ${CMAKE_CURRENT_SOURCE_DIR}"/src/po/kylin-burner.mo"
COMMAND "msgfmt" ${CMAKE_CURRENT_SOURCE_DIR}"/src/po/zh_CN.po"
"-o" ${CMAKE_CURRENT_SOURCE_DIR}"/src/po/zh_CN.mo"
COMMAND "msgfmt" ${CMAKE_CURRENT_SOURCE_DIR}"/src/po/bo_CN.po"
"-o" ${CMAKE_CURRENT_SOURCE_DIR}"/src/po/bo_CN.mo"
)
target_include_directories(kylin-burner PRIVATE
${KYSDKQTWIDGETS_PKG_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
${KYSDKSYSINFO_PKG_INCLUDE_DIRS}
${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS}/ukuistylehelper
${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS}/windowmanager)
target_link_directories(kylin-burner PRIVATE
${KYSDKQTWIDGETS_PKG_LIBRARY_DIRS}
${KYSDKSYSINFO_PKG_LIBRARY_DIRS}
${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS}
${KYSDKQTWIDGETS_PKG_LIBRARY_DIRS})
@ -170,9 +206,14 @@ target_link_libraries(kylin-burner PRIVATE
pthread
gsettings-qt
ukui-log4qt
${GLIB2_LIBRARIES}
${KYSDKQTWIDGETS_PKG_LIBRARIES}
${KYSDKSYSINFO_PKG_LIBRARIES}
${KYSDKWAYLANDHELPER_PKG_LIBRARIES})
install(TARGETS kylin-burner ${INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS kylin-burner.desktop DESTINATION /usr/share/applications)
install(FILES src/po/kylin-burner.mo DESTINATION /usr/share/locale/zh_CN/LC_MESSAGES/)
install(FILES src/po/zh_CN.mo RENAME kylin-burner.mo DESTINATION /usr/share/locale/zh_CN/LC_MESSAGES/)
install(FILES src/po/bo_CN.mo RENAME kylin-burner.mo DESTINATION /usr/share/locale/bo_CN/LC_MESSAGES/)
install(DIRECTORY kylin-burner DESTINATION /usr/share/kylin-user-guide/data/guide/)
install(FILES gsettings/org.ukui.kylinburner.gschema.xml DESTINATION /usr/share/glib-2.0/schemas/)

25
debian/control vendored
View File

@ -4,32 +4,33 @@ Priority: optional
Maintainer: Derek.Wong <wangye@kylinos.cm>
Build-Depends: cmake,
debhelper-compat (= 12),
libglib2.0-dev,
libgsettings-qt-dev,
libkysdk-qtwidgets-dev,
libqt5x11extras5-dev (>= 5.10.0~),
libukui-log4qt-dev,
libkf5windowsystem-dev,
libx11-dev,
pkg-config,
libgsettings-qt-dev,
libkysdk-sysinfo-dev,
qtbase5-dev (>= 5.10.0~),
libukui-log4qt-dev,
libkysdk-qtwidgets-dev,
pkg-config,
libkysdk-waylandhelper-dev,
libkf5windowsystem-dev
libglib2.0-dev
Standards-Version: 4.4.1
Breaks: kylin-burner-i18n
Breaks:kylin-burner-i18n
Package: kylin-burner
Architecture: any
Depends: cdrdao [linux-any],
cdrskin,
dvd+rw-tools,
genisoimage,
dvd+rw-tools,
growisofs,
udisks2 [linux-any],
vcdimager,
udisks2 [linux-any],
wodim,
xorriso,
${misc:Depends},
${shlibs:Depends}
Breaks: kylin-burner-i18n
${shlibs:Depends},
${misc:Depends}
Breaks:kylin-burner-i18n
Description: <insert up to 60 chars description>
<insert long description, indented with spaces>

13
debian/kylin-burner.logrotate vendored Normal file
View File

@ -0,0 +1,13 @@
/var/log/kylin-burner/*log {
daily
missingok
rotate 7
sharedscripts
postrotate
invoke-rc.d --quiet kylin-burner restart > /dev/null
endscript
compress
delaycompress
notifempty
create
}

16
debian/kylin-burner.postinst vendored Normal file
View File

@ -0,0 +1,16 @@
#!/bin/sh
set -e
LOG_DIR=/var/log/kylin-burner
if [ ! -d $LOG_DIR ]; then
mkdir $LOG_DIR
chmod 0755 $LOG_DIR
touch $LOG_DIR/os_audit.log
chmod 0777 $LOG_DIR/os_audit.log
fi
if [ -d $LOG_DIR ]; then
chmod 0755 $LOG_DIR
chmod 0777 $LOG_DIR/os_audit.log
fi

View File

@ -0,0 +1,20 @@
<schemalist>
<schema id="org.ukui.kylinburner" path="/org/ukui/kylinburner/" gettext-domain="kylinburner">
<key type="s" name="kylinburner">
<default>"true"</default>
<summary>Enable to use kylin-bunrer</summary>
<description>Whether enable to use kylin-burner</description>
</key>
<key type="s" name="burner-os-auditlog-name">
<default>""</default>
<summary>kylin-burner save name</summary>
<description>Record kylin-burner saved name</description>
</key>
<key type="b" name="burneraudit-isrunning">
<default>false</default>
<summary>Whether kylin-burner audit is running</summary>
<description>Whether running kylin-burner auit</description>
</key>
</schema>
</schemalist>

BIN
kylin-burner/en_US/image/1.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 192 KiB

BIN
kylin-burner/en_US/image/10.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 40 KiB

BIN
kylin-burner/en_US/image/11.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 207 KiB

BIN
kylin-burner/en_US/image/12.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 222 KiB

BIN
kylin-burner/en_US/image/13.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 KiB

After

Width:  |  Height:  |  Size: 243 KiB

BIN
kylin-burner/en_US/image/2.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 131 KiB

BIN
kylin-burner/en_US/image/3.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 278 KiB

BIN
kylin-burner/en_US/image/4.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 42 KiB

BIN
kylin-burner/en_US/image/5.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 219 KiB

BIN
kylin-burner/en_US/image/6.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 170 KiB

BIN
kylin-burner/en_US/image/7.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 42 KiB

BIN
kylin-burner/en_US/image/8.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 30 KiB

BIN
kylin-burner/en_US/image/9.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
kylin-burner/zh_CN/image/1.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 81 KiB

BIN
kylin-burner/zh_CN/image/11.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 146 KiB

BIN
kylin-burner/zh_CN/image/12.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 145 KiB

BIN
kylin-burner/zh_CN/image/13.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 KiB

After

Width:  |  Height:  |  Size: 166 KiB

BIN
kylin-burner/zh_CN/image/2.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 284 KiB

BIN
kylin-burner/zh_CN/image/4.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 48 KiB

BIN
kylin-burner/zh_CN/image/7.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 116 KiB

BIN
kylin-burner/zh_CN/image/8.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -1,4 +1,4 @@
# 刻录
# 刻
## 概 述
刻录是一款界面简洁基础功能齐全的Linux下光盘刻录软件其主要实现业务包含创建镜像数据刻录数据追加刻录镜像刻录镜像提取及光盘复制其主界面如图1所示。
@ -128,7 +128,7 @@
![图 10 刻录设置-big](image/10.png)
### 弹出
### 弹
当刻录机中有光盘时,[弹出]按钮可用如图11所示用户可以手动弹出光盘当刻录机中没有光盘时在设置中的[弹出]按钮不可用且置灰如图12所示。
@ -136,7 +136,7 @@
![图 12 弹出不可用且置灰-big](image/12.png)
### 擦除
### 擦
当刻录机中的光盘的类型是RW盘且光盘有数据或刻录好的镜像存在时擦除按钮可用如图13所示其他情况下擦除按钮不可用且置灰。擦除按钮可以擦除光盘中的所有数据和刻录到光盘的镜像文件。

View File

@ -0,0 +1 @@
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#262626;}</style></defs><g id="f"><path class="cls-1" d="M12.5,14h-9A2.5,2.5,0,0,1,1,11.5v-7A2.5,2.5,0,0,1,3.5,2h3A2.5,2.5,0,0,1,8.87,3.71.54.54,0,0,0,9.34,4H12.5A2.5,2.5,0,0,1,15,6.5v5A2.5,2.5,0,0,1,12.5,14ZM3.5,3A1.5,1.5,0,0,0,2,4.5v7A1.5,1.5,0,0,0,3.5,13h9A1.5,1.5,0,0,0,14,11.5v-5A1.5,1.5,0,0,0,12.5,5H9.35a1.51,1.51,0,0,1-1.41-.94A1.51,1.51,0,0,0,6.5,3h-3Z"/></g></svg>

After

Width:  |  Height:  |  Size: 494 B

View File

@ -8,5 +8,6 @@
<file>delete.png</file>
<file>kylin-burner.qrc</file>
<file>newfolder.png</file>
<file>folder-visiting-symbolic.svg</file>
</qresource>
</RCC>

View File

@ -7,6 +7,9 @@
#include "src/process/processearse.h"
#include "src/process/processmediainfo.h"
#include "src/process/processisoinfo.h"
#include "src/data/iso9660.h"
#include "src/data/iso9660backend.h"
#include "src/status-fix/discscsi.h"
#include <unistd.h>
#include <fcntl.h>
@ -20,6 +23,7 @@
#include <QCoreApplication>
#include <QFileInfo>
#include <QTimer>
#include <QDate>
#define WAIT_SEC 10
#define FACTOR_CD 175
@ -35,6 +39,7 @@ DataMedium::DataMedium(QString mediuType, QString blockName, QObject *parent) :
m_u64FreeCapacity(0),
m_u32TrackNumber(0),
m_u64UsedCapacity(0),
m_mountPointTimer(new QTimer),
m_oCDROM(qobject_cast<DataCDROM *>(parent))
{
@ -42,6 +47,7 @@ DataMedium::DataMedium(QString mediuType, QString blockName, QObject *parent) :
m_oUsedCapacity = _("%1 B").arg(0.00);
m_oFreeCapacity = _("%1 B").arg(0.00);
m_oMediumName.clear();
m_oCDROM->updateVerficationData(false); // 刚插入的光盘默认不进行校验数据
connect(this, SIGNAL(info(QString)), LOGGER, SLOT(info(QString)));
connect(this, SIGNAL(warn(QString)), LOGGER, SLOT(warn(QString)));
connect(this, SIGNAL(error(QString)), LOGGER, SLOT(error(QString)));
@ -62,6 +68,36 @@ DataMedium::DataMedium(QString mediuType, QString blockName, QObject *parent) :
m_oIcon = QIcon::fromTheme("media-optical-dvd");
//load();
m_discread = new DiscRead(blockName);
connect(m_mountPointTimer, &QTimer::timeout, this, &DataMedium::slotsMountPoint);
}
DataMedium::DataMedium(DataMedium &other, QObject *parent) :
QObject(parent)
{
m_u8Status = other.status();
//m_bAppRunning;
m_bErasable = other.isErasable();
//m_bUDF;
m_bEnableUDF = other.isEnableUDF() ;
m_oCDROM = qobject_cast<DataCDROM *>(parent);
//m_u32TrackNumber;
m_u64UsedCapacity = other.get32UsedCapacity();
m_u64FreeCapacity = other.get32FreeCapacity();
m_u64Capacity = other.get32Capacity();
//m_oVolumnID;
m_oBlockName = other.getBlockName();
m_oMediumType = other.getType();
m_oUsedCapacity = other.getUsedCapacity();
m_oFreeCapacity = other.getFreeCapacity();
m_oCapacity = other.getCapacity();
m_oMountPoint = other.getMountPoint();
//m_oMediumName;
m_oDisplay = other.display();
m_oIcon = other.icon();
m_iSpeeds = other.getNumSpeed();
m_oSpeeds = other.speeds();
m_mountPointTimer = nullptr;
}
void DataMedium::load()
@ -100,6 +136,8 @@ void DataMedium::load()
}
void DataMedium::fixDiscStatus(){
m_discread->disconnect(); //关闭connect,可能会有第二次,使用不同槽函数
if(m_discread->isBlank()){
m_u8Status = MEDIUM_EMPTY;
}else if(m_discread->canAppend()){
@ -108,7 +146,115 @@ void DataMedium::fixDiscStatus(){
m_u8Status = MEDIUM_FINALIZED;
capacity();
mountPoint();
m_mountPointTimer->start(1000);
// m_oDisplay = _("%1 - %2 medium, left space : %3")
// .arg(m_oMediumName.isEmpty() ? _("Empty medium") : m_oCDROM->settingVolumnID())
// .arg(m_oMediumType).arg(m_oFreeCapacity);
// Q_EMIT g_user_signal->changeDiscStatus();
}
void DataMedium::secondFixDiscStatus()
{
qDebug() << "m_discread->canAppend() = " << m_discread->canAppend();
if(m_discread->canAppend()) {
m_u8Status = MEDIUM_INCOMPLETE;
capacity();
Q_EMIT g_user_signal->secondChangeDiscStatus();
qDebug() << QString("[%1][%2] 挂载点已查到:[%3] 定时器已关,发送信号").arg(__func__).arg(__LINE__).arg(m_oMountPoint);
if (!m_discread->discLabel().isEmpty()) {
m_oVolumnID = m_discread->discLabel();
qDebug() << QString("[%1][%2]: set卷标=%3").arg(__func__).arg(__LINE__).arg(m_oVolumnID);
m_oCDROM->setVolumnID(m_oVolumnID);
m_oDisplay = _("%1 - %2 medium, left space : %3")
.arg(m_oMediumName.isEmpty() ? _("Empty medium") : m_oVolumnID)
.arg(m_oMediumType).arg(m_oFreeCapacity);
qDebug()<<__LINE__<<__func__<<m_oFreeCapacity;
} else {
QString currentTime = QDate::currentDate().toString("yyyy-MM-dd");
//m_oCDROM->setVolumnID(currentTime); // V10空卷标时使用当前日期作为卷标
m_oCDROM->setVolumnID(_("KylinBurner"));
m_oDisplay = _("%1 - %2 medium, left space : %3")
.arg(m_oMediumName.isEmpty() ? _("Empty medium") : _("KylinBurner"))
.arg(m_oMediumType).arg(m_oFreeCapacity);
}
// m_oDisplay = _("%1 - %2 medium, left space : %3")
// .arg(m_oMediumName.isEmpty() ? _("Empty medium") : m_oCDROM->settingVolumnID())
// .arg(m_oMediumType).arg(m_oFreeCapacity);
}
}
void DataMedium::slotsMountPoint()
{
qDebug() << QString("[%1][%2] 进入start").arg(__func__).arg(__LINE__);
if ((m_u8Status > MEDIUM_EMPTY && m_u8Status < MEDIUM_OTHER) &&
(m_oMountPoint.isEmpty() || m_oMediumName.isEmpty()) &&
m_bAppRunning)
{
FILE *fp = nullptr;
struct mntent *mp = nullptr;
fp = setmntent("/proc/mounts", "r");
if (nullptr == fp)
{
error(_("Cannot load mount information.%1").arg(strerror(errno)));
//qDebug() << QString("[%1][%2] ").arg(__func__).arg(__LINE__);
return;
}
while (nullptr != (mp = getmntent(fp))) {
if (QString::fromUtf8(mp->mnt_fsname) == m_oBlockName)
{
m_oMountPoint = QString::fromUtf8(mp->mnt_dir);
m_oMediumName = m_oMountPoint.split("/").takeLast();
if (QString::fromUtf8(mp->mnt_type).contains("UDF") ||
QString::fromUtf8(mp->mnt_type).contains("udf"))
{
m_bUDF = true;
debug(_("Medium %1 mounted by UDF").arg(m_oMountPoint));
}
// Fix 112786 获取挂载点后,再次确认光盘状态
if(m_u8Status != MEDIUM_INCOMPLETE) {
connect(m_discread, &DiscRead::workFinished, this, &DataMedium::secondFixDiscStatus);
m_discread->work();
}
m_mountPointTimer->stop();
m_mountPointTimer->disconnect();
//qDebug() << QString("[%1][%2] 挂载点已查到:[%3] 定时器已关").arg(__func__).arg(__LINE__).arg(m_oMountPoint);
info(QString("[%1][%2] 挂载点已查到:[%3] 定时器已关").arg(__func__).arg(__LINE__).arg(m_oMountPoint));
break;
}
}
endmntent(fp);
} else {
if (m_u8Status == MEDIUM_EMPTY) {
m_mountPointTimer->stop();
m_mountPointTimer->disconnect();
//qDebug() << QString("[%1][%2] 空光盘 定时器已关").arg(__func__).arg(__LINE__);
info(QString("[%1][%2] 空光盘 定时器已关").arg(__func__).arg(__LINE__));
}
}
if (!m_discread->discLabel().isEmpty()) {
m_oVolumnID = m_discread->discLabel();
qDebug() << QString("[%1][%2]: set卷标=%3").arg(__func__).arg(__LINE__).arg(m_oVolumnID);
m_oCDROM->setVolumnID(m_oVolumnID);
m_oDisplay = _("%1 - %2 medium, left space : %3")
.arg(m_oMediumName.isEmpty() ? _("Empty medium") : m_oVolumnID)
.arg(m_oMediumType).arg(m_oFreeCapacity);
} else {
QString currentTime = QDate::currentDate().toString("yyyy-MM-dd");
//m_oCDROM->setVolumnID(currentTime); // V10空卷标时使用当前日期作为卷标
m_oCDROM->setVolumnID(_("KylinBurner"));
m_oDisplay = _("%1 - %2 medium, left space : %3")
.arg(m_oMediumName.isEmpty() ? _("Empty medium") : _("KylinBurner"))
.arg(m_oMediumType).arg(m_oFreeCapacity);
}
m_oDisplay = _("%1 - %2 medium, left space : %3")
.arg(m_oMediumName.isEmpty() ? _("Empty medium") : m_oCDROM->settingVolumnID())
.arg(m_oMediumType).arg(m_oFreeCapacity);
@ -232,14 +378,16 @@ void DataMedium::capacity()
if (MEDIUM_FINALIZED == m_u8Status) // finalized all 0.
{
qDebug()<<__LINE__<<__func__<<"加载失败";
warn(_("Donot load type of finalized capacity."));
return;
}
if (m_oMediumType.contains("DVD+RW") || m_oMediumType.contains("DVD-RW"))
{
ProcessMediaInfo *media = new ProcessMediaInfo(m_oCDROM, this);
media->exec();
m_u64Capacity = media->size();
//计算光盘总容量
ProcessMediaInfo media(m_oCDROM, this);
media.exec();
m_u64Capacity = media.size();
if (MEDIUM_EMPTY == m_u8Status)
{
m_u64FreeCapacity = m_u64Capacity;
@ -248,13 +396,37 @@ void DataMedium::capacity()
}
else if (m_oMediumType.contains("DVD-RW"))
{
m_u64FreeCapacity = media->size();
m_u64FreeCapacity = media.size();
m_oFreeCapacity = toUnitString(m_u64FreeCapacity);
}
else {}
debug(_("SIZE IS %1 | %2").arg(m_u64Capacity).arg(m_oCapacity));
delete media;
media=nullptr;
//计算DVD-RW和DVD+RW的已使用容量
if (m_u8Status == MEDIUM_INCOMPLETE) {
Iso9660SimplePrimaryDescriptor isoDesc;
isoDesc = Iso9660SimplePrimaryDescriptor();
Iso9660 iso( new Iso9660DeviceBackend( m_oCDROM ) );
iso.setStartSector( 0 );
iso.setPlainIso9660( true );
if( iso.open() ) {
isoDesc = iso.primaryDescriptor();
m_u64UsedCapacity = isoDesc.getUsedCapacity();
m_oCapacity = toUnitString(m_u64Capacity);
m_oUsedCapacity = toUnitString(m_u64UsedCapacity);
m_u64FreeCapacity = m_u64Capacity - m_u64UsedCapacity;
m_oFreeCapacity = toUnitString(m_u64FreeCapacity);
info(_("Capacity: %1 - used(%2) - free(%3)").arg(m_oCapacity).arg(m_oUsedCapacity).arg(m_oFreeCapacity));
} else {
// 没有获取到已使用数据容量可能是Win刻录的UDF盘或空光盘
info(QString("[%1][%2] Failed to obtain the capacity. It may be a real UDF disk").arg(__func__).arg(__LINE__));
}
info(QString("[%1][%2] DVD+/-RW Capacity calculation completed"));
}
qDebug() << __func__ << __LINE__ << "容量计算完成";
return;
}
@ -343,6 +515,7 @@ void DataMedium::speed()
}
//弃用使用slotMountPoint()
void DataMedium::mountPoint()
{
FILE *fp = nullptr;
@ -426,8 +599,12 @@ QString DataMedium::toUnitString(unsigned long size64)
DataMedium::~DataMedium()
{
//qDebug()<<"~ Medium"<< this << " DataROM地址为::" << m_oCDROM << " (" << m_oCDROM->device() <<") -----------------";
//qDebug()<<"~ Medium" << this << " DataROM地址为::" << m_oCDROM << " (" << m_oCDROM->device() <<") -----------------";
//qDebug() << "";
//info("析构Medium");
if(m_mountPointTimer)
delete m_mountPointTimer;
m_mountPointTimer=nullptr;
}
@ -457,6 +634,7 @@ DataCDROM::DataCDROM(QString blockName, QObject *parent) :
connect(m_oSetting, SIGNAL(closeSession(bool)), BUSNESSSETTING, SLOT(setCloseSession(bool)));
connect(m_oSetting, SIGNAL(open(bool)), BUSNESSSETTING, SLOT(setOpen(bool)));
connect(m_oSetting, SIGNAL(createISO(bool)), BUSNESSSETTING, SLOT(setCreateISO(bool)));
connect(m_oSetting, SIGNAL(verficationData(bool)), BUSNESSSETTING, SLOT(setVerficationData(bool)));
connect(m_oSetting, SIGNAL(preparer(QString)), BUSNESSSETTING, SLOT(setPreparer(QString)));
connect(m_oSetting, SIGNAL(publisher(QString)), BUSNESSSETTING, SLOT(setPublisher(QString)));
connect(m_oSetting, SIGNAL(volumnID(QString)), BUSNESSSETTING, SLOT(setVolumnID(QString)));
@ -468,6 +646,7 @@ DataCDROM::DataCDROM(QString blockName, QObject *parent) :
connect(this, SIGNAL(clean(bool)), m_oSetting, SLOT(updateClean(bool)));
connect(this, SIGNAL(createISO(bool)), m_oSetting, SLOT(updateCreateISO(bool)));
connect(this, SIGNAL(closeSession(bool)), m_oSetting, SLOT(updateCloseSession(bool)));
connect(this, SIGNAL(verficationData(bool)), m_oSetting, SLOT(updateVerficationData(bool)));
connect(this, SIGNAL(setOpen(bool)), m_oSetting, SLOT(updateOpen(bool)));
connect(this, SIGNAL(copyright(QString)), m_oSetting, SLOT(updateCopyright(QString)));
connect(this, SIGNAL(preparer(QString)), m_oSetting, SLOT(updatePreparer(QString)));
@ -492,6 +671,62 @@ DataCDROM::DataCDROM(QString blockName, QObject *parent) :
}
DataCDROM::DataCDROM(DataCDROM &other, QString blockName, QObject *parent) :
QObject(parent)
{
m_oBlockName = blockName;
m_bCDROM = true;
m_bStart = false;
m_bAppRunning = true;
m_iHandle = -1;
m_iUsing = 0;
m_oMedium = nullptr;
m_oSetting = nullptr;
m_bUpdateStart = false;
m_bPrepare_openDevice = false;
if (!m_oBlockName.startsWith("/dev/"))
{
m_bCDROM = false;
m_oDisplay.clear();
m_oDisplay = _("No need burner.");
}
use();
}
DataCDROM * DataCDROM::clone()
{
DataCDROM *cdrom = new DataCDROM(*this, this->m_oBlockName);
cdrom->m_oSetting = new DataSetting(*this->m_oSetting,cdrom);
cdrom->m_oMedium = new DataMedium(*this->m_oMedium, cdrom);
cdrom->m_iHandle = this->m_iHandle;
cdrom->m_u32MediumRSupport = this->m_u32MediumRSupport;
cdrom->m_u32MediumWSupport = this->m_u32MediumWSupport;
cdrom->m_u32BurnModeSupport = this->m_u32BurnModeSupport;
cdrom->m_bEjected = this->m_bEjected;
cdrom->m_bCDROM = this->m_bCDROM;
cdrom->m_bAppRunning = this->m_bAppRunning;
cdrom->m_oDisplay = this->m_oDisplay;
cdrom->m_oVendor = this->m_oVendor;
cdrom->m_oProductor = this->m_oVendor;
cdrom->m_oBlockName = this->m_oBlockName;
cdrom->m_oMediumType = this->m_oMediumType;
cdrom->m_oTimer = nullptr;
connect(cdrom, &DataCDROM::updateCDROMBurnStart, this, &DataCDROM::slotsUpdateCDROMBurnStart);
return cdrom;
}
void DataCDROM::umountMedium(QString device)
{
QString cmd;
//use BlockName replace MountPoint,Becase MountPoint may has spaces
//cmd = QString("umount %1").arg(m_oMedium ? m_oMedium->getMountPoint() : QString());
cmd = QString("umount %1").arg(device);
::system(cmd.toUtf8().data());
}
void DataCDROM::update()
{
connect(g_user_signal, &GlobalUserSignal::changeDiscStatus, this, &DataCDROM::receiveDiscStatusChange);
@ -513,8 +748,11 @@ void DataCDROM::update()
// 0. ready cdrom.
if (!open())
{
if (isOpen()){
close();
}
if(!open()){
release();
return;
}
@ -573,11 +811,11 @@ void DataCDROM::sendMediumStatusToOtherView()
emit empty();
break;
case DataMedium::MEDIUM_INCOMPLETE:
if(!mediumMountPoint().isEmpty())
if(!mediumMountPoint().isEmpty())
emit appendale();
break;
case DataMedium::MEDIUM_FINALIZED:
if(!mediumMountPoint().isEmpty())
if(!mediumMountPoint().isEmpty())
emit finished();
break;
}
@ -599,6 +837,7 @@ void DataCDROM::loadMedium()
close();
if (m_oMedium)
{
qDebug()<<__LINE__<<__func__<<"DataCDROM";
switch (m_oMedium->status())
{
case DataMedium::MEDIUM_EMPTY:
@ -677,11 +916,8 @@ void DataCDROM::eject()
void DataCDROM::earse()
{
ProcessEarse *earse;
earse = new ProcessEarse(this, this);
earse->exec();
delete earse;
ProcessEarse earse(this);
earse.exec();
}
bool DataCDROM::isEjected()
@ -701,7 +937,17 @@ QString DataCDROM::mDisplay()
QIcon DataCDROM::mediumIcon()
{
return m_oMedium ? m_oMedium->icon() : QIcon::fromTheme("application-x-cd-image");
//return m_oMedium ? m_oMedium->icon() : QIcon::fromTheme("application-json");
//return m_oMedium ? m_oMedium->icon() : QIcon::fromTheme("application-json");
}
void DataCDROM::updateVerficationData(bool b)
{
if (m_oSetting) {
//qInfo() << __func__ << __LINE__ << "设置verficationData的值为" << b;
m_oSetting->updateVerficationData(b);
} else {
//qInfo() << __func__ << __LINE__ << "m_oSetting为空不设置verficationData的值为" << b;
}
}
bool DataCDROM::open()
@ -712,8 +958,8 @@ bool DataCDROM::open()
release();
return true;
}
QThread::msleep(500); // bucause when loading new insert CDROM, will have no rights.
m_iHandle = ::open(m_oBlockName.toUtf8().constData(), O_NONBLOCK | O_RDONLY);
//QThread::msleep(500); // bucause when loading new insert CDROM, will have no rights.
m_iHandle = ::open(m_oBlockName.toUtf8().constData(), O_NONBLOCK | O_CLOEXEC | O_RDONLY);
if (m_iHandle < 0)
{
error(_("Open block device %1 faied.%2").arg(m_oBlockName).arg(strerror(errno)));
@ -755,7 +1001,28 @@ bool DataCDROM::execSCSI(const unsigned char *cdb, const int cdbLength,
}
return true;
}
bool DataCDROM::read10(unsigned char *data, unsigned int dataLen, unsigned long startAdress, unsigned int length, bool fua)
{
::memset( data, 0, dataLen );
DiscScsi cmd(m_oBlockName);
cmd[0] = 0x28; // MMC_READ_10
cmd[1] = ( fua ? 0x8 : 0x0 );
cmd[2] = startAdress>>24;
cmd[3] = startAdress>>16;
cmd[4] = startAdress>>8;
cmd[5] = startAdress;
cmd[7] = length>>8;
cmd[8] = length;
cmd[9] = 0; // Necessary to set the proper command length
if( !cmd.transport( SCSI_READ, data, dataLen ) ) {
qDebug() << m_oBlockName << ": READ 10 failed!";
return false;
}
else
return true;
}
void DataCDROM::updateMediumUsedSize(unsigned long size)
{
if (0 == size) return;
@ -806,6 +1073,12 @@ void DataCDROM::slotsPrepareTimerOut()
}
void DataCDROM::slotsUpdateCDROMBurnStart(bool b)
{
//qDebug() << __func__ << __LINE__ << "m_bStart = " << b;
m_bStart = b;
}
QString DataCDROM::display(QString blockName)
{
Q_UNUSED(blockName);
@ -863,6 +1136,11 @@ bool DataCDROM::doorIsOpen()
return false;
}
void DataCDROM::setVolumnID(QString str)
{
emit m_oSetting->volumnID(str);
}
void DataCDROM::support()
{
unsigned short len = 0;
@ -1376,16 +1654,29 @@ DataCDROM::~DataCDROM()
{
//qDebug() << "";
//qDebug()<<"~ DataCDROM"<< this << " DataROM地址为::" << this << " (" << this->device() <<") -------start----------";
//info(QString("析构 DataCDROM, m_iUsing = [%2]").arg(m_iUsing));
if (-1 != m_iHandle) ::close(m_iHandle);
m_iHandle = -1;
if(m_oMedium)
{
//qDebug() << "DataCDROM:~DataCDROM() delete m_oMedium = " << m_oMedium;
delete m_oMedium;
m_oMedium = nullptr;
//info(QString("[%1] [%2] : 已delete m_oMedium").arg(__func__).arg(__LINE__));
}
//delete m_oSetting;
//m_oSetting = nullptr;
delete m_oTimer;
//delete m_oTimer;
if(m_oTimer) {
delete m_oTimer;
//info(QString("[%1] [%2] : 已delete m_oTimer").arg(__func__).arg(__LINE__));
}
m_oTimer = nullptr;
//qDebug()<<"~ DataCDROM"<< this << " DataROM地址为::" << this << " (" << this->device() <<") -------end----------";
//qDebug() << " ";
}
bool DataCDROM::isOpen()
{
return m_iHandle >= 0;
}

View File

@ -8,7 +8,7 @@
#include <QIcon>
#include <QProcess>
#include <QTimer>
#include <QDebug>
class DataCDROM;
class DataMedium : public QObject
@ -60,6 +60,7 @@ public:
};
public:
explicit DataMedium(QString, QString, QObject *);
DataMedium(DataMedium &, QObject *);
~DataMedium();
public:
bool isErasable() const { return m_bErasable; }
@ -92,6 +93,8 @@ private:
private slots:
void slotsChangeBurnFormat_CDROM();
void fixDiscStatus();
void secondFixDiscStatus(); //检测到挂载点后,再次修正光盘状态
void slotsMountPoint();
private:
unsigned char m_u8Status;
bool m_bAppRunning;
@ -105,6 +108,7 @@ private:
unsigned long m_u64UsedCapacity;
unsigned long m_u64FreeCapacity;
unsigned long m_u64Capacity;
QString m_oVolumnID;
QString m_oBlockName;
QString m_oMediumType;
QString m_oUsedCapacity;
@ -117,6 +121,7 @@ private:
QList<int> m_iSpeeds;
QStringList m_oSpeeds;
DiscRead *m_discread;
QTimer *m_mountPointTimer;
};
@ -132,14 +137,18 @@ public:
};
public:
explicit DataCDROM(QString blockName, QObject *parent = nullptr);
DataCDROM(DataCDROM &, QString blockName, QObject *parent = nullptr);
static void umountMedium(QString);
~DataCDROM();
public:
bool isOpen();
void update();
void sendMediumStatusToOtherView();
void loadMedium();
void umount();
bool doorIsOpen();
void setVolumnID(QString);
DataCDROM * clone();
public:
void use() { ++m_iUsing; }
void release() { if (--m_iUsing == 0) delete this; }
@ -166,20 +175,35 @@ public:
QString mediumMountPoint() const { return m_oMedium ? m_oMedium->getMountPoint() : QString(); }
public:
void setting() { if(m_oSetting) m_oSetting->load();}
// 从m_oSetting中获取值
int settingSpeed() const { return m_oSetting ? m_oSetting->getSpeed() : 0; }
bool settingClean() const { return m_oSetting ? m_oSetting->getClean() : false; }
bool settingCreateISO() const { return m_oSetting ? m_oSetting->getCreateISO() : false; }
bool settingCloseSession() const { return m_oSetting ? m_oSetting->getCloseSession() : false; }
bool settingVerficationData() const { return m_oSetting ? m_oSetting->getVerficationData() : false; }
bool settingOpen() const { return m_oSetting ? m_oSetting->getOpen() : false; }
QString settingPreparer() const { return m_oSetting ? m_oSetting->getPreparer() : QString(); }
QString settingPublisher() const { return m_oSetting ? m_oSetting->getPublisher() : QString(); }
QString settingVolumnID() const { return m_oSetting ? m_oSetting->getVolumnID() : QString(); }
QString settingCopyright() const { return m_oSetting ? m_oSetting->getCopyright() : QString(); }
QString settingTempPath() const { return m_oSetting ? m_oSetting->getTempPath() : QString(); }
// QString getVendor() const {
// qDebug()<<__func__<<__LINE__<<m_oVendor;
// return m_oVendor;}
// 向m_oSetting设置值
void updateVerficationData(bool b);
public: // scsi command
bool open();
void close();
bool execSCSI(const unsigned char *, const int, unsigned char *, const int);
bool read10( unsigned char* data,
unsigned int dataLen,
unsigned long startAdress,
unsigned int length,
bool fua=false );
public slots:
void updateMediumUsedSize(unsigned long);
void receiveDiscStatusChange();
@ -195,6 +219,7 @@ private slots:
void changeISOName(QString);
void changeISOPath(QString);
void slotsPrepareTimerOut();
void slotsUpdateCDROMBurnStart(bool); //更新m_bStart状态
private:
//int m_iUsing;
int m_iHandle;
@ -225,13 +250,15 @@ signals:
// medium
void empty(); void appendale(); void finished();
// setting
void speed(int); void clean(bool); void createISO(bool);
void closeSession(bool); void setOpen(bool);
void speed(int); void clean(bool);
void createISO(bool);void closeSession(bool);
void setOpen(bool); void verficationData(bool);
void preparer(QString); void publisher(QString);
void volumnID(QString); void copyright(QString);
void tempPath(QString); void burnFormat(QString);
// other
void eject(bool);
void updateCDROMBurnStart(bool); // 发送m_bStart状态
};
#endif // DATACDROM_H

View File

@ -8,15 +8,35 @@
#include <QDir>
#include <QCoreApplication>
#include <QDebug>
#include <QScopedPointer>
bool DataDirectory::g_bFilterHidden = false;
bool DataDirectory::g_bFilterBroken = false;//是否执行损坏连接文件过滤
bool DataDirectory::g_bRepleace = false;//是否执行连接文件替换
void DataDirectory::setFilterHidden(bool filter)
{
DataDirectory::g_bFilterHidden = filter;
}
void DataDirectory::setFilterBrokenSymbolLinks(bool filter)
{
DataDirectory::g_bFilterBroken = filter;
}
void DataDirectory::setRepleaceSymbolLinks(bool filter)
{
DataDirectory::g_bRepleace = filter;
}
DataDirectory::DataDirectory(QString path, QObject *parent, bool fromDisk) :
DataFile(path, parent, fromDisk)
{
DataDirectory *dir;
m_oChildren.clear();
m_bFilterBroken = false;
m_bFilterHidden = false;
m_bRepleace = false;
m_bFilterBroken = DataDirectory::g_bFilterHidden;
m_bFilterHidden = DataDirectory::g_bFilterBroken;
m_bRepleace = DataDirectory::g_bRepleace;
m_bIsDirectory = true;
m_oHashChildren.clear();
m_u64Files = 0;
@ -31,11 +51,14 @@ DataDirectory::DataDirectory(QString path, QObject *parent, bool fromDisk) :
if (!m_bIsRoot)
{
m_bFilterHidden = dir->filterHidden();
qDebug()<<__LINE__<<__func__<<m_bFilterHidden;
m_bFilterBroken = dir->filterBrokenSymbolLinks();
m_bRepleace = dir->repleaceSymbolLinks();
}
if (m_bIsRoot) m_u64Size = 0;
if (m_bIsRoot){
m_u64Size = 0;
}
if (".." == m_oDisplayName)
{
m_oIcon = QIcon::fromTheme("go-up-symbolic");
@ -88,9 +111,14 @@ bool DataDirectory::take(DataFile *file)
int idx;
idx = m_oChildren.indexOf(file);
if (-1 == idx) return false;
if (-1 == idx){
qDebug()<<__LINE__<<__func__<<idx;
return false;
}
m_oChildren.takeAt(idx);
//qDebug()<<__LINE__<<__func__<<idx;
m_oHashChildren.remove(file->display());
//qDebug()<<__LINE__<<__func__<<file->display();
return true;
}
@ -112,7 +140,9 @@ void DataDirectory::append(DataFile *d)
case 0:
do
{
renamed = EXEC->input(newName, _("Rename"), _("Add new name for %1").arg(d->display()), d->display());
QScopedPointer<InputChange> p(new InputChange);
//renamed = EXEC->input(newName, _("Rename"), _("Add new name for %1").arg(d->display()), d->display());
renamed = p->input(newName, _("Rename"), _("File name duplicate, need to rename:"), d->display());
if (!renamed) break;
if (newName.trimmed().isEmpty())
{
@ -238,9 +268,7 @@ void DataDirectory::clear()
".." == (m_oChildren.at(i))->display())
continue;
//删除DataFile指针会造成闪退
//delete m_oChildren.at(i);
delete m_oChildren.at(i);
}
}
@ -249,7 +277,7 @@ void DataDirectory::clean()
for (int i = m_oChildren.size() - 1; i > -1 && m_oChildren.size(); --i)
{
//删除DataFile指针会造成闪退
//delete m_oChildren.at(i);
delete m_oChildren.at(i);
}
}
@ -275,33 +303,43 @@ void DataDirectory::copy()
void DataDirectory::execHidden(bool b)
{
m_bFilterHidden = b;
qDebug()<<"DataDirectory"<<__func__<<__LINE__<<m_bFilterHidden;
hidden(b);
}
void DataDirectory::execBroken(bool b)
{
m_bFilterBroken = b;
qDebug()<<"DataDirectory"<<__func__<<__LINE__<<m_bFilterBroken;
broken(b);
}
void DataDirectory::execRepleace(bool b)
{
m_bRepleace = b;
qDebug()<<"DataDirectory"<<__func__<<__LINE__<<m_bRepleace;
repleace(b);
}
void DataDirectory::turnViewFilterFileToHidden()
{
if (m_oChildren.size() == 0) m_bFilterHidden = false;
if (m_oChildren.size() == 0){
m_bFilterHidden = false;
execHidden(false);
qDebug()<<"DataDirectory"<<__func__<<__LINE__<<m_bFilterHidden;
}
for (int i = 0; i < m_oChildren.size(); ++i)
{
if (m_oChildren.at(i)->attrHidden())
{
m_bFilterHidden = true;
qDebug()<<"DataDirectory"<<__func__<<__LINE__<<m_bFilterHidden;
return;
}
}
m_bFilterHidden = false;
execHidden(false);
qDebug()<<"DataDirectory"<<__func__<<__LINE__<<m_bFilterHidden;
}
void DataDirectory::turnViewFilterFileToBrokenSymbolLinks()
@ -442,7 +480,12 @@ void DataDirectory::doChild(DataFile *child, bool b)
case 0:
do
{
renamed = EXEC->input(newName, _("Rename"), _("Add new name for %1").arg(child->display()), child->display());
QScopedPointer<InputChange> p(new InputChange);
// renamed = EXEC->input(newName, _("Rename"), _("Add new name for %1").arg(child->display()), child->display());
renamed=p->input(newName, _("Rename"), _("File name duplicate, need to rename:"),child->display());
if (!renamed) break;
if (newName.trimmed().isEmpty())
{
@ -518,6 +561,7 @@ void DataDirectory::doChild(DataFile *child, bool b)
{
linked = static_cast<DataDirectory *>(m_oLinkTarget);
linked->take(child);
}
debug(_("Move child %1 out").arg(child->display()));
return;

View File

@ -2,6 +2,7 @@
#define DATADIRECTORY_H
#include "datafile.h"
#include "src/view/inputchange.h"
class DataDirectory : public DataFile
{
@ -29,9 +30,24 @@ public:
void clean();
void copy();
void *findChildByDisplay(QString, bool child = false);
bool filterHidden() const { return m_bFilterHidden; }
bool filterBrokenSymbolLinks() const { return m_bFilterBroken; }
bool repleaceSymbolLinks() const { return m_bRepleace; }
static void setFilterHidden(bool filter);
bool filterHidden() const {
// 暂不提供针对具体节点的隐藏属性,改为使用全局隐藏属性
// return m_bFilterHidden;
return g_bFilterHidden;
}
static void setFilterBrokenSymbolLinks(bool filter);
bool filterBrokenSymbolLinks() const {
// 暂不提供针对具体节点的过滤,改为使用全局配置
// return m_bFilterBroken;
return g_bFilterBroken;
}
static void setRepleaceSymbolLinks(bool filter);
bool repleaceSymbolLinks() const {
// 暂不提供针对具体节点的过滤,改为使用全局配置
// return m_bRepleace;
return g_bRepleace;
}
void execHidden(bool b = true);
void execBroken(bool b = true);
void execRepleace(bool b = true);
@ -45,6 +61,7 @@ public slots:
void doFile(bool, DataFile *);
void doChild(DataFile *, bool);
private:
InputChange *inputchange;//界面
bool m_bIsRoot;//是否为根节点
bool m_bFilterHidden;//是否执行隐藏文件过滤
bool m_bFilterBroken;//是否执行损坏连接文件过滤
@ -54,6 +71,9 @@ private:
unsigned long m_u64NewDataSize;//当前文件夹下新添加文件大小
QList<DataFile *> m_oChildren;//当前文件夹下子文件
QHash<QString, DataFile *> m_oHashChildren;//当前文件夹下唯一子文件
static bool g_bFilterHidden;//是否执行隐藏文件过滤
static bool g_bFilterBroken;//是否执行损坏连接文件过滤
static bool g_bRepleace;//是否执行连接文件替换
signals:
void updateSize(unsigned long);
};

View File

@ -7,6 +7,7 @@
#include <QDateTime>
#include <QMimeType>
#include <QMimeDatabase>
#include <QDebug>
DataFile::DataFile(QString path, QObject *parent, bool fromDisk)
: QObject(parent)
@ -30,6 +31,7 @@ DataFile::DataFile(QString path, QObject *parent, bool fromDisk)
m_bIsDirectory = f.isDir();
m_oRealName = f.fileName();
m_oDisplayName = m_oRealName;
if (m_oDisplayName.length() > NAME_LENGTH)
{
if (f.suffix().length())
@ -113,6 +115,7 @@ DataFile::DataFile(QString path, QObject *parent, bool fromDisk)
if (m_oLinkTarget)
{
connect(dir, SIGNAL(update(QString)), m_oLinkTarget, SLOT(onUpdate(QString)));
connect(dir, SIGNAL(hidden(bool)), m_oLinkTarget, SLOT(slotsDoHidde(bool)));
connect(dir, SIGNAL(broken(bool)), m_oLinkTarget, SLOT(slotsDoBroken(bool)));
connect(dir, SIGNAL(repleace(bool)), m_oLinkTarget, SLOT(slotsDoRepleace(bool)));
@ -227,7 +230,11 @@ void DataFile::filter()
parent = qobject_cast<DataDirectory *>(this->parent());
if (nullptr == parent) return;
if (parent->filterHidden() && m_bAttrHidden) slotsDoHidde(true);
if (parent->filterHidden() && m_bAttrHidden)
{
qDebug()<<"DataFile"<<__LINE__<<__func__;
slotsDoHidde(true);
}
if (parent->filterBrokenSymbolLinks() && m_bAttrLink && nullptr == m_oLinkTarget)
slotsDoBroken(true);
if (parent->repleaceSymbolLinks() && m_oLinkTarget)
@ -294,11 +301,13 @@ void DataFile::slotsDoHidde(bool b)
{
if (b)
{
qDebug()<<__func__<<__LINE__<<"Filter hidden file 文件"<<b;
parent->take(this);
size(this->m_u64Size, false);
doHidden(this);
disconnect(parent, SIGNAL(hidden(bool)), this, SLOT(slotsDoHidde(bool)));
debug(_("Filter hidden file. %1").arg(m_oDisplayName));
}
}
else
@ -307,6 +316,8 @@ void DataFile::slotsDoHidde(bool b)
{
parent = qobject_cast<DataDirectory *>(this);
parent->execHidden(b);
qDebug()<<"DataFile"<<__func__<<__LINE__<<b;
}
}
}

View File

@ -15,7 +15,8 @@ DataSetting::DataSetting(QObject *parent) :
m_bClean(false),
m_bCloseSession(false),
m_bCreateISO(false),
m_bOpen(false)
m_bOpen(false),
m_bVerficationData(false)
{
struct passwd *pwd;
QDir dir;
@ -24,6 +25,7 @@ DataSetting::DataSetting(QObject *parent) :
m_oPreparer = _("KylinSoft");
m_oPublisher = QString::fromUtf8(pwd->pw_name);
//m_oVolumnID = QDate::currentDate().toString("yyyy-MM-dd"); //V10上使用日期作为卷标
m_oVolumnID = _("KylinBurner");
m_oCopyright = _("Kylinsoft © %1 All rights.").arg(QDate::currentDate().toString("yyyy"));
dir.setPath(QDir::homePath() + "/.cache/KylinBurner/");
@ -33,6 +35,23 @@ DataSetting::DataSetting(QObject *parent) :
//qDebug()<<"new DataSetting(m_SBurnFormat==["<<m_SBurnFormat<<"])";
}
DataSetting::DataSetting(DataSetting &other, QObject *parent)
{
parent = other.parent();
m_iSpeed = other.getSpeed();
m_bClean = other.getClean();
m_bCreateISO = other.getCreateISO();
m_bCloseSession = other.getCloseSession();
m_bVerficationData = other.getVerficationData();
m_bOpen = other.getOpen();
m_oPreparer = other.getPreparer();
m_oPublisher = other.getPublisher();
m_oVolumnID = other.getVolumnID();
m_oCopyright = other.getCopyright();
m_oTemporaryPth = other.getTempPath();
m_SBurnFormat = other.getBurnFormat();
}
void DataSetting::load()
{
//qDebug()<<"DataSetting::load() speed("<<m_iSpeed<<")";
@ -44,7 +63,7 @@ void DataSetting::load()
open(m_bOpen);
preparer(m_oPreparer);
publisher(m_oPublisher);
volumnID(m_oVolumnID);
//volumnID(m_oVolumnID);
copyright(m_oCopyright);
tempPath(m_oTemporaryPth);
burnFormat(m_SBurnFormat);

View File

@ -8,6 +8,7 @@ class DataSetting : public QObject
Q_OBJECT
public:
explicit DataSetting(QObject *parent = nullptr);
DataSetting(DataSetting &other, QObject *parent);
~DataSetting();
public:
void load();
@ -16,6 +17,7 @@ public:
bool getClean() const { return m_bClean; }
bool getCreateISO() const { return m_bCreateISO; }
bool getCloseSession() const { return m_bCloseSession; }
bool getVerficationData() const { return m_bVerficationData; }
bool getOpen() const { return m_bOpen; }
QString getPreparer() const { return m_oPreparer; }
QString getPublisher() const { return m_oPublisher; }
@ -28,6 +30,7 @@ public slots:
void updateClean(bool b) { m_bClean = b; }
void updateCreateISO(bool b) { m_bCreateISO = b; }
void updateCloseSession(bool b) { m_bCloseSession = b; }
void updateVerficationData(bool b) { m_bVerficationData = b;}
void updateOpen(bool b) { m_bOpen = b; }
void updatePreparer(QString s) { m_oPreparer = s; }
void updatePublisher(QString s) { m_oPublisher = s; }
@ -40,6 +43,7 @@ private:
bool m_bClean;
bool m_bCreateISO;
bool m_bCloseSession;
bool m_bVerficationData;
bool m_bOpen;
QString m_oPreparer;
QString m_oPublisher;
@ -52,6 +56,7 @@ signals:
void clean(bool);
void createISO(bool);
void closeSession(bool);
void verficationData(bool);
void open(bool);
void preparer(QString);
void publisher(QString);

254
src/data/iso9660.cpp Normal file
View File

@ -0,0 +1,254 @@
#include "iso9660.h"
//#include <config-k3b.h>
//#include "k3bglobals.h"
#include "iso9660.h"
#include "iso9660backend.h"
#include "datacdrom.h"
#include "datacdrom.h"
#include "src/libisofs/isofs.h"
#include <QDebug>
#include <QDir>
#include <QFile>
/* callback function for libisofs */
int Iso9660::read_callback( char* buf, sector_t start, int len, void* udata )
{
Iso9660* isoF = static_cast<Iso9660*>(udata);
return isoF->read( start, buf, len );
}
class Iso9660::Private
{
public:
Private()
: cdDevice(0),
fd(-1),
isOpen(false),
startSector(0),
plainIso9660(false),
backend(0) {
}
Iso9660SimplePrimaryDescriptor primaryDesc;
DataCDROM *cdDevice;
int fd;
bool isOpen;
// only used for direkt Device::Device access
unsigned int startSector;
bool plainIso9660;
Iso9660Backend* backend;
};
Iso9660::Iso9660( Iso9660Backend* backend )
{
d = new Private();
d->backend = backend;
}
Iso9660::~Iso9660()
{
close();
delete d->backend;
delete d;
}
void Iso9660::setStartSector( unsigned int startSector )
{
d->startSector = startSector;
}
void Iso9660::setPlainIso9660( bool b )
{
d->plainIso9660 = b;
}
bool Iso9660::plainIso9660() const
{
return d->plainIso9660;
}
int Iso9660::read( unsigned int sector, char* data, int count )
{
if( count == 0 )
return 0;
else
return d->backend->read( sector, data, count );
}
bool Iso9660::open()
{
//if( d->isOpen )
// return true;
iso_vol_desc *desc;
QString path,tmp,uid,gid;
k3b_struct_stat buf;
int access,c_i,c_j;
struct el_torito_boot_descriptor* bootdesc;
// TODO implement win32 support
/* We'll use the permission and user/group of the 'host' file except
* in Rock Ridge, where the permissions are stored on the file system
*/
if ( k3b_stat( QFile::encodeName(m_filename), &buf ) < 0 ) {
/* defaults, if stat fails */
memset(&buf,0,sizeof(k3b_struct_stat));
buf.st_mode=0777;
}
uid.setNum(buf.st_uid);
gid.setNum(buf.st_gid);
access = buf.st_mode & ~S_IFMT;
int c_b=1;
c_i=1;c_j=1;
desc = ReadISO9660( &Iso9660::read_callback, d->startSector, this );
if (desc) {
qDebug() << "Iso9660::" << __func__ << __LINE__ << "desc != null";
switch (isonum_711(desc->data.type)) {
case ISO_VD_PRIMARY:
createSimplePrimaryDesc( (struct iso_primary_descriptor*)&desc->data );
qDebug() << __func__ << __LINE__;
break;
default:
qDebug() << __func__ << __LINE__;
break;
}
} else {
qDebug() << "Iso9660::" << __func__ << __LINE__ << "desc = null";
return false;
}
FreeISO9660(desc);
return true;
}
bool Iso9660::isOpen() const
{
return d->isOpen;
}
void Iso9660::createSimplePrimaryDesc( struct iso_primary_descriptor* desc )
{
//d->primaryDesc.volumeId = QString::fromLocal8Bit( desc->volume_id, 32 ).trimmed();
//d->primaryDesc.systemId = QString::fromLocal8Bit( desc->system_id, 32 ).trimmed();
//d->primaryDesc.volumeSetId = QString::fromLocal8Bit( desc->volume_set_id, 128 ).trimmed();
//d->primaryDesc.publisherId = QString::fromLocal8Bit( desc->publisher_id, 128 ).trimmed();
//d->primaryDesc.preparerId = QString::fromLocal8Bit( desc->preparer_id, 128 ).trimmed();
//d->primaryDesc.applicationId = QString::fromLocal8Bit( desc->application_id, 128 ).trimmed();
//d->primaryDesc.volumeSetSize = isonum_723(desc->volume_set_size);
//d->primaryDesc.volumeSetNumber = isonum_723(desc->volume_set_size);
//qDebug() << "desc->logical_block_size = " << desc->logical_block_size;
//qDebug() << "desc->volume_space_size = " << desc->volume_space_size;
d->primaryDesc.logicalBlockSize = isonum_723(desc->logical_block_size);
d->primaryDesc.volumeSpaceSize = isonum_733(desc->volume_space_size);
qDebug() << "d->primaryDesc.logicalBlockSize = " << d->primaryDesc.logicalBlockSize;
qDebug() << "d->primaryDesc.volumeSpaceSize = " << d->primaryDesc.volumeSpaceSize;
}
void Iso9660::close()
{
if( d->isOpen ) {
d->backend->close();
d->isOpen = false;
}
}
const Iso9660SimplePrimaryDescriptor& Iso9660::primaryDescriptor() const
{
return d->primaryDesc;
}
void Iso9660::debug() const
{
if( isOpen() ) {
qDebug() << "System Id: " << primaryDescriptor().systemId;
qDebug() << "Volume Id: " << primaryDescriptor().volumeId;
qDebug() << "Volume Set Id: " << primaryDescriptor().volumeSetId;
qDebug() << "Preparer Id: " << primaryDescriptor().preparerId;
qDebug() << "Publisher Id: " << primaryDescriptor().publisherId;
qDebug() << "Application Id: " << primaryDescriptor().applicationId;
qDebug() << "Volume Set Size: " << primaryDescriptor().volumeSetSize;
qDebug() << "Volume Set Number: " << primaryDescriptor().volumeSetNumber;
}
}
Iso9660SimplePrimaryDescriptor::Iso9660SimplePrimaryDescriptor()
: volumeSetSize(0),
volumeSetNumber(0),
logicalBlockSize(0),
volumeSpaceSize(0)
{
}
bool operator==( const Iso9660SimplePrimaryDescriptor& d1,
const Iso9660SimplePrimaryDescriptor& d2 )
{
return( d1.volumeId == d2.volumeId &&
d1.systemId == d2.systemId &&
d1.volumeSetId == d2.volumeSetId &&
d1.publisherId == d2.publisherId &&
d1.preparerId == d2.preparerId &&
d1.applicationId == d2.applicationId &&
d1.volumeSetSize == d2.volumeSetSize &&
d1.volumeSetNumber == d2.volumeSetNumber &&
d1.logicalBlockSize == d2.logicalBlockSize &&
d1.volumeSpaceSize == d2.volumeSpaceSize );
}
bool operator!=( const Iso9660SimplePrimaryDescriptor& d1,
const Iso9660SimplePrimaryDescriptor& d2 )
{
return( d1.volumeId != d2.volumeId ||
d1.systemId != d2.systemId ||
d1.volumeSetId != d2.volumeSetId ||
d1.publisherId != d2.publisherId ||
d1.preparerId != d2.preparerId ||
d1.applicationId != d2.applicationId ||
d1.volumeSetSize != d2.volumeSetSize ||
d1.volumeSetNumber != d2.volumeSetNumber ||
d1.logicalBlockSize != d2.logicalBlockSize ||
d1.volumeSpaceSize != d2.volumeSpaceSize );
}

154
src/data/iso9660.h Normal file
View File

@ -0,0 +1,154 @@
#ifndef ISO9660_H
#define ISO9660_H
#include <QDateTime>
#include <QHash>
#include <QString>
#include <QStringList>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef HAVE_STAT64
#define k3b_struct_stat struct stat64
#define k3b_stat ::stat64
#define k3b_lstat ::lstat64
#else
#define k3b_struct_stat struct stat
#define k3b_stat ::stat
#define k3b_lstat ::lstat
#endif
struct iso_directory_record;
struct el_torito_boot_descriptor;
struct iso_primary_descriptor;
typedef long sector_t;
class Iso9660;
class Iso9660Backend;
/**
* Simplyfied primary descriptor which just contains the fields
* used by K3b.
*/
class Iso9660SimplePrimaryDescriptor
{
public:
/**
* Creates an empty descriptor
*/
Iso9660SimplePrimaryDescriptor();
QString volumeId;
QString systemId;
QString volumeSetId;
QString publisherId;
QString preparerId;
QString applicationId;
int volumeSetSize;
int volumeSetNumber;
long logicalBlockSize;
long long volumeSpaceSize;
long long getUsedCapacity() { return logicalBlockSize* volumeSpaceSize; }
};
/**
* This class is based on the KIso class by
* Gy<EFBFBD>gy Szombathelyi <gyurco@users.sourceforge.net>.
* A lot has been changed and bugfixed.
* The API has been improved to be useful.
*
* Due to the stupid Qt which does not support large files as default
* we cannot use QIODevice with DVDs! That's why we have our own
* reading code which is not allowed by KArchive (which is limited to int
* by the way... who the hell designed this?)
* I also removed the KArchive inheritance because of the named reasons.
* So this stuff contains a lot KArchive code which has been made usable.
*
* That does not mean that this class is well designed. No, it's not. :)
*
* Opening a Iso9660 object should be fast since creation of the directory
* and file entries is not done until a call to Iso9660Directory::entries.
*/
class Iso9660
{
public:
/**
* Directly specify the backend to read from.
* Iso9660 will take ownership of the backend and delete it.
*/
explicit Iso9660( Iso9660Backend* );
/**
* If the .iso is still opened, then it will be
* closed automatically by the destructor.
*/
virtual ~Iso9660();
/**
* Set where to start reading in the source.
*/
void setStartSector( unsigned int startSector );
/**
* If set to true before opening Iso9660 will ignore RR and joliet extensions
* and only create plain iso9660 names.
*/
void setPlainIso9660( bool );
bool plainIso9660() const;
/**
* Opens the archive for reading.
* Parses the directory listing of the archive
* and creates the Iso9660Directory/Iso9660File entries.
*/
bool open();
bool isOpen() const;
/**
* Closes everything.
* This is also called in the destructor
*/
void close();
/**
* @param sector startsector
* @param len number of sectors
* @return number of sectors read or -1 on error
*/
int read( unsigned int sector, char* data, int len );
/**
* The name of the os file, as passed to the constructor
* Null if you did not use the QString constructor.
*/
QString fileName() { return m_filename; }
const Iso9660SimplePrimaryDescriptor& primaryDescriptor() const;
void debug() const;
private:
void createSimplePrimaryDesc( struct iso_primary_descriptor* desc );
// only used for creation
static int read_callback( char* buf, sector_t start, int len, void* udata );
bool m_rr;
private:
QString m_filename;
class Private;
Private * d;
};
#endif // ISO9660_H

101
src/data/iso9660backend.cpp Normal file
View File

@ -0,0 +1,101 @@
#include "iso9660backend.h"
#include "src/status-fix/discscsi.h"
/*
*
* Copyright (C) 2005 Sebastian Trueg <trueg@k3b.org>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file "COPYING" for the exact licensing terms.
*/
#include "iso9660backend.h"
#include "datacdrom.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "src/data/datacdrom.h"
#include <QFile>
#include <QDebug>
Iso9660DeviceBackend::Iso9660DeviceBackend( DataCDROM *dev )
: m_device( dev ),
m_isOpen(false)
{
}
Iso9660DeviceBackend::~Iso9660DeviceBackend()
{
close();
}
bool Iso9660DeviceBackend::open()
{
if( m_isOpen )
return true;
else if( m_device->open() ) {
// set optimal reading speed
//m_device->setSpeed( 0xffff, 0xffff );
m_isOpen = true;
return true;
}
else
return false;
}
void Iso9660DeviceBackend::close()
{
if( m_isOpen ) {
m_isOpen = false;
m_device->close();
}
}
int Iso9660DeviceBackend::read( unsigned int sector, char* data, int len )
{
if( m_device->open() )
{
qDebug() << "Iso9660DeviceBackend::"<<__func__ << __LINE__ << "open";
//
// split the number of sectors to be read
// FIXME: use a "real" value, not some arbitrary one
//
static const int maxReadSectors = 20;
int sectorsRead = 0;
int retries = 10; // TODO: no fixed value
while( retries ) {
int read = qMin(len-sectorsRead, maxReadSectors);
if( !m_device->read10( (unsigned char*)(data+sectorsRead*2048),
read*2048,
sector+sectorsRead,
read)) {
retries--;
}
else {
qDebug() << __func__ << __LINE__ ;
sectorsRead += read;
retries = 10; // new retires for every read part
qDebug() << __func__ << __LINE__ << "sectorsRead = " << sectorsRead << " len = " << len;
if( sectorsRead == len )
return len;
}
}
}
qDebug() << "Iso9660DeviceBackend::"<<__func__ << __LINE__ << "没有open";
//
return -1;
}

37
src/data/iso9660backend.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef ISO9660BACKEND_H
#define ISO9660BACKEND_H
#include <QString>
class DataCDROM;
class Iso9660Backend
{
public:
Iso9660Backend() {}
virtual ~Iso9660Backend() {}
virtual bool open() = 0;
virtual void close() = 0;
virtual bool isOpen() const = 0;
virtual int read( unsigned int sector, char* data, int len ) = 0;
};
class Iso9660DeviceBackend : public Iso9660Backend
{
public:
explicit Iso9660DeviceBackend( DataCDROM * dev );
~Iso9660DeviceBackend() override;
bool open() override;
void close() override;
bool isOpen() const override { return m_isOpen; }
int read( unsigned int sector, char* data, int len ) override;
private:
DataCDROM *m_device;
bool m_isOpen;
};
#endif // ISO9660BACKEND_H

238
src/frame/auditlog.cpp Normal file
View File

@ -0,0 +1,238 @@
#include <QDir>
#include <QDebug>
#include <QObject>
#include <QFileInfo>
#include <QDateTime>
#include <QMimeDatabase>
#include "auditlog.h"
#include "src/po/translation.h"
#include <glib.h>
const QString auditLogFile = "/var/log/kylin-burner/os_audit.log";
AuditLog::AuditLog(){
initInfo();
}
/** 针对光盘进行的操作以及结果记录到审计日志中
*
* appendFile()appendFiles()
*
* @recorderName @discType (eg DVD+R)
* @operation () @burnResult (10)
*/
void AuditLog::outputResult(const QString& recorderName, const QString& discType, const QString& operation, int burnResult){
if(!mLogFile.isOpen())
return;
// if(mFilesList.isEmpty()){ //擦除操作、校验操作不需要考虑文件
// if(operation != _("Earse") || operation != _("Disk Check"))
// return;
// }
QString currentTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
//写日志
mWriteStream<<_("Time") <<"="<<currentTime <<", "
<<_("User") <<"="<<mUserName <<", "
<<_("RecorderType")<<"="<<recorderName.trimmed() <<", "
<<_("DiscProperty")<<"="<<discType <<", "
<<_("FileName") <<"=";
if(!mFilesList.isEmpty()){
for(auto& tmpFile : mFilesList)
mWriteStream<<getFileInfo(tmpFile);
}else
mWriteStream<<_("Current operation donot need file"); //擦除操作不需要考虑文件
mWriteStream<<", ";
mWriteStream<<_("Operation") <<"="<<operation <<", "
<<_("Result") <<"="<<(burnResult? _("success"):_("fail"))
<<"\n";
mWriteStream.flush();
mFilesList.clear();
}
/** 拷贝光盘或提取镜像的信息,记录到审计日志
*/
void AuditLog::outputCopyResult(const QString& mountPoint, const QString &destRecorder,
QString destDiscType, const QString &operation, bool result){
if(!mLogFile.isOpen())
return;
if(destRecorder.isEmpty())
return;
//qDebug()<<__func__<<__LINE__<<operation<<mountPoint;
QString currentTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
mWriteStream<<_("Time") <<"="<<currentTime <<", "
<<_("User") <<"="<<mUserName <<", "
<<_("RecorderType") <<"="<<destRecorder.trimmed() <<", "
<<_("DiscProperty") <<"=";
//如果是提取镜像操作,不需要写光盘类型(因为没有目标光盘)
if(destDiscType.isEmpty())
destDiscType = _("Donot need disc");
mWriteStream<<destDiscType<<", ";
//提取镜像时,输出源光盘的挂载点目录下的文件
getFilesFromMountpoint(mountPoint);
if(!mFilesList.isEmpty()){
mWriteStream<<_("FileName") <<"=";
for(auto& tmpFile : mFilesList)
mWriteStream<<getFileInfo(tmpFile);
mWriteStream<<", ";
}
mWriteStream<<_("Operation") <<"="<<operation <<", "
<<_("Result") <<"="<<(result? _("success"):_("fail"))
<<"\n";
mWriteStream.flush();
mFilesList.clear();
}
/** 不需要刻录机时的创建镜像操作,操作和结果记录到审计日志
* appendFile()appendFiles()
*/
void AuditLog::ouputCreateResult(const QString &recorderName, const QString &targetFile, int result){
if(!mLogFile.isOpen())
return;
if(mFilesList.isEmpty()) //需要文件才能创建iso文件
return;
if(recorderName.isEmpty() || targetFile.isEmpty()) //刻录机名和目标iso文件名
return;
QString currentTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
mWriteStream<<_("Time") <<"="<<currentTime <<", "
<<_("User") <<"="<<mUserName <<", "
<<_("RecorderType") <<"="<<recorderName.trimmed() <<", "
<<_("DiscProperty") <<"="<<_("Donot need disc") <<", "
<<_("FileName") <<"="; //源文件列表
//源文件列表
for(auto& tmpFile : mFilesList)
mWriteStream<<getFileInfo(tmpFile);
mWriteStream<<", ";
mWriteStream<<_("ImageFile") <<"="<<getFileInfo(targetFile) <<", " //镜像文件路径
<<_("Operation") <<"="<<_("Creating ISO") <<", "
<<_("Result") <<"="<<(result? _("success"):_("fail"))
<<"\n";
mWriteStream.flush();
mFilesList.clear();
}
QString AuditLog::getFileInfo(const QString &file){
QString fileInfo;
if(file.isEmpty())
return fileInfo;
QMimeDatabase mimeData;
QMimeType currentFileType;
QFileInfo currentFile(file);
//求文件大小
qint64 byteSize = currentFile.size(); //计算文件大小
QString fileSize=stringSize(byteSize);
// char* formatSize = g_format_size(byteSize); //转为人类可读的形式
// QString fileSize = formatSize;
qDebug()<<__func__<<__LINE__<<fileSize;
//g_free(formatSize);
//获取文件类型
currentFileType = mimeData.mimeTypeForFile(currentFile);
//拼接文件信息
fileInfo = currentFile.filePath();
fileInfo += " (";
fileInfo += currentFileType.comment();
fileInfo += ", ";
fileInfo += fileSize;
fileInfo += ") ";
return fileInfo;
}
void AuditLog::getFilesFromMountpoint(const QString& mountPoint){
if(mountPoint.isEmpty())
return;
QDir dir(mountPoint);
//qDebug()<<__func__<<__LINE__<<dir.exists();
if(!dir.exists())
return;
QStringList filesList = dir.entryList(QDir::Files|QDir::Dirs|QDir::Hidden|QDir::NoDotAndDotDot);
for(auto& file : filesList)
mFilesList.append(mountPoint + "/" + file);
//qDebug()<<__func__<<__LINE__<<mFilesList.isEmpty();
}
/** 添加待写入到光盘内的文件
*/
void AuditLog::appendFile(const QString &filePath){
if(filePath.isEmpty())
return;
if(filePath.contains(".cache/KylinBurner/"))
return;
mFilesList.append(filePath);
}
void AuditLog::appendFiles(const QStringList &fileLists){
if(fileLists.isEmpty())
return;
mFilesList.append(fileLists);
}
void AuditLog::initInfo(){
mUserName = qgetenv("USER");
if(mUserName.isEmpty())
mUserName = qgetenv("USERNAME");
mLogFile.setFileName(auditLogFile);
qDebug()<<__func__<<__LINE__<<auditLogFile;
if(mLogFile.open(QIODevice::WriteOnly | QIODevice::Append)) //只读方式打开
mWriteStream.setDevice(&mLogFile);
}
QString AuditLog::stringSize(unsigned long size)
{
int unit;
qreal rsize;
QString ret;
unit = -1;
rsize = size * 1.0;
while (rsize > 1024.00)
{
++unit; rsize /= 1024.00;
}
ret = QString("%1 ").arg(rsize, 0, 'f', 1);
switch (unit)
{
case 0:
ret.append(_("KB"));
break;
case 1:
ret.append(_("MB"));
break;
case 2:
ret.append(_("GB"));
break;
default:
ret.append(_("B"));
break;
}
return ret;
}
AuditLog::~AuditLog(){
if(mLogFile.isOpen()){
mLogFile.flush();
mLogFile.close();
}
}

35
src/frame/auditlog.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef AUDITLOG_H
#define AUDITLOG_H
#include <QFile>
#include <QDataStream>
#include <QTextStream>
class AuditLog
{
public:
AuditLog();
~AuditLog();
void appendFile(const QString& filePath);
void appendFiles(const QStringList& fileLists);
void outputResult(const QString& recorderName, const QString& discType, const QString& operation, int burnResult);//记录刻录结果
void outputCopyResult(const QString& mountPoint, const QString& destRercorderName,
QString destDiscType, const QString& operation, bool result);
void ouputCreateResult(const QString& recorderName, const QString& targetFile, int result);
private:
void initInfo();
QString getFileInfo(const QString& file);
void getFilesFromMountpoint(const QString& mountPoint);
QString stringSize(unsigned long);
private:
QFile mLogFile;
QString mUserName;
QStringList mFilesList;
QTextStream mWriteStream;
};
/* 返回上一级目录?
*/
#endif // AUDITLOG_H

View File

@ -12,7 +12,28 @@ GlobalUserSignal *GlobalUserSignal::getInstance()
GlobalUserSignal::GlobalUserSignal(QObject *parent) : QObject(parent)
{
mMap.clear();
}
bool GlobalUserSignal::getDeviceBusyStatus(QString dev)
{
if (mMap.contains(dev))
return mMap.value(dev);
else {
return false;
}
}
void GlobalUserSignal::setDeviceBusyStatus(QString dev,bool result)
{
mMap.insert(dev,result);
}
void GlobalUserSignal::removeDevice(QString dev,bool result)
{
if (mMap.contains(dev)) { //判断设备是否在mMap中
mMap.remove(dev);
}
}
GlobalUserSignal::~GlobalUserSignal()

View File

@ -22,6 +22,7 @@
#include <QDir>
#include <QFileInfo>
#include <QMap>
class GlobalUserSignal : public QObject
@ -39,6 +40,9 @@ signals:
//改变DataCDROM中DataSetting中m_SBurnFormat值
void changBurnFormat();
//DataMedia光盘挂载后光盘状态确认有错时通知BurnData的add按钮
void secondChangeDiscStatus();
//当有光盘发送该信号将信号传输到menu界面让其添加擦除信息
void haveMedium(void *);
//刻录操作结束并弹出后通知UI界面去除光盘的相关信息
@ -47,6 +51,15 @@ signals:
//使用udisks2修复光盘的状态判断(空盘、追加)
void changeDiscStatus();
//LogicMain类发出信号通知ProcessBurnData类光驱被拔出
void removeDisc(QString blockName);
//主题改变
void iconChange(QIcon);
public: //成员函数
bool getDeviceBusyStatus(QString);
void setDeviceBusyStatus(QString,bool);
void removeDevice(QString,bool);
private:
static GlobalUserSignal* instance;
@ -55,6 +68,9 @@ private:
GlobalUserSignal(const GlobalUserSignal &) = delete;
GlobalUserSignal &operator = (const GlobalUserSignal &) = delete;
private:
QMap<QString,bool> mMap;
};

280
src/libisofs/COPYING Normal file
View File

@ -0,0 +1,280 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Steet, Fifth Floor, Cambridge, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

9
src/libisofs/ChangeLog Normal file
View File

@ -0,0 +1,9 @@
K3b Changes
- renamed the st_xxx time fileds in rr_entry to rr_st_xxx to make it compile
0.1 -> 0.2
- Critical directory parsing bug fixed
- Call backs only if some sanity checks on the directory entry succeeds
(length checks to avoid buffer overrun if received corrupt data)
- Preliminary El Torito boot specification support (No multiple boot entries yet)

24
src/libisofs/README Normal file
View File

@ -0,0 +1,24 @@
This is the 0.2 release of libisofs. For changes, see the ChangeLog.
Libisofs implements the reading of the famous ISO-9660 (ECMA-167) file system,
found on CD-ROM media. It also supports the Rock Ridge Interchange Protocol and
Microsoft Joliet extensions. It allows user-mode programs to query the
filesystem volume descriptors and traverse through the directory structure.
Preliminary support for El-Torito boot CDs are added in version 0.2.
To use it in your project, I recommend to copy bswap.h, isofs.h, iso_fs.h,
el_torito.h rock.h and isofs.c to your sources, and include isofs.h in the
appropriate places.
Currently only the directory tables are parsed, the path tables are not.
(The path tables contain redundant information.)
Also a sample program can be compiled with the supplied Makefile. Simply
execute 'make', it should create the executable file isofs.
On big-endian systems, you need to define WORDS_BIGENDIAN (either in the
compiler command-line, or if you defined HAVE_CONFIG_H, in config.h)
György Szombathelyi <gyurco@users.sourceforge.net>
http://libcdrom.sourceforge.net/libisofs.html

117
src/libisofs/bswap.h Normal file
View File

@ -0,0 +1,117 @@
/* From the mplayer project (www.mplayerhq.hu) */
#ifndef __BSWAP_H__
#define __BSWAP_H__
//#include "config-k3b.h"
#define ENABLE_DVD_RIPPING
/* #undef ENABLE_MUSICBRAINZ */
#define ENABLE_TAGLIB
#define HAVE_SYS_VFS_H
#define HAVE_SYS_STATVFS_H
#define HAVE_STAT64
#define K3B_VERSION_STRING "19.12.3"
/* #undef ENABLE_HAL_SUPPORT */
/* #undef ENABLE_AUDIO_PLAYER */
#define HAVE_BYTESWAP_H
/* #undef WORDS_BIGENDIAN */
#define HAVE_ICONV
/* #undef ICONV_SECOND_ARGUMENT_IS_CONST */
#define HAVE_FFMPEG_AVFORMAT_OPEN_INPUT
#define HAVE_FFMPEG_AV_DUMP_FORMAT
#define HAVE_FFMPEG_AVFORMAT_FIND_STREAM_INFO
#define HAVE_FFMPEG_AVFORMAT_CLOSE_INPUT
#define HAVE_FFMPEG_AVCODEC_OPEN2
/* #undef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO2 */
/* #undef HAVE_FFMPEG_AVCODEC_DECODE_AUDIO3 */
#define HAVE_FFMPEG_AVCODEC_DECODE_AUDIO4
#define HAVE_FFMPEG_AVMEDIA_TYPE
/* #undef HAVE_FFMPEG_CODEC_MP3 */
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#else
#ifdef ARCH_X86
inline static unsigned short ByteSwap16(unsigned short x)
{
__asm("xchgb %b0,%h0" :
"=q" (x) :
"0" (x));
return x;
}
#define bswap_16(x) ByteSwap16(x)
inline static unsigned int ByteSwap32(unsigned int x)
{
#if defined(__CPU__) && (__CPU__ > 386)
__asm("bswap %0":
"=r" (x) :
#else
__asm("xchgb %b0,%h0\n"
" rorl $16,%0\n"
" xchgb %b0,%h0":
"=q" (x) :
#endif
"0" (x));
return x;
}
#define bswap_32(x) ByteSwap32(x)
inline static unsigned long long int ByteSwap64(unsigned long long int x)
{
register union { __extension__ unsigned long long int __ll;
unsigned int __l[2]; } __x;
asm("xchgl %0,%1":
"=r"(__x.__l[0]),"=r"(__x.__l[1]):
"0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
return __x.__ll;
}
#define bswap_64(x) ByteSwap64(x)
#else
#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8)
/* code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. */
#define bswap_32(x) \
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#define bswap_64(x) \
(__extension__ \
({ union { __extension__ unsigned long long int __ll; \
unsigned int __l[2]; } __w, __r; \
__w.__ll = (x); \
__r.__l[0] = bswap_32 (__w.__l[1]); \
__r.__l[1] = bswap_32 (__w.__l[0]); \
__r.__ll; }))
#endif /* !ARCH_X86 */
#endif /* !HAVE_BYTESWAP_H */
/*
be2me ... BigEndian to MachineEndian
le2me ... LittleEndian to MachineEndian
*/
#ifdef WORDS_BIGENDIAN
#define be2me_16(x) (x)
#define be2me_32(x) (x)
#define be2me_64(x) (x)
#define le2me_16(x) bswap_16(x)
#define le2me_32(x) bswap_32(x)
#define le2me_64(x) bswap_64(x)
#else
#define be2me_16(x) bswap_16(x)
#define be2me_32(x) bswap_32(x)
#define be2me_64(x) bswap_64(x)
#define le2me_16(x) (x)
#define le2me_32(x) (x)
#define le2me_64(x) (x)
#endif
#endif

63
src/libisofs/el_torito.h Normal file
View File

@ -0,0 +1,63 @@
#ifndef ELTORITO_H
#define ELTORITO_H 1
#include "iso_fs.h"
#define EL_TORITO_ID "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0"
struct el_torito_boot_descriptor {
char type [ISODCL ( 1, 1)]; /* 711 */
char id [ISODCL ( 2, 6)];
char version [ISODCL ( 7, 7)]; /* 711 */
char system_id [ISODCL ( 8, 39)]; /* achars */
char unused [ISODCL ( 40, 71)];
char boot_catalog [ISODCL ( 72, 75)]; /* 731 */
};
struct validation_entry {
char type [ISODCL ( 1, 1)]; /* 1 */
char platform [ISODCL ( 2, 2)];
char unused [ISODCL ( 3, 4)];
char id [ISODCL ( 5, 28)];
char cheksum [ISODCL ( 29, 30)];
char key [ISODCL ( 31, 31)]; /* 0x55 */
char key2 [ISODCL ( 32, 32)]; /* 0xaa */
};
struct default_entry {
char bootid [ISODCL ( 1, 1)];
char media [ISODCL ( 2, 2)];
char loadseg [ISODCL ( 3, 4)];
char systype [ISODCL ( 5, 5)];
char unused [ISODCL ( 6, 6)];
char seccount [ISODCL ( 7, 8)];
char start [ISODCL ( 9, 12)];
char unused2 [ISODCL ( 13, 32)];
};
struct section_header {
char headerid [ISODCL ( 1, 1)];
char platform [ISODCL ( 2, 2)];
char entries [ISODCL ( 3, 4)];
char id [ISODCL ( 5, 32)];
};
struct section_entry {
char bootid [ISODCL ( 1, 1)];
char media [ISODCL ( 2, 2)];
char loadseg [ISODCL ( 3, 4)];
char systype [ISODCL ( 5, 5)];
char unused [ISODCL ( 6, 6)];
char seccount [ISODCL ( 7, 8)];
char start [ISODCL ( 9, 12)];
char selcrit [ISODCL ( 13, 13)];
char vendor_selcrit [ISODCL ( 14, 32)];
};
struct section_entry_ext {
char extid [ISODCL ( 1, 1)];
char extrec [ISODCL ( 2, 2)];
char vendor_selcrit [ISODCL ( 3, 32)];
};
#endif

219
src/libisofs/iso_fs.h Normal file
View File

@ -0,0 +1,219 @@
/* From the linux kernel */
#ifndef _ISO_FS_H
#define _ISO_FS_H 1
#include "bswap.h"
/*
* The isofs filesystem constants/structures
*/
/* This part borrowed from the bsd386 isofs */
#define ISODCL(from, to) (to - from + 1)
struct iso_volume_descriptor {
char type[ISODCL(1,1)]; /* 711 */
char id[ISODCL(2,6)];
char version[ISODCL(7,7)];
char data[ISODCL(8,2048)];
};
/* volume descriptor types */
#define ISO_VD_BOOT 0
#define ISO_VD_PRIMARY 1
#define ISO_VD_SUPPLEMENTARY 2
#define ISO_VD_END 255
#define ISO_STANDARD_ID "CD001"
struct iso_primary_descriptor {
char type [ISODCL ( 1, 1)]; /* 711 */
char id [ISODCL ( 2, 6)];
char version [ISODCL ( 7, 7)]; /* 711 */
char unused1 [ISODCL ( 8, 8)];
char system_id [ISODCL ( 9, 40)]; /* achars */
char volume_id [ISODCL ( 41, 72)]; /* dchars */
char unused2 [ISODCL ( 73, 80)];
char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
char unused3 [ISODCL ( 89, 120)];
char volume_set_size [ISODCL (121, 124)]; /* 723 */
char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
char logical_block_size [ISODCL (129, 132)]; /* 723 */
char path_table_size [ISODCL (133, 140)]; /* 733 */
char type_l_path_table [ISODCL (141, 144)]; /* 731 */
char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
char type_m_path_table [ISODCL (149, 152)]; /* 732 */
char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
char volume_set_id [ISODCL (191, 318)]; /* dchars */
char publisher_id [ISODCL (319, 446)]; /* achars */
char preparer_id [ISODCL (447, 574)]; /* achars */
char application_id [ISODCL (575, 702)]; /* achars */
char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
char file_structure_version [ISODCL (882, 882)]; /* 711 */
char unused4 [ISODCL (883, 883)];
char application_data [ISODCL (884, 1395)];
char unused5 [ISODCL (1396, 2048)];
};
/* Almost the same as the primary descriptor but two fields are specified */
struct iso_supplementary_descriptor {
char type [ISODCL ( 1, 1)]; /* 711 */
char id [ISODCL ( 2, 6)];
char version [ISODCL ( 7, 7)]; /* 711 */
char flags [ISODCL ( 8, 8)]; /* 853 */
char system_id [ISODCL ( 9, 40)]; /* achars */
char volume_id [ISODCL ( 41, 72)]; /* dchars */
char unused2 [ISODCL ( 73, 80)];
char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
char escape [ISODCL ( 89, 120)]; /* 856 */
char volume_set_size [ISODCL (121, 124)]; /* 723 */
char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
char logical_block_size [ISODCL (129, 132)]; /* 723 */
char path_table_size [ISODCL (133, 140)]; /* 733 */
char type_l_path_table [ISODCL (141, 144)]; /* 731 */
char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
char type_m_path_table [ISODCL (149, 152)]; /* 732 */
char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
char volume_set_id [ISODCL (191, 318)]; /* dchars */
char publisher_id [ISODCL (319, 446)]; /* achars */
char preparer_id [ISODCL (447, 574)]; /* achars */
char application_id [ISODCL (575, 702)]; /* achars */
char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
char file_structure_version [ISODCL (882, 882)]; /* 711 */
char unused4 [ISODCL (883, 883)];
char application_data [ISODCL (884, 1395)];
char unused5 [ISODCL (1396, 2048)];
};
#define HS_STANDARD_ID "CDROM"
struct hs_volume_descriptor {
char foo [ISODCL ( 1, 8)]; /* 733 */
char type [ISODCL ( 9, 9)]; /* 711 */
char id [ISODCL ( 10, 14)];
char version [ISODCL ( 15, 15)]; /* 711 */
char data[ISODCL(16,2048)];
};
struct hs_primary_descriptor {
char foo [ISODCL ( 1, 8)]; /* 733 */
char type [ISODCL ( 9, 9)]; /* 711 */
char id [ISODCL ( 10, 14)];
char version [ISODCL ( 15, 15)]; /* 711 */
char unused1 [ISODCL ( 16, 16)]; /* 711 */
char system_id [ISODCL ( 17, 48)]; /* achars */
char volume_id [ISODCL ( 49, 80)]; /* dchars */
char unused2 [ISODCL ( 81, 88)]; /* 733 */
char volume_space_size [ISODCL ( 89, 96)]; /* 733 */
char unused3 [ISODCL ( 97, 128)]; /* 733 */
char volume_set_size [ISODCL (129, 132)]; /* 723 */
char volume_sequence_number [ISODCL (133, 136)]; /* 723 */
char logical_block_size [ISODCL (137, 140)]; /* 723 */
char path_table_size [ISODCL (141, 148)]; /* 733 */
char type_l_path_table [ISODCL (149, 152)]; /* 731 */
char unused4 [ISODCL (153, 180)]; /* 733 */
char root_directory_record [ISODCL (181, 214)]; /* 9.1 */
};
/* We use this to help us look up the parent inode numbers. */
struct iso_path_table{
char name_len[1]; /* 711 */
char ext_attr_length[1]; /* 711 */
char extent[4]; /* 731 */
char parent[2]; /* 721 */
char name[1];
};
/* high sierra is identical to iso, except that the date is only 6 bytes, and
there is an extra reserved byte after the flags */
struct iso_directory_record {
char length [ISODCL (1, 1)]; /* 711 */
char ext_attr_length [ISODCL (2, 2)]; /* 711 */
char extent [ISODCL (3, 10)]; /* 733 */
char size [ISODCL (11, 18)]; /* 733 */
char date [ISODCL (19, 25)]; /* 7 by 711 */
char flags [ISODCL (26, 26)];
char file_unit_size [ISODCL (27, 27)]; /* 711 */
char interleave [ISODCL (28, 28)]; /* 711 */
char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
char name_len [ISODCL (33, 33)]; /* 711 */
char name [1];
};
/* 8 bit numbers */
__inline unsigned char isonum_711(char *p);
__inline char isonum_712(char *p);
/* 16 bit numbers */
__inline unsigned short isonum_721(char *p);
__inline unsigned short isonum_722(char *p);
__inline unsigned short isonum_723(char *p);
/* 32 bit numbers */
__inline unsigned int isonum_731(char *p);
__inline unsigned int isonum_732(char *p);
__inline unsigned int isonum_733(char *p);
/* 8 bit numbers */
__inline unsigned char isonum_711(char *p)
{
return *(unsigned char *)p;
}
__inline char isonum_712(char *p)
{
return *p;
}
/* 16 bit numbers */
__inline unsigned short isonum_721(char *p)
{
return le2me_16(*(unsigned short *)p);
}
__inline unsigned short isonum_722(char *p)
{
return be2me_16(*(unsigned short *)p);
}
__inline unsigned short isonum_723(char *p)
{
/* Ignore bigendian datum due to broken mastering programs */
return le2me_16(*(unsigned short *)p);
}
/* 32 bit numbers */
__inline unsigned int isonum_731(char *p)
{
return le2me_32(*(unsigned int *)p);
}
__inline unsigned int isonum_732(char *p)
{
return be2me_32(*(unsigned int *)p);
}
__inline unsigned int isonum_733(char *p)
{
/* Ignore bigendian datum due to broken mastering programs */
return le2me_32(*(unsigned int *)p);
}
#endif /*_ISOFS_H*/

875
src/libisofs/isofs.cpp Normal file
View File

@ -0,0 +1,875 @@
/***************************************************************************
isofs.c - libisofs implementation
-------------------
begin : Oct 25 2002
copyright : (C) 2002 by Szombathelyi György
email : gyurco@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "isofs.h"
#include "rock.h"
/* internal function from the linux kernel (isofs fs) */
static time_t getisotime(int year,int month,int day,int hour,
int minute,int second,int tz) {
int days, i;
time_t crtime;
year-=1970;
if (year < 0) {
crtime = 0;
} else {
int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
days = year * 365;
if (year > 2)
days += (year+1) / 4;
for (i = 1; i < month; ++i)
days += monlen[i-1];
if (((year+2) % 4) == 0 && month > 2)
days++;
days += day - 1;
crtime = ((((days * 24) + hour) * 60 + minute) * 60)
+ second;
/* sign extend */
if (tz & 0x80)
tz |= (-1 << 8);
/*
* The timezone offset is unreliable on some disks,
* so we make a sanity check. In no case is it ever
* more than 13 hours from GMT, which is 52*15min.
* The time is always stored in localtime with the
* timezone offset being what get added to GMT to
* get to localtime. Thus we need to subtract the offset
* to get to true GMT, which is what we store the time
* as internally. On the local system, the user may set
* their timezone any way they wish, of course, so GMT
* gets converted back to localtime on the receiving
* system.
*
* NOTE: mkisofs in versions prior to mkisofs-1.10 had
* the sign wrong on the timezone offset. This has now
* been corrected there too, but if you are getting screwy
* results this may be the explanation. If enough people
* complain, a user configuration option could be added
* to add the timezone offset in with the wrong sign
* for 'compatibility' with older discs, but I cannot see how
* it will matter that much.
*
* Thanks to kuhlmav@elec.canterbury.ac.nz (Volker Kuhlmann)
* for pointing out the sign error.
*/
if (-52 <= tz && tz <= 52)
crtime -= tz * 15 * 60;
}
return crtime;
}
/**
* Returns the Unix from the ISO9660 9.1.5 time format
*/
time_t isodate_915(char * p, int hs) {
return getisotime(1900+p[0],p[1],p[2],p[3],p[4],p[5],hs==0 ? p[6] : 0);
}
/**
* Returns the Unix from the ISO9660 8.4.26.1 time format
* BUG: hundredth of seconds are ignored, because Unix time_t has one second
* resolution (I think it's no problem at all)
*/
time_t isodate_84261(char * p, int hs) {
int year,month,day,hour,minute,second;
year=(p[0]-'0')*1000 + (p[1]-'0')*100 + (p[2]-'0')*10 + p[3]-'0';
month=(p[4]-'0')*10 + (p[5]-'0');
day=(p[6]-'0')*10 + (p[7]-'0');
hour=(p[8]-'0')*10 + (p[9]-'0');
minute=(p[10]-'0')*10 + (p[11]-'0');
second=(p[12]-'0')*10 + (p[13]-'0');
return getisotime(year,month,day,hour,minute,second,hs==0 ? p[16] : 0);
}
void FreeBootTable(boot_head *boot) {
boot_entry *be,*next;
be=boot->defentry;
while (be) {
next=be->next;
free(be);
be=next;
}
boot->defentry=NULL;
}
int BootImageSize(readfunc*,int media,sector_t,int len,void*) {
int ret;
switch(media & 0xf) {
case 0:
ret=len; /* No emulation */
break;
case 1:
ret=80*2*15; /* 1.2 MB */
break;
case 2:
ret=80*2*18; /* 1.44 MB */
break;
case 3:
ret=80*2*36; /* 2.88 MB */
break;
case 4:
/* FIXME!!! */
ret=len; /* Hard Disk */
break;
default:
ret=len;
}
return ret;
}
static boot_entry *CreateBootEntry(char *be) {
boot_entry *entry;
entry = (boot_entry*) malloc(sizeof(boot_entry));
if (!entry) return NULL;
memset(entry, 0, sizeof(boot_entry));
memcpy(entry->data,be,0x20);
return entry;
}
int ReadBootTable(readfunc *read,sector_t sector, boot_head *head, void *udata) {
char buf[2048], *c, *be;
int i,end=0;
unsigned short sum;
boot_entry *defcur=NULL,*deflast=NULL;
register struct validation_entry *ventry=NULL;
head->sections=NULL;
head->defentry=NULL;
while (1) {
be = (char*) &buf;
if ( read(be, sector, 1, udata) != 1 ) goto err;
/* first entry needs to be a validation entry */
if (!ventry) {
ventry=(struct validation_entry *) be;
if ( isonum_711(ventry->type) !=1 ) goto err;
sum=0;
c = (char*) ventry;
for (i=0;i<16;++i) { sum += isonum_721(c); c+=2; }
if (sum) goto err;
memcpy(&head->ventry,be,0x20);
be += 0x20;
}
while (!end && (be < (buf+1))) {
switch (isonum_711(be)) {
case 0x88:
defcur=CreateBootEntry(be);
if (!defcur) goto err;
if (deflast)
deflast->next=defcur;
else
head->defentry=defcur;
defcur->prev=deflast;
deflast=defcur;
break;
case 0x90:
case 0x91:
break;
default:
end=1;
break;
}
be += 0x20;
}
if (end) break;
sector ++;
}
return 0;
err:
FreeBootTable(head);
return -1;
}
/**
* Creates the linked list of the volume descriptors
*/
iso_vol_desc *ReadISO9660(readfunc *read,sector_t sector,void *udata) {
int i;
struct iso_volume_descriptor buf;
iso_vol_desc *first=NULL,*current=NULL,*prev=NULL;
for (i=0;i<100;i++) {
if (read( (char*) &buf, sector+i+16, 1, udata) != 1 ) {
FreeISO9660(first);
return NULL;
}
if (!memcmp(ISO_STANDARD_ID,&buf.id,5)) {
switch ( isonum_711(&buf.type[0]) ) {
case ISO_VD_BOOT:
case ISO_VD_PRIMARY:
case ISO_VD_SUPPLEMENTARY:
current=(iso_vol_desc*) malloc(sizeof(iso_vol_desc));
if (!current) {
FreeISO9660(first);
return NULL;
}
current->prev=prev;
current->next=NULL;
if (prev) prev->next=current;
memcpy(&(current->data),&buf,2048);
if (!first) first=current;
prev=current;
break;
case ISO_VD_END:
return first;
break;
}
} else if (!memcmp(HS_STANDARD_ID,(struct hs_volume_descriptor*) &buf,5)) {
/* High Sierra format not supported (yet) */
}
}
return first;
}
/**
* Frees the linked list of volume descriptors
*/
void FreeISO9660(iso_vol_desc *data) {
iso_vol_desc *current;
while (data) {
current=data;
data=current->next;
free(current);
}
}
/**
* Frees the strings in 'rrentry'
*/
void FreeRR(rr_entry *rrentry) {
if (rrentry->name) {
free(rrentry->name);
rrentry->name=NULL;
}
if (rrentry->sl) {
free(rrentry->sl);
rrentry->sl = NULL;
}
}
int str_nappend(char **d, char *s, int n)
{
int i = 0;
char *c;
while (i < n && s[i]) i++;
i++;
if (*d) i += (strlen(*d) + 1);
c = (char*) malloc(i);
if (!c) return -ENOMEM;
if (*d) {
strcpy(c, *d);
strncat(c, s, n);
free(*d);
} else
strncpy(c, s, n);
c[i - 1] = 0;
*d = c;
return 0;
}
static int str_append(char **d, const char *s) {
int i;
char *c;
i=strlen(s)+1;
if (*d) i+=(strlen(*d)+1);
c=(char*) malloc(i);
if (!c) return -ENOMEM;
if (*d) {
strcpy(c,*d);
strcat(c,s);
free(*d);
} else
strcpy(c,s);
c[i-1]=0;
*d=c;
return 0;
}
#define rrtlen(c) (((unsigned char) c & 0x80) ? 17 : 7)
#define rrctime(f,c) ((unsigned char) f & 0x80) ? isodate_84261(c,0) : isodate_915(c,0)
/**
* Parses the System Use area and fills rr_entry with values
*/
int ParseRR(struct iso_directory_record *idr, rr_entry *rrentry) {
int suspoffs,susplen,i,f,ret=0;
char *r, *c;
struct rock_ridge *rr;
suspoffs=33+isonum_711(idr->name_len);
if (!(isonum_711(idr->name_len) & 1)) suspoffs++;
susplen=isonum_711(idr->length)-suspoffs;
r= & (((char*) idr)[suspoffs]);
rr = (struct rock_ridge*) r;
memset(rrentry,0,sizeof(rr_entry));
rrentry->len = sizeof(rr_entry);
while (susplen > 0) {
if (isonum_711(&rr->len) > susplen || rr->len == 0) break;
if (rr->signature[0]=='N' && rr->signature[1]=='M') {
if (!(rr->u.NM.flags & 0x26) && rr->len>5 && !rrentry->name) {
if (str_nappend(&rrentry->name,rr->u.NM.name,isonum_711(&rr->len)-5)) {
FreeRR(rrentry); return -ENOMEM;
}
ret++;
}
} else if (rr->signature[0]=='P' && rr->signature[1]=='X' &&
(isonum_711(&rr->len)==44 || isonum_711(&rr->len)==36)) {
rrentry->mode=isonum_733(rr->u.PX.mode);
rrentry->nlink=isonum_733(rr->u.PX.n_links);
rrentry->uid=isonum_733(rr->u.PX.uid);
rrentry->gid=isonum_733(rr->u.PX.gid);
if (isonum_711(&rr->len)==44) rrentry->serno=isonum_733(rr->u.PX.serno);
ret++;
} else if (rr->signature[0]=='P' && rr->signature[1]=='N' &&
isonum_711(&rr->len)==20) {
rrentry->dev_major=isonum_733(rr->u.PN.dev_high);
rrentry->dev_minor=isonum_733(rr->u.PN.dev_low);
ret++;
} else if (rr->signature[0]=='P' && rr->signature[1]=='L' &&
isonum_711(&rr->len)==12) {
rrentry->pl=isonum_733(rr->u.PL.location);
ret++;
} else if (rr->signature[0]=='C' && rr->signature[1]=='L' &&
isonum_711(&rr->len)==12) {
rrentry->cl=isonum_733(rr->u.CL.location);
ret++;
} else if (rr->signature[0]=='R' && rr->signature[1]=='E' &&
isonum_711(&rr->len)==4) {
rrentry->re=1;
ret++;
} else if (rr->signature[0]=='S' && rr->signature[1]=='L' &&
isonum_711(&rr->len)>7) {
i = isonum_711(&rr->len)-5;
c = (char*) rr;
c += 5;
while (i>0) {
switch(c[0] & ~1) {
case 0x2:
if (str_append(&rrentry->sl,".")) {
FreeRR(rrentry); return -ENOMEM;
}
break;
case 0x4:
if (str_append(&rrentry->sl,"..")) {
FreeRR(rrentry); return -ENOMEM;
}
break;
}
if ( (c[0] & 0x08) == 0x08 || (c[1] && rrentry->sl &&
strlen(rrentry->sl)>1) ) {
if (str_append(&rrentry->sl,"/")) {
FreeRR(rrentry); return -ENOMEM;
}
}
if ((unsigned char)c[1]>0) {
if (str_nappend(&rrentry->sl,c+2,(unsigned char)c[1])) {
FreeRR(rrentry); return -ENOMEM;
}
}
i -= ((unsigned char)c[1] + 2);
c += ((unsigned char)c[1] + 2);
}
ret++;
} else if (rr->signature[0]=='T' && rr->signature[1]=='F' &&
isonum_711(&rr->len)>5) {
i = isonum_711(&rr->len)-5;
f = rr->u.TF.flags;
c = (char*) rr;
c += 5;
while (i >= rrtlen(f)) {
if (f & 1) {
rrentry->t_creat=rrctime(f,c);
f &= ~1;
} else if (f & 2) {
rrentry->rr_st_mtime=rrctime(f,c);
f &= ~2;
} else if (f & 4) {
rrentry->rr_st_atime=rrctime(f,c);
f &= ~4;
} else if (f & 8) {
rrentry->rr_st_ctime=rrctime(f,c);
f &= ~8;
} else if (f & 16) {
rrentry->t_backup=rrctime(f,c);
f &= ~16;
} else if (f & 32) {
rrentry->t_expire=rrctime(f,c);
f &= ~32;
} else if (f & 64) {
rrentry->t_effect=rrctime(f,c);
f &= ~64;
}
i -= rrtlen(f);
c += rrtlen(f);
}
ret++;
} else if (rr->signature[0]=='Z' && rr->signature[1]=='F' &&
isonum_711(&rr->len)==16) {
/* Linux-specific extension: transparent decompression */
rrentry->z_algo[0]=rr->u.ZF.algorithm[0];
rrentry->z_algo[1]=rr->u.ZF.algorithm[1];
rrentry->z_params[0]=rr->u.ZF.parms[0];
rrentry->z_params[1]=rr->u.ZF.parms[1];
rrentry->z_size=isonum_733(rr->u.ZF.real_size);
ret++;
} else {
/* printf("SUSP sign: %c%c\n",rr->signature[0],rr->signature[1]); */
}
susplen -= isonum_711(&rr->len);
r += isonum_711(&rr->len);
rr = (struct rock_ridge*) r;
}
return ret;
}
/**
* Iterates over the directory entries. The directory is in 'buf',
* the size of the directory is 'size'. 'callback' is called for each
* directory entry with the parameter 'udata'.
*/
int ProcessDir(readfunc *read,int extent,int size,dircallback *callback,void *udata) {
int pos=0,ret=0,siz;
char *buf;
struct iso_directory_record *idr;
if (size & 2047) {
siz=((size>>11)+1)<<11;
} else {
siz=size;
}
buf=(char*) malloc(siz);
if (!buf) return -ENOMEM;
if (read(buf,extent,siz>>11,udata)!=siz>>11) {
free(buf);
return -EIO;
}
while (size>0) {
idr=(struct iso_directory_record*) &buf[pos];
if (isonum_711(idr->length)==0) {
size-=(2048 - (pos & 0x7ff));
if (size<=2) break;
pos+=0x800;
pos&=0xfffff800;
idr=(struct iso_directory_record*) &buf[pos];
}
pos+=isonum_711(idr->length);
pos+=isonum_711(idr->ext_attr_length);
size-=isonum_711(idr->length);
size-=isonum_711(idr->ext_attr_length);
if (size<0) break;
if (isonum_711(idr->length)
<33 ||
isonum_711(idr->length)<33+isonum_711(idr->name_len)) {
/* Invalid directory entry */
continue;
}
if ((ret=callback(idr,udata))) break;
}
free(buf);
return ret;
}
/**
* returns the joliet level from the volume descriptor
*/
int JolietLevel(struct iso_volume_descriptor *ivd) {
int ret=0;
register struct iso_supplementary_descriptor *isd;
isd = (struct iso_supplementary_descriptor *) ivd;
if (isonum_711(ivd->type)==ISO_VD_SUPPLEMENTARY) {
if (isd->escape[0]==0x25 &&
isd->escape[1]==0x2f) {
switch (isd->escape[2]) {
case 0x40:
ret=1;
break;
case 0x43:
ret=2;
break;
case 0x45:
ret=3;
break;
}
}
}
return ret;
}
/********************************************************************/
#if 0
#include <time.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <iconv.h>
int level=0,joliet=0,dirs,files;
iconv_t iconv_d;
int fd;
int readf(char *buf, int start, int len,void *udata) {
int ret;
if ((ret=lseek(fd, start << 11, SEEK_SET))<0) return ret;
ret=read(fd, buf, len << 11);
if (ret<0) return ret;
return (ret >> 11);
}
void dumpchars(char *c,int len) {
while (len>0) {
printf("%c",*c);
len--;
c++;
}
}
void sp(int num) {
int i;
for (i=0;i<num*5;i++) { printf(" "); };
}
void dumpflags(char flags) {
if (flags & 1) printf("HIDDEN ");
if (flags & 2) printf("DIR ");
if (flags & 4) printf("ASF ");
}
void dumpjoliet(char *c,int len) {
char outbuf[255];
size_t out;
int ret;
char *outptr;
outptr=(char*) &outbuf;
out=255;
if ((iconv(iconv_d,&c,&len,&outptr,&out))<0) {
printf("conversion error=%d",errno);
return;
}
ret=255-out;
dumpchars((char*) &outbuf,ret);
}
void dumpchardesc(char *c,int len) {
if (joliet)
dumpjoliet(c,len);
else {
dumpchars(c,len);
}
}
void dumpiso915time(char *t, int hs) {
time_t time;
char *c;
time=isodate_915(t,hs);
c=(char*) ctime(&time);
if (c && c[strlen(c)-1]==0x0a) c[strlen(c)-1]=0;
if (c) printf("%s",c);
}
void dumpiso84261time(char *t, int hs) {
time_t time;
char *c;
time=isodate_84261(t,hs);
c=(char*) ctime(&time);
if (c && c[strlen(c)-1]==0x0a) c[strlen(c)-1]=0;
if (c) printf("%s",c);
}
void dumpdirrec(struct iso_directory_record *dir) {
if (isonum_711(dir->name_len)==1) {
switch (dir->name[0]) {
case 0:
printf(".");
break;
case 1:
printf("..");
break;
default:
printf("%c",dir->name[0]);
break;
}
}
dumpchardesc(dir->name,isonum_711(dir->name_len));
printf(" size=%d",isonum_733(dir->size));
printf(" extent=%d ",isonum_733(dir->extent));
dumpflags(isonum_711(dir->flags));
dumpiso915time((char*) &(dir->date),0);
}
void dumprrentry(rr_entry *rr) {
printf(" NM=[%s] uid=%d gid=%d nlink=%d mode=%o ",
rr->name,rr->uid,rr->gid,rr->nlink,rr->mode);
if (S_ISCHR(rr->mode) || S_ISBLK(rr->mode))
printf("major=%d minor=%d ",rr->dev_major,rr->dev_minor);
if (rr->mode & S_IFLNK && rr->sl) printf("slink=%s ",rr->sl);
/*
printf("\n");
if (rr->t_creat) printf("t_creat: %s",ctime(&rr->t_creat));
if (rr->rr_st_mtime) printf("rr_st_mtime: %s",ctime(&rr->rr_st_mtime));
if (rr->rr_st_atime) printf("rr_st_atime: %s",ctime(&rr->rr_st_atime));
if (rr->rr_st_ctime) printf("rr_st_ctime: %s",ctime(&rr->rr_st_ctime));
if (rr->t_backup) printf("t_backup: %s",ctime(&rr->t_backup));
if (rr->t_expire) printf("t_expire: %s",ctime(&rr->t_expire));
if (rr->t_effect) printf("t_effect: %s",ctime(&rr->t_effect));
*/
}
void dumpsusp(char *c, int len) {
dumpchars(c,len);
}
void dumpboot(struct el_torito_boot_descriptor *ebd) {
printf("version: %d\n",isonum_711(ebd->version));
printf("system id: ");dumpchars(ebd->system_id,ISODCL(8,39));printf("\n");
printf("boot catalog start: %d\n",isonum_731(ebd->boot_catalog));
}
void dumpdefentry(struct default_entry *de) {
printf("Default entry: \n");
printf(" bootid=%x\n",isonum_711(de->bootid));
printf(" media emulation=%d (",isonum_711(de->media));
switch(isonum_711(de->media) & 0xf) {
case 0:
printf("No emulation");
break;
case 1:
printf("1.2 Mb floppy");
break;
case 2:
printf("1.44 Mb floppy");
break;
case 3:
printf("2.88 Mb floppy");
break;
case 4:
printf("Hard Disk");
break;
default:
printf("Unknown/Invalid");
break;
}
printf(")\n");
printf(" loadseg=%d\n",isonum_721(de->loadseg));
printf(" systype=%d\n",isonum_711(de->systype));
printf(" start lba=%d count=%d\n",isonum_731(de->start),
isonum_721(de->seccount));
}
void dumpbootcat(boot_head *bh) {
boot_entry *be;
printf("System id: ");dumpchars(bh->ventry.id,ISODCL(28,5));printf("\n");
be=bh->defentry;
while (be) {
dumpdefentry(be->data);
be=be->next;
}
}
void dumpdesc(struct iso_primary_descriptor *ipd) {
printf("system id: ");dumpchardesc(ipd->system_id,ISODCL(9,40));printf("\n");
printf("volume id: ");dumpchardesc(ipd->volume_id,ISODCL(41,72));printf("\n");
printf("volume space size: %d\n",isonum_733(ipd->volume_space_size));
printf("volume set size: %d\n",isonum_723(ipd->volume_set_size));
printf("volume seq num: %d\n",isonum_723(ipd->volume_set_size));
printf("logical block size: %d\n",isonum_723(ipd->logical_block_size));
printf("path table size: %d\n",isonum_733(ipd->path_table_size));
printf("location of type_l path table: %d\n",isonum_731(ipd->type_l_path_table));
printf("location of optional type_l path table: %d\n",isonum_731(ipd->opt_type_l_path_table));
printf("location of type_m path table: %d\n",isonum_732(ipd->type_m_path_table));
printf("location of optional type_m path table: %d\n",isonum_732(ipd->opt_type_m_path_table));
/*
printf("Root dir record:\n");dumpdirrec((struct iso_directory_record*) &ipd->root_directory_record);
*/
printf("Volume set id: ");dumpchardesc(ipd->volume_set_id,ISODCL(191,318));printf("\n");
printf("Publisher id: ");dumpchardesc(ipd->publisher_id,ISODCL(319,446));printf("\n");
printf("Preparer id: ");dumpchardesc(ipd->preparer_id,ISODCL(447,574));printf("\n");
printf("Application id: ");dumpchardesc(ipd->application_id,ISODCL(575,702));printf("\n");
printf("Copyright id: ");dumpchardesc(ipd->copyright_file_id,ISODCL(703,739));printf("\n");
printf("Abstract file id: ");dumpchardesc(ipd->abstract_file_id,ISODCL(740,776));printf("\n");
printf("Bibliographic file id: ");dumpchardesc(ipd->bibliographic_file_id,ISODCL(777,813));printf("\n");
printf("Volume creation date: ");dumpiso84261time(ipd->creation_date,0);printf("\n");
printf("Volume modification date: ");dumpiso84261time(ipd->modification_date,0);printf("\n");
printf("Volume expiration date: ");dumpiso84261time(ipd->expiration_date,0);printf("\n");
printf("Volume effective date: ");dumpiso84261time(ipd->effective_date,0);printf("\n");
printf("File structure version: %d\n",isonum_711(ipd->file_structure_version));
}
int mycallb(struct iso_directory_record *idr,void *udata) {
rr_entry rrentry;
sp(level);dumpdirrec(idr);
if (level==0) printf(" (Root directory) ");
printf("\n");
if (ParseRR(idr,&rrentry)>0) {
sp(level);printf(" ");dumprrentry(&rrentry);printf("\n");
}
FreeRR(&rrentry);
if ( !(idr->flags[0] & 2) ) files++;
if ( (idr->flags[0] & 2) && (level==0 || isonum_711(idr->name_len)>1) ) {
level++;
dirs++;
ProcessDir(&readf,isonum_733(idr->extent),isonum_733(idr->size),&mycallb,udata);
level--;
}
return 0;
}
/************************************************/
int main(int argc, char *argv[]) {
int i=1,sector=0;
iso_vol_desc *desc;
boot_head boot;
if (argc<2) {
fprintf(stderr,"\nUsage: %s iso-file-name or device [starting sector]\n\n",argv[0]);
return 0;
}
if (argc>=3) {
sector=atoi(argv[2]);
printf("Using starting sector number %d\n",sector);
}
fd=open(argv[1],O_RDONLY);
if (fd<0) {
fprintf(stderr,"open error\n");
return -1;
}
iconv_d=iconv_open("ISO8859-2","UTF16BE");
if (iconv_d==0) {
fprintf(stderr,"iconv open error\n");
return -1;
}
desc=ReadISO9660(&readf,sector,NULL);
if (!desc) {
printf("No volume descriptors\n");
return -1;
}
while (desc) {
printf("\n\n--------------- Volume descriptor (%d.) type %d: ---------------\n\n",
i,isonum_711(desc->data.type));
switch (isonum_711(desc->data.type)) {
case ISO_VD_BOOT: {
struct el_torito_boot_descriptor* bootdesc;
bootdesc=&(desc->data);
dumpboot(bootdesc);
if ( !memcmp(EL_TORITO_ID,bootdesc->system_id,ISODCL(8,39)) ) {
if (ReadBootTable(&readf,isonum_731(bootdesc->boot_catalog),&boot,NULL)) {
printf("Boot Catalog Error\n");
} else {
dumpbootcat(&boot);
FreeBootTable(&boot);
}
}
}
break;
case ISO_VD_PRIMARY:
case ISO_VD_SUPPLEMENTARY:
joliet=0;
joliet = JolietLevel(&desc->data);
printf("Joliet level: %d\n",joliet);
dumpdesc((struct iso_primary_descriptor*) &desc->data);
printf("\n\n--------------- Directory structure: -------------------\n\n");
dirs=0;files=0;
mycallb( &( ((struct iso_primary_descriptor*) &desc->data)->root_directory_record), NULL );
printf("\nnumber of directories: %d\n",dirs);
printf("\nnumber of files: %d\n",files);
break;
}
desc=desc->next;
i++;
}
iconv_close(iconv_d);
close(fd);
FreeISO9660(desc);
return 0;
}
#endif

153
src/libisofs/isofs.h Normal file
View File

@ -0,0 +1,153 @@
/***************************************************************************
isofs.h - include this file to use libisofs
-------------------
begin : Oct 25 2002
copyright : (C) 2002 by Szombathelyi György
email : gyurco@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ISOFS_H
#define ISOFS_H
#include <sys/time.h>
#include "iso_fs.h"
#include "el_torito.h"
typedef long sector_t;
typedef struct _rr_entry {
int len; /* length of structure */
char *name; /* Name from 'NM' */
char *sl; /* symbolic link data */
time_t t_creat;
time_t rr_st_mtime;
time_t rr_st_atime;
time_t rr_st_ctime;
time_t t_backup;
time_t t_expire;
time_t t_effect;
int mode; /* POSIX file modes */
int nlink;
int uid;
int gid;
int serno;
int dev_major;
int dev_minor;
int pl; /* parent location */
int cl; /* child location */
int re; /* relocated */
char z_algo[2]; /* zizofs algorithm */
char z_params[2]; /* zizofs parameters */
int z_size; /* zizofs real_size */
} rr_entry;
typedef struct _iso_vol_desc {
struct _iso_vol_desc *next;
struct _iso_vol_desc *prev;
struct iso_volume_descriptor data;
} iso_vol_desc;
typedef struct _boot_entry {
struct _boot_entry *next;
struct _boot_entry *prev;
struct _boot_entry *parent;
struct _boot_entry *child;
char data[32];
} boot_entry;
typedef struct _boot_head {
struct validation_entry ventry;
struct _boot_entry *defentry;
struct _boot_entry *sections;
} boot_head;
/**
* this callback function needs to read 'len' sectors from 'start' into 'buf'
*/
typedef int readfunc(char *buf,sector_t start, int len,void *);
/**
* ProcessDir uses this callback
*/
typedef int dircallback(struct iso_directory_record *,void *);
/**
* Returns the Unix from the ISO9660 9.1.5 (7 bytes) time format
* This function is from the linux kernel.
* Set 'hs' to non-zero if it's a HighSierra volume
*/
time_t isodate_915(char * p, int hs);
/**
* Returns the Unix time from the ISO9660 8.4.26.1 (17 bytes) time format
* BUG: hundredth of seconds are ignored, because time_t has one second
* resolution (I think it's no problem at all)
* Set 'hs' to non-zero if it's a HighSierra volume
*/
time_t isodate_84261(char * p, int hs);
/**
* Creates the linked list of the volume descriptors
* 'sector' is the starting sector number of where the filesystem start
* (starting sector of a session on a CD-ROM)
* If the function fails, returns NULL
* Don't forget to call FreeISO9660 after using the volume descriptor list!
*/
iso_vol_desc *ReadISO9660(readfunc *read,sector_t sector,void *udata);
/**
* Frees the linked list of volume descriptors.
*/
void FreeISO9660(iso_vol_desc *data);
/**
* Iterates over the directory entries. The directory is in 'buf',
* the size of the directory is 'size'. 'callback' is called for each
* directory entry with the parameter 'udata'.
*/
int ProcessDir(readfunc *read,int extent,int size,dircallback *callback,void *udata);
/**
* Parses the System Use area and fills rr_entry with values
*/
int ParseRR(struct iso_directory_record *idr, rr_entry *rrentry);
/**
* Frees the strings in 'rrentry'
*/
void FreeRR(rr_entry *rrentry);
/**
* returns the joliet level from the volume descriptor
*/
int JolietLevel(struct iso_volume_descriptor *ivd);
/**
* Returns the size of the boot image (in 512 byte sectors)
*/
int BootImageSize(readfunc *read,int media,sector_t start,int len,void *udata);
/**
* Frees the boot catalog entries in 'boot'. If you ever called ReadBootTable,
* then don't forget to call FreeBootTable!
*/
void FreeBootTable(boot_head *boot);
/**
* Reads the boot catalog into 'head'. Don't forget to call FreeBootTable!
*/
int ReadBootTable(readfunc *read,sector_t sector, boot_head *head, void *udata);
int str_nappend(char **d, char *s, int n);
#endif

127
src/libisofs/rock.h Normal file
View File

@ -0,0 +1,127 @@
/* this header is from the linux kernel */
#ifndef ROCK_H
#define ROCK_H 1
/* These structs are used by the system-use-sharing protocol, in which the
Rock Ridge extensions are embedded. It is quite possible that other
extensions are present on the disk, and this is fine as long as they
all use SUSP */
struct SU_SP{
unsigned char magic[2];
unsigned char skip;
};
struct SU_CE{
char extent[8];
char offset[8];
char size[8];
};
struct SU_ER{
unsigned char len_id;
unsigned char len_des;
unsigned char len_src;
unsigned char ext_ver;
char data[1];
};
struct RR_RR{
char flags[1];
};
struct RR_PX{
char mode[8];
char n_links[8];
char uid[8];
char gid[8];
char serno[8];
};
struct RR_PN{
char dev_high[8];
char dev_low[8];
};
struct SL_component{
unsigned char flags;
unsigned char len;
char text[1];
};
struct RR_SL{
unsigned char flags;
struct SL_component link;
};
struct RR_NM{
unsigned char flags;
char name[1];
};
struct RR_CL{
char location[8];
};
struct RR_PL{
char location[8];
};
struct stamp{
char time[7];
};
struct RR_TF{
char flags;
struct stamp times[1]; /* Variable number of these beasts */
};
/* Linux-specific extension for transparent decompression */
struct RR_ZF{
char algorithm[2];
char parms[2];
char real_size[8];
};
/* These are the bits and their meanings for flags in the TF structure. */
#define TF_CREATE 1
#define TF_MODIFY 2
#define TF_ACCESS 4
#define TF_ATTRIBUTES 8
#define TF_BACKUP 16
#define TF_EXPIRATION 32
#define TF_EFFECTIVE 64
#define TF_LONG_FORM 128
struct rock_ridge{
char signature[2];
char len; /* 711 */
char version; /* 711 */
union{
struct SU_SP SP;
struct SU_CE CE;
struct SU_ER ER;
struct RR_RR RR;
struct RR_PX PX;
struct RR_PN PN;
struct RR_SL SL;
struct RR_NM NM;
struct RR_CL CL;
struct RR_PL PL;
struct RR_TF TF;
struct RR_ZF ZF;
} u;
};
#define RR_PX 1 /* POSIX attributes */
#define RR_PN 2 /* POSIX devices */
#define RR_SL 4 /* Symbolic link */
#define RR_NM 8 /* Alternate Name */
#define RR_CL 16 /* Child link */
#define RR_PL 32 /* Parent link */
#define RR_RE 64 /* Relocation directory */
#define RR_TF 128 /* Timestamps */
#endif /* ROCK_H */

View File

@ -18,6 +18,7 @@
#include <QCommandLineParser>
#include <ukui-log4qt.h>
#include <QTranslator>
#include <QLibraryInfo>
#include <kwidget.h>
#include <ukuistylehelper/ukuistylehelper.h>
#include <windowmanager/windowmanager.h>
@ -38,10 +39,17 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
setlocale(QLocale::China, "zh_CN");
trans.load("qt_zh_CN.qm", "/usr/share/qt5/translations/");
a.installTranslator(&trans);
// QT自身标准的翻译
#ifndef QT_NO_TRANSLATION
QString locale = QLocale::system().name();
QString translatorFileName = QLatin1String("qt_");
translatorFileName += locale;
QTranslator *selfTransOfQt = new QTranslator();
if (selfTransOfQt->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
a.installTranslator(selfTransOfQt);
else
qDebug() << "load qt translator file failed!";
#endif
//initUkuiLog4qt("burner");
ABOUT->init();
@ -53,6 +61,10 @@ int main(int argc, char *argv[])
CFG->set("DataSetting", "Delete Data", true);
CFG->set("DataSetting", "Clean Data", true);
CFG->set("FilterFile","hidden",false);
CFG->set("FilterFile","broken",false);
CFG->set("FilterFile","Repleace",false);
LOGGER->init();
MENU->init();
MODAL->init();
@ -75,18 +87,18 @@ int main(int argc, char *argv[])
//图标库主题的刻录图片名换为burner
//a.setWindowIcon(QIcon::fromTheme("disk-burner"));
a.setWindowIcon(QIcon::fromTheme("burner"));
QCoreApplication::setApplicationName(_("Burner"));
//判断是否是wayland环境
bool isWayland = false;
if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
//判断是否是wayland环境
bool isWayland = false;
if(QString(qgetenv("XDG_SESSION_TYPE")) == "wayland") {
qputenv("QT_QPA_PLATFORM", "wayland");
isWayland = true;
}
}
MainWindow w(parser->positionalArguments(), nullptr);
if(isWayland) {
kdk::UkuiStyleHelper::self()->removeHeader(&w);
if(isWayland) {
kdk::UkuiStyleHelper::self()->removeHeader(&w);
// set window position
int sw = QGuiApplication::primaryScreen()->availableGeometry().width();
int sh = QGuiApplication::primaryScreen()->availableGeometry().height();

152
src/model/diroptutils.cpp Normal file
View File

@ -0,0 +1,152 @@
#include "diroptutils.h"
#include <QMapIterator>
#include <QFileInfo>
#include <QFileInfoList>
#include <QMap>
#include <QDir>
#include <QDebug>
#include <QCryptographicHash>
DirOptUtils::DirOptUtils()
{
mMap.clear();
}
DirOptUtils::~DirOptUtils()
{
}
void DirOptUtils::testPrintMap()
{
QMapIterator<QString, QString> iterator(mMap);
while (iterator.hasNext()) {
iterator.next();
qDebug() << iterator.key() << ":" << iterator.value();
}
}
QStringList DirOptUtils::getFileListUnderDir1(const QString &dirPath)
{
//最外层目录
QStringList fileList;
mdirPath = dirPath;
QDir dir(dirPath);
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot | QDir::Dirs| QDir::Hidden);
foreach (auto fileInfo, fileInfoList) {
if(fileInfo.isDir())
{
getFileListUnderDir2(fileInfo.absoluteFilePath());
}
if(fileInfo.isFile())
{
if (0 == fileInfo.fileName().compare("md5sum.txt") || 0 == fileInfo.fileName().compare(".md5sum.txt")){
} else {
// 计算文件md5值并写入map中
QString md5output = calculateMd5(fileInfo.absoluteFilePath());
QString fileRelativePath = fileInfo.absoluteFilePath();
fileRelativePath = "." + fileRelativePath.mid(mdirPath.length()); //绝对路径变相对路径
mMap.insert(fileRelativePath, md5output);
qDebug() << __FUNCTION__ << __LINE__ << mdirPath << "absolute path=[" << fileInfo.absoluteFilePath() << "] relativePath: [" << fileRelativePath << "]";
}
}
}
return fileList;
}
QStringList DirOptUtils::getFileListUnderDir2(const QString &dirPath)
{
//里层目录
QStringList fileList;
QDir dir(dirPath);
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden);
foreach (auto fileInfo, fileInfoList) {
if(fileInfo.isDir())
{
getFileListUnderDir2(fileInfo.absoluteFilePath());
}
if(fileInfo.isFile())
{
// 计算文件md5值并写入map中
QString md5output = calculateMd5(fileInfo.absoluteFilePath());
QString fileRelativePath = fileInfo.absoluteFilePath();
fileRelativePath = "." + fileRelativePath.mid(mdirPath.length()); //绝对路径变相对路径
mMap.insert(fileRelativePath, md5output);
qDebug() << __FUNCTION__ << __LINE__ << mdirPath << "absolute path=[" << fileInfo.absoluteFilePath() << "] relativePath: [" << fileRelativePath << "]";
}
}
return fileList;
}
QString DirOptUtils::calculateMd5(const QString &path)
{
/* 打开文件 */
QFile file(path);
if(!file.open(QIODevice::ReadOnly))
{
qDebug()<<"文件打开错误";
return QString();
}
QCryptographicHash md5_hash(QCryptographicHash::Md5);
md5_hash.reset();
/* 文本读取 */
while(!file.atEnd())
{
md5_hash.addData(file.readLine());
}
return md5_hash.result().toHex();
}
//获取文件的相对路径
QString DirOptUtils::getRelativePath(const QString &filePath)
{
QString fileRelativePath = filePath;
}
//在指定目录下生成md5sum.txt文件
bool DirOptUtils::generateCheckFile()
{
// 1 生成校验文件.md5sum.txt文件
QDir tempDir;
QString fileName = ".md5sum.txt";
if (!tempDir.exists(mdirPath)) {
qDebug() << "dir: [" << mdirPath << "] is not exist";
return false;
}
QFile tempFile;
tempDir.setCurrent(mdirPath);
if (tempFile.exists(fileName)) {
qDebug() << QString("dir[%1] has exist, so we need delete it.").arg(tempDir.path());
// 删除它
tempFile.remove(fileName);
}
tempFile.setFileName(fileName);
if (tempFile.open(QIODevice::ReadWrite | QIODevice::Text)) {
QMapIterator<QString, QString> iterator(mMap);
while (iterator.hasNext()) {
iterator.next();
QString path = iterator.key();
QString md5 = iterator.value();
QString output = md5 + " " + path + "\n";
QTextStream out(&tempFile);
out << output;
}
tempFile.close();
qDebug() << "写完成";
} else {
qDebug() << "failed to open file";
}
}

24
src/model/diroptutils.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef DIROPTUTILS_H
#define DIROPTUTILS_H
#include <QObject>
#include <QMap>
class DirOptUtils
{
public:
DirOptUtils();
~DirOptUtils();
QStringList getFileListUnderDir1(const QString&); //遍历当前路径下文件
QStringList getFileListUnderDir2(const QString&);
QString getRelativePath(const QString&);
QString calculateMd5(const QString&);
void testPrintMap();
bool generateCheckFile();
private:
QMap<QString, QString> mMap;
QString mdirPath;
};
#endif // DIROPTUTILS_H

View File

@ -4,9 +4,12 @@
#include "src/data/datacdrom.h"
#include "src/po/translation.h"
#include "src/view/filefilterrules.h"
#include "src/frame/configuration.h"
#include <QFont>
#include <QBrush>
#include <QDebug>
#include <ukuistylehelper.h>
FileFilterModel::FileFilterModel(QObject *parent)
: QAbstractItemModel(parent),
@ -205,6 +208,7 @@ void FileFilterModel::addFilterNode(void *c)
void FileFilterModel::deleteFilterNode(int idx)
{
qDebug()<<__LINE__<<__func__<<idx;
DataDirectory *root;
if (idx >= m_oRoots.size() || idx < 0) return;
@ -226,8 +230,11 @@ void FileFilterModel::showRules()
if (root)
{
FILTERRULES->init(root);
if (FILTERRULES->isHidden())
if (FILTERRULES->isHidden()) {
if(FILTERRULES->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(FILTERRULES);
FILTERRULES->show();
}
else
FILTERRULES->activateWindow();
}
@ -240,7 +247,8 @@ void FileFilterModel::addFilterData(int idx, void *d)
root = (DataDirectory *)m_oRoots.at(idx);
if (nullptr == root) return;
beginInsertRows(createIndex(idx, 0, root), root->counts(), 1);
root->filterAppend((DataFile *)d);
root->append((DataFile *)d);
// root->filterAppend((DataFile *)d);
endInsertRows();
root->turnViewFilterFileToHidden();
root->turnViewFilterFileToBrokenSymbolLinks();
@ -263,15 +271,30 @@ void FileFilterModel::recovery(/*QModelIndexList idxes*/)
replaces.clear();
root = static_cast<DataDirectory *>(m_oRoots.at(m_iIndex));
qDebug()<<__LINE__<<__func__<<root->counts();
for (int i = 0; i < root->counts(); ++i)
{
child = root->at(i);
beginRemoveRows(createIndex(m_iIndex, 0, m_oRoots.at(m_iIndex)), 0, 1);
root->take(child);
--i;
endRemoveRows();
if (child->attrHidden()) hiddens << child;
else if (child->attrSymbolLink() && child->linkTarget()) replaces << child;
else brokens << child;
if (child->attrHidden())
{
CFG->set("FilterFile","hidden",!child->attrHidden());
hiddens << child;
}
else if (child->attrSymbolLink() && child->linkTarget())
{
CFG->set("FilterFile","Repleace",!child->attrSymbolLink());
replaces << child;
}
else
{
CFG->set("FilterFile","broken",false);
brokens << child;
}
}
#if 0
@ -303,6 +326,7 @@ void FileFilterModel::recovery(/*QModelIndexList idxes*/)
}
}
#endif
qDebug()<<__func__<<__LINE__<<"FileFilterModel"<<hiddens.size();
recovery(hiddens, brokens, replaces);
root->turnViewFilterFileToHidden();
root->turnViewFilterFileToBrokenSymbolLinks();
@ -323,6 +347,7 @@ QList<void *> FileFilterModel::recoveryHiddenData(int idx, int level)
file = root->at(i);
if (file->level() >= level && file->attrHidden())
{
qDebug()<<__LINE__<<__func__;
if (file->isDirectory() && file->level() == level) continue;
beginRemoveRows(createIndex(idx, 0, m_oRoots.at(idx)), 0, 1);
parent = qobject_cast<DataDirectory *>(file->parent());

View File

@ -544,7 +544,16 @@ bool LogicBurnData::checkSize()
cdrom = static_cast<DataCDROM *>(m_oBurners.at(m_iIndex));
storage.setPath(cdrom->settingTempPath());
if (dir->size() > storage.bytesAvailable()) return false;
// if (cdrom->isCDROM() && dir->nSize() > cdrom->mediumFreeSize()) return false;
//bug120965,155809,解决由于要刻录的文件容量大于光盘剩余容量造成的刻录错误,
if (cdrom->isCDROM() )
{
qDebug()<<__LINE__<<__func__<<dir->nSize();
qDebug()<<__LINE__<<__func__<<cdrom->mediumFreeSize();
if (dir->nSize() > cdrom->mediumFreeSize())
return false;
}
return true;
}
@ -598,10 +607,14 @@ int LogicBurnData::filter(QModelIndex idx)
ret = 0;
node = nullptr;
if (!idx.isValid())
if (!idx.isValid()){
node = (DataDirectory *)(m_oRoots.at(m_iIndex));
else
qDebug()<<"LogicBurnData "<<__func__<<__LINE__<<node;
}
else{
node = static_cast<DataDirectory *>(idx.internalPointer());
qDebug()<<"LogicBurnData "<<__func__<<__LINE__<<node;
}
if (!node) return ret;
FILTERRULES->init(node);
return ret;
@ -614,14 +627,28 @@ int LogicBurnData::doFilterHidden(QModelIndex idx)
ret = 0;
node = nullptr;
if (!idx.isValid())
if (!idx.isValid()){
qDebug()<<__LINE__<<__func__<<"1";
node = (DataDirectory *)(m_oRoots.at(m_iIndex));
else
}
else{
qDebug()<<__LINE__<<__func__<<"2";
node = static_cast<DataDirectory *>(idx.internalPointer());
if (!node) return ret;
}
if (!node){
qDebug()<<__LINE__<<__func__<<"3";
return ret;
}
node->execHidden();
if (idx.isValid()) rootIndex(idx);
else rootIndex(createIndex(m_iIndex, 0, node));
if (idx.isValid()){
qDebug()<<__LINE__<<__func__<<"4";
rootIndex(idx);
}
else {
qDebug()<<__LINE__<<__func__<<"5";
rootIndex(createIndex(m_iIndex, 0, node));
}
return ret;
}
@ -633,11 +660,14 @@ int LogicBurnData::doRecoveryHidden(QList<void *> data, QModelIndex idx)
if (data.size() == 0)
{
if (!idx.isValid())
if (!idx.isValid()){
parent = (DataDirectory *)(m_oRoots.at(m_iIndex));
else
}
else{
parent = static_cast<DataDirectory *>(idx.internalPointer());
}
parent->execHidden(false);
qDebug()<<"LogicBurnData"<<__func__<<__LINE__;
}
while (data.size())
@ -646,10 +676,12 @@ int LogicBurnData::doRecoveryHidden(QList<void *> data, QModelIndex idx)
file = static_cast<DataFile *>(data.takeFirst());
parent = qobject_cast<DataDirectory *>(file->parent());
root = qobject_cast<DataDirectory *>(parent->parent());
if (root)
if (root){
beginInsertRows(createIndex(root->of(parent), 0, parent), parent->counts(), 1);
else
}
else{
beginInsertRows(createIndex(m_iIndex, 0, m_oRoots.at(m_iIndex)), parent->counts(), 1);
}
parent->execHidden(false);
parent->append(file);
file->size(file->size(), true);
@ -752,10 +784,12 @@ int LogicBurnData::doRecoveryRepleace(QList<void *> data)
parent->append(file);
else
{
//delete file;
//file = nullptr;
file->disconnect();
delete file;
file = nullptr;
}
connect(parent, SIGNAL(repleace(bool)), file, SLOT(slotsDoRepleace(bool)));
if(file)
connect(parent, SIGNAL(repleace(bool)), file, SLOT(slotsDoRepleace(bool)));
endInsertRows();
#endif
}
@ -831,8 +865,6 @@ int LogicBurnData::addDatasToIndex(QStringList files, QModelIndex idx)
}
m_bCancel = false;
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
title(_("Add File(s)"));
setRange(0, parents.size() * needAdd(files));
@ -864,6 +896,7 @@ int LogicBurnData::addDatasToIndex(QStringList files, QModelIndex idx)
ret += addFile(f.absoluteFilePath(), parent);
if (m_bCancel) break;
}
qDebug()<<__func__<<__LINE__<<"LogicBurnData"<<str;
endInsertRows();
}
@ -898,11 +931,19 @@ int LogicBurnData::deleteDatasFromIndex(QModelIndexList idxes, QModelIndex p)
{
if (i == m_iIndex) continue; // current idx has saved.
root = (DataDirectory *)(m_oRoots.at(i));
if (parent->isRoot())
if (parent->isRoot()){
parent = (DataDirectory *)(m_oRoots.at(i));
else
}
else{
parent = (DataDirectory *)(root->findChildByDisplay(str));
if (parent) parents << parent;
}
if (parent){
parents << parent;
}
}
}
childNames.clear();
@ -929,7 +970,9 @@ int LogicBurnData::deleteDatasFromIndex(QModelIndexList idxes, QModelIndex p)
if (nullptr == child)
child = (DataFile *)(parent->findChildByDisplay(str, true));
}
beginRemoveRows(p, parent->of(child), size);
foreach (str, childNames)
{
QCoreApplication::processEvents();
@ -1072,7 +1115,6 @@ void LogicBurnData::deleteRoot(int idx)
endRemoveRows();
disconnect(root, SIGNAL(updateSize(ulong)), this, SLOT(slotsUpdateSize(ulong)));
delete root;
root = nullptr;
m_oRoots.takeAt(idx);
}
@ -1091,15 +1133,20 @@ void LogicBurnData::recovery(QList<void *> hiddens, QList<void *> brokens, QList
if (nullptr == child) continue;
parent = static_cast<DataDirectory *>(child->parent());
root = static_cast<DataDirectory *>(parent->parent());
if (parent->isRoot())
if (parent->isRoot()){
idx = createIndex(m_oRoots.indexOf(parent), 0, parent);
else
}
else{
idx = createIndex(root->of(parent), 0, parent);
}
beginInsertRows(idx, parent->counts(), 1);
qDebug()<<"LogicBurnData"<<__func__<<__LINE__;
parent->execHidden(false);
parent->append(child);
endInsertRows();
connect(parent, SIGNAL(hidden(bool)), child, SLOT(slotsDoHidde(bool)));
qDebug()<<__func__<<__LINE__<<"LogicBurnData recovery";
}
while (brokens.size())
@ -1125,8 +1172,6 @@ void LogicBurnData::recovery(QList<void *> hiddens, QList<void *> brokens, QList
void LogicBurnData::slotsSetting()
{
BUSNESSSETTING;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
setting(m_oBurners.at(m_iIndex));
}
@ -1187,6 +1232,7 @@ void LogicBurnData::slotsCreateISO(void *d)
void LogicBurnData::slotsCreateISO()
{
ProcessCreateISO *createISO;
qDebug()<<__func__<<__LINE__<<m_iIndex;
createISO = new ProcessCreateISO(m_oRoots.at(m_iIndex),
m_oBurners.at(m_iIndex),
@ -1201,13 +1247,16 @@ void LogicBurnData::slotsCreateISO()
void LogicBurnData::slotsBurnData()
{
#if 1
ProcessBurnData *burnData;
burnData = new ProcessBurnData(m_oRoots.at(m_iIndex),
m_oBurners.at(m_iIndex),
this);
burnData->exec();
delete burnData;
DataCDROM *cdrom = (DataCDROM*)m_oBurners.at(m_iIndex);
ProcessBurnData burnData(m_oRoots.at(m_iIndex), cdrom);
cdrom->m_bStart = true;
burnData.exec();
for (int i = 0; i < m_oBurners.size(); ++i) {
if(m_oBurners.at(i) == cdrom) {
cdrom->m_bStart = false;
break;
}
}
#else
qDebug()<<"\n_________________________";
qDebug()<<"call ProcessBurnData,finish ISO9660 Format burner";
@ -1219,13 +1268,8 @@ void LogicBurnData::slotsBurnData()
void LogicBurnData::slotsBurnUDFData()
{
#if 1
ProcessBurnUDFData *burnData;
burnData = new ProcessBurnUDFData(m_oRoots.at(m_iIndex),
m_oBurners.at(m_iIndex),
this);
burnData->exec();
delete burnData;
ProcessBurnUDFData burnData(m_oRoots.at(m_iIndex) ,m_oBurners.at(m_iIndex));
burnData.exec();
#else
qDebug()<<"\n_________________________";
qDebug()<<"call ProcessBurnUDFData,finish UDF Format burner";
@ -1300,8 +1344,6 @@ int LogicBurnData::addDiskData(QStringList files, void *r)
PROGRESS;
title(_("Loading Disk Data."));
MODAL->cancelEnable(false);
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
setRange(0, needAdd(files));
b = true;
@ -1409,6 +1451,7 @@ int LogicBurnData::addDirectoy(QString path, void *d, bool disk)
if (!item->valid())
{
addValue(1, item->icon(), _("Cannot added %1 to %2").arg(item->display()).arg(parent->display()));
qDebug()<<__LINE__<<__func__<<"LogicBurnData"<<item->display()<<parent->display();
delete item;
return 0;
}
@ -1461,5 +1504,30 @@ int LogicBurnData::addFile(QString path, void *d, bool disk)
item->filter();
}
addValue(1, item->icon(), _("Added %1 to %2").arg(item->display()).arg(parent->display()));
qDebug()<<__LINE__<<__func__<<item->display()<<"LogicBurnData"<<parent->display();
return 1;
}
//bool LogicBurnData::isAbleBurnData()
//{
// DataDirectory *dir;
// DataCDROM *cdrom;
// if (0 == m_oRoots.size()) return false;
// if (m_iIndex < 0 || m_iIndex >= m_oRoots.size()) return false;
// dir = static_cast<DataDirectory *>(m_oRoots.at(m_iIndex));
// if (m_iIndex >= m_oBurners.size()) return false;
// cdrom = static_cast<DataCDROM *>(m_oBurners.at(m_iIndex));
// //qDebug() <<__func__ << __LINE__ << m_iIndex << m_oRoots;
// // DVD+/-RW的容量问题已解决
// if (cdrom->isCDROM())
// {
// // zyj:添加文件的容量 > 光盘剩余容量时,"刻录/追加刻录"按钮不置灰
// // 按钮点击后,出现"添加文件容量大于光盘剩余容量"提示弹框
// //qDebug() << __func__ << __LINE__ << dir->nSize();
// //qDebug() << __func__ << __LINE__ << cdrom->mediumFreeSize();
// if (dir->nSize() >= cdrom->mediumFreeSize())
// return false;
// }
// return true;
//}

View File

@ -86,6 +86,7 @@ private:
int needAdd(QString);
int addDirectoy(QString, void *, bool disk = false);
int addFile(QString, void *, bool disk = false);
// bool isAbleBurnData(); // 通过判断新加入文件的容量与光盘剩余容量大小,决定是否可以刻录
private:
int m_iIndex;
bool m_bCancel;

View File

@ -8,8 +8,7 @@
#include "src/view/modaldialog.h"
#include <QFileInfo>
#include <ukuistylehelper.h>
#include <QDebug>
LogicBurnImage *LogicBurnImage::m_oInstance = nullptr;
QMutex LogicBurnImage::m_oMutex;
@ -26,7 +25,7 @@ LogicBurnImage::LogicBurnImage(QObject *parent) :
m_oISOPath.clear();
m_oISOPaths.clear();
m_oBurners.clear();
connect(MAIN,SIGNAL(appendableMedium(void*)),this,SLOT(slotsNewBurner(void*)));
connect(MAIN, SIGNAL(emptyMedium(void*)), this, SLOT(slotsNewBurner(void*)));
connect(MAIN, SIGNAL(noMedium(void*)), this, SLOT(slotsDeleteBurner(void*)));
connect(MAIN,SIGNAL(burnImage()), this, SLOT(slotsBurnImage()));
@ -53,26 +52,51 @@ void LogicBurnImage::init()
QFileInfo f;
QVariantList vars;
if (m_oISOPath.isEmpty())
{
vars = CFG->gets("BurnImage", "Paths");
while (vars.size())
{
isoPath = vars.takeFirst().toString();
f.setFile(isoPath);
if (f.exists())
{
debug(_("Loaded iso path <%1>").arg(isoPath));
emit newISOPath(isoPath);
}
}
}
// if (m_oISOPath.isEmpty())
// {
// vars = CFG->gets("BurnImage", "Paths");
// while (vars.size())
// {
// isoPath = vars.takeFirst().toString();
// f.setFile(isoPath);
// if (f.exists())
// {
// debug(_("Loaded iso path <%1>").arg(isoPath));
// emit newISOPath(isoPath);
// }
// }
// }
if (0 == m_oBurners.size())
{
emit enableBurner(m_iBurner >= 0);
emit enableBusness(check());
emit burnerError(_("No valid burner,need burner which with empty meduim."));
}
emit enableBurner(m_iBurner >= 0);
emit enableBusness(check());
if(m_oBurners.size() > 0){
DataCDROM *cdrom;
// qDebug() << QString("[%1] [%2] : 光盘设置的 m_iBurner = %3").arg(__func__).arg(__LINE__).arg(m_iBurner);
cdrom = (DataCDROM *)(m_oBurners.at(m_iBurner));
// qDebug() <<__func__<<__LINE__<<cdrom;
if(cdrom->mediumType().contains("RW")&&DataMedium::MEDIUM_EMPTY != cdrom->mediumStatus()){
emit burnerError(_("This disc is a non-empty disc and needs to be erased!"));
emit enableBurner(m_iBurner >= 0);
emit enableBusness(check());
return;
}else if(DataMedium::MEDIUM_EMPTY != cdrom->mediumStatus()){
emit burnerError(_("No valid burner,need burner which with empty meduim."));
emit enableBurner(m_iBurner >= 0);
emit enableBusness(check());
return;
}
//if(DataMedium::MEDIUM_EMPTY == cdrom->mediumStatus()){
emit enableBurner(m_iBurner >= 0);
emit enableBusness(check());
//}
}
//emit enableBurner(m_iBurner >= 0);
//emit enableBusness(check());
}
QIcon LogicBurnImage::mediumIcon(int idx)
@ -135,6 +159,21 @@ bool LogicBurnImage::check()
emit burnerError(_("No valid burner,need burner which with empty meduim."));
return false;
}
if(m_oBurners.size() > 0){
DataCDROM *cdrom;
// qDebug() << QString("[%1] [%2] : 光盘设置的 m_iBurner = %3").arg(__func__).arg(__LINE__).arg(m_iBurner);
cdrom = (DataCDROM *)(m_oBurners.at(m_iBurner));
// qDebug() <<"LogicBurnImage"<<__func__<<__LINE__<<cdrom;
if(cdrom->mediumType().contains("RW")&&DataMedium::MEDIUM_EMPTY != cdrom->mediumStatus()){
emit burnerError(_("This disc is a non-empty disc and needs to be erased!"));
return false;
}else if(DataMedium::MEDIUM_EMPTY != cdrom->mediumStatus()){
emit burnerError(_("No valid burner,need burner which with empty meduim."));
return false;
}
}
cdrom = (DataCDROM *)(m_oBurners.at(m_iBurner));
f.setFile(m_oISOPath);
@ -163,6 +202,7 @@ void LogicBurnImage::slotsNewBurner(void *d)
emit newBurner(cdrom->mDisplay(), cdrom->display());
debug(_("New empty medium burner %1, medium %2")
.arg(cdrom->display()).arg(cdrom->mDisplay()));
qDebug()<<__LINE__<<__func__<<cdrom->mDisplay();
}
}
@ -176,27 +216,30 @@ void LogicBurnImage::slotsDeleteBurner(void *d)
debug(_("Remove burner."));
m_oBurners.takeAt(idx);
deleteBurner(idx);
if (m_iBurner == idx) --m_iBurner;
if (m_iBurner == idx) {
// qDebug()<<__LINE__<<__func__<<d;
// qDebug() << QString("[%1] [%2] : idx = %3 移除的光盘为m_iBurner = %4").arg(__func__).arg(__LINE__).arg(idx).arg(m_iBurner);
// --m_iBurner;
// qDebug()<<__LINE__<<__func__<<d;
// qDebug() << QString("[%1] [%2] : 移除光盘后的m_iBurner = %4").arg(__func__).arg(__LINE__).arg(m_iBurner);
}
}
}
void LogicBurnImage::slotsBurnImage()
{
DataCDROM *cdrom;
ProcessBurnImage *burnImage;
cdrom = (DataCDROM *)m_oBurners.at(m_iBurner);
debug(_("Begin to burn image, burn image<%1> to medium in <%2>")
.arg(m_oISOPath).arg(cdrom->display()));
burnImage = new ProcessBurnImage(m_oISOPath, cdrom, this);
burnImage->exec();
ProcessBurnImage burnImage(m_oISOPath, cdrom);
burnImage.exec();
}
void LogicBurnImage::slotsSetting()
{
BUSNESSSETTING;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
setting(m_oBurners.at(m_iBurner));
}

View File

@ -5,8 +5,9 @@
#include "src/view/modaldialog.h"
#include "src/process/processgetiso.h"
#include "src/process/processcopydisk.h"
#include <ukuistylehelper.h>
#include "src/view/execdialog.h"
#include "src/po/translation.h"
#include <QDebug>
LogicCopyImage *LogicCopyImage::m_oInstance = nullptr;
QMutex LogicCopyImage::m_oMutex;
@ -73,6 +74,7 @@ void LogicCopyImage::slotsDestination(void *d)
void LogicCopyImage::slotsSource(void *d)
{
m_oSources.clear();
m_oSources << d;
source(d);
}
@ -101,8 +103,6 @@ void LogicCopyImage::slotsSetting()
DataCDROM *src;
DataCDROM *des;
BUSNESSSETTING;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
src = static_cast<DataCDROM *>(m_oSources.at(m_iSource));
des = static_cast<DataCDROM *>(m_oDestinations.at(m_iDestination));
@ -135,10 +135,28 @@ void LogicCopyImage::slotsCopyImage()
void LogicCopyImage::slotsCopyData()
{
ProcessCopyDisk *copyDisk;
DataCDROM *src;
DataCDROM *des;
// if (m_iDestination == 0) return true;
// if (m_iSource < 0 || m_iDestination < 0) return false;
src = static_cast<DataCDROM *>(m_oSources.at(m_iSource));
des = static_cast<DataCDROM *>(m_oDestinations.at(m_iDestination));
if(src->mediumType().contains("CD")&&des->mediumType().contains("DVD")){
EXEC->information("",_("This disc is a CD, and copying to DVD is not supported"),true);
return;
}else if(src->mediumType().contains("DVD")&&des->mediumType().contains("CD")){
EXEC->information("",_("This disc is a DVD, and copying to CD is not supported"),true);
return;
}else{
copyDisk = new ProcessCopyDisk(m_oSources.at(m_iSource), m_oDestinations.at(m_iDestination), this);
copyDisk->exec();
delete copyDisk;
}
}
LogicCopyImage::~LogicCopyImage()

View File

@ -8,7 +8,7 @@
#include "src/data/datacdrom.h"
#include "src/view/modaldialog.h"
#include "src/view/filefilterrules.h"
#include "src/frame/signals.h"
#include <unistd.h>
#include <pwd.h>
#include <QDebug>
@ -16,7 +16,7 @@
#include <QFileInfo>
#include <QMutex>
#include <QThread>
#include <ukuistylehelper.h>
#include <QDebug>
LogicMain *LogicMain::m_oInstance = nullptr;
QMutex LogicMain::m_oMutex;
@ -46,7 +46,7 @@ LogicMain::LogicMain(QObject *parent) :
if (m_oCurrentIcon != m_oTheme->get("iconThemeName").toString())
{
m_oCurrentIcon = m_oTheme->get("iconThemeName").toString();
emit iconChange(QIcon::fromTheme("burner"));
emit g_user_signal->iconChange(QIcon::fromTheme("burner"));
}
});
}
@ -155,13 +155,18 @@ void LogicMain::createCDROM(QString blockName)
}
else
{
qDebug()<<__LINE__<<__func__<<"Creating new cdrom named"<<blockName;
cdrom = new DataCDROM(blockName, this);
m_oCDROMS.insert(blockName, cdrom);
QThread::sleep(1);
}
if (cdrom->isCDROM())
{
QThread::msleep(200);
qDebug()<<__LINE__<<__func__<<"new cdrom "<<blockName << "is real CDROM";
connect(cdrom, SIGNAL(empty()),this, SLOT(slotsEmptyMedium()));
connect(cdrom, SIGNAL(appendale()), this, SLOT(slotsAppendableMedium()));
connect(cdrom, SIGNAL(finished()), this, SLOT(slotsFinishedMedium()));
@ -169,9 +174,9 @@ void LogicMain::createCDROM(QString blockName)
if(!cdrom->m_bUpdateStart)
{
cdrom->m_bUpdateStart = true;
//qDebug()<<"createCDROM update() start";
qDebug()<<"createCDROM update() start " << blockName;
cdrom->update();
//qDebug()<<"createCDROM update() end";
qDebug()<<"createCDROM update() end " << blockName;
cdrom->m_bUpdateStart = false;
}
}
@ -205,11 +210,11 @@ void LogicMain::createCDROM(QString blockName)
}
if(cdrom->m_iUsing > 0 && cdrom->isCDROM() && cdrom->mediumStatus() >=0)
{
//qDebug() << "开始加载数据";
cdrom->sendMediumStatusToOtherView();
}
// if(cdrom->m_iUsing > 0 && cdrom->isCDROM() && cdrom->mediumStatus() >=0)
// {
// qDebug() << "开始加载数据";
// cdrom->sendMediumStatusToOtherView();
// }
}
@ -327,11 +332,14 @@ void LogicMain::changeCDROM(QString blockName)
{
DataCDROM *cdrom;
debug(_("Change CDROM, block name is %1").arg(blockName));
QThread::sleep(1);
qDebug()<<"Change CDROM, block name is "<<blockName;
QThread::msleep(200);
qDebug()<<"Change CDROM, block name is "<<blockName;
cdrom = static_cast<DataCDROM *>(m_oCDROMS.value(blockName));
if (nullptr == cdrom)
{
qDebug()<<"Change CDROM, block name is "<<blockName;
// createCDROM(blockName);
return;
}
@ -343,14 +351,14 @@ void LogicMain::changeCDROM(QString blockName)
{
//update没有开始
//qDebug() << "change update() 开始了";
qDebug() << "change update() 开始了 " << blockName;
cdrom->m_bUpdateStart = true;
if (!MODAL->isHidden() && !cdrom->isEjected()) MODAL->close();
debug(_("Change CDROM %1").arg(cdrom->display()));
noMedium(cdrom);
cdrom->update();
//qDebug() << "changeCDROM update() end";
qDebug() << "changeCDROM update() end" << blockName;
//qDebug()<< "";
cdrom->m_bUpdateStart = false;
@ -371,7 +379,7 @@ void LogicMain::changeCDROM(QString blockName)
*/
if(cdrom->m_iUsing > 0) //有光驱
{
//qDebug() << "changeDevice 执行update()后,有光驱";
qDebug() << "changeDevice 执行update()后,有光驱";
if(cdrom->doorIsOpen()) //光驱门开(光驱门开/插入光驱)
{
//移除信号;
@ -382,13 +390,13 @@ void LogicMain::changeCDROM(QString blockName)
if (cdrom->mediumStatus() < 0) //没光盘
{
debug(_("There is no medium in CDROM %1").arg(cdrom->display()));
//qDebug() << "changeDevice 执行update()后,光驱没有被拔,但没有光盘";
qDebug() << "changeDevice 执行update()后,光驱没有被拔,但没有光盘";
//移除信号
noMedium(cdrom);
}
else// 有光盘
{
//qDebug() << "changeDevice 执行update()后,光驱没有被拔,且有光盘,发送信号haveMedium";
qDebug() << "changeDevice 执行update()后,光驱没有被拔,且有光盘,发送信号haveMedium";
//cdrom->sendMediumStatusToOtherView();
emit g_user_signal->haveMedium(cdrom);
@ -401,20 +409,19 @@ void LogicMain::changeCDROM(QString blockName)
{
//???还需要移除信号吗???
noMedium(cdrom);
//qDebug() << "changeDevice 执行update()后,光驱被拔=NULL";
qDebug() << "changeDevice 执行update()后,光驱被拔=NULL";
}
if(cdrom->m_iUsing > 0 && cdrom->isCDROM() && cdrom->mediumStatus() >=0)
{
//qDebug()<< "changeCDROM 加载数据";
cdrom->sendMediumStatusToOtherView();
}
//if(cdrom->m_iUsing > 0 && cdrom->isCDROM() && cdrom->mediumStatus() >=0)
//{
// //qDebug()<< "changeCDROM 加载数据";
// cdrom->sendMediumStatusToOtherView();
//}
}
else
{
//qDebug() << "change update() 已经开始了,不操作了";
qDebug() << "change update() 已经开始了,不操作了";
return ;
}
}
@ -432,7 +439,10 @@ void LogicMain::removeCDROM(QString block)
if (!MODAL->isHidden()) MODAL->accept();
if (nullptr == cdrom) return;
debug(_("Remove CDROM %1").arg(cdrom->display()));
qDebug()<<__LINE__<<__func__<<"Remove CDROM %1"<<cdrom->display();
m_oCDROMS.remove(block);
qDebug()<<__LINE__<<__func__<<"Remove CDROM %1"<<cdrom->display();
emit g_user_signal->removeDisc(block);
//cdrom->release();
noMedium(cdrom); // 首先移除数据
deleteCDROM(cdrom); // 移除界面展示中遗留的光驱信息。
@ -458,6 +468,7 @@ void LogicMain::slotsAppendableMedium()
//cdrom->use();
debug(_("Get appendable medium in CDROM %1").arg(cdrom->display()));
debug(_("BurnerName : %1 DiskName : %2").arg(cdrom->display()).arg(cdrom->mDisplay()));
emit appendableMedium(sender());
//cdrom->release();
}
@ -536,16 +547,12 @@ void LogicMain::slotsDoBusness()
void LogicMain::slotsDataSetting()
{
DATASETTING;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
}
void LogicMain::slotsDiskCheck()
{
DISKCHECK;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
}

View File

@ -10,6 +10,7 @@
#include <QDBusMessage>
#include <QDBusConnection>
#include <QFileInfo>
#include <QDebug>
MenuFactory *MenuFactory::m_oInstance = nullptr;
QMutex MenuFactory::m_oMutex;
@ -97,6 +98,7 @@ MenuFactory::MenuFactory(QObject *parent) :
connect(m_oActionVersion, SIGNAL(triggered(bool)), this, SIGNAL(version(bool)));
connect(m_oActionAbout, SIGNAL(triggered(bool)), this, SIGNAL(about(bool)));
connect(m_oActionAbout,SIGNAL(triggered(bool)),this,SLOT(showabout()));
//m_oActionAbout->setShortcut(QKeySequence(Qt::Key_F10));
//m_oActionAbout->setShortcutContext(Qt::ApplicationShortcut);
@ -350,6 +352,20 @@ void MenuFactory::newEarse(void *c)
m_oErases << cdrom;
}
}
else if(cdrom->mediumIsErasable() && idx > -1){
if(cdrom->mediumStatus() != DataMedium::MEDIUM_EMPTY)
{
m_oEraseActions.clear();
m_oSubErase->clear();
m_oErases.clear();
m_oEraseActions << m_oSubErase->addAction(cdrom->mediumIcon(),
cdrom->mDisplay(),
cdrom, SLOT(earse()));
m_oErases << cdrom;
}
}
//逻辑对吗?还得再看
if (m_oEraseActions.size())
m_oActionEarse->setMenu(m_oSubErase);
@ -415,7 +431,9 @@ void MenuFactory::takeCDROM(void * cdrom)
}
#endif
}
void MenuFactory::showabout(){
ABOUT->show();
}
MenuFactory::~MenuFactory()
{
QMenu *menu;

View File

@ -28,6 +28,7 @@ private slots:
void newEarse(void *);
void removeEarse(void *);
void takeCDROM(void *);
void showabout();
private:
static MenuFactory *m_oInstance;
static QMutex m_oMutex;

View File

@ -9,7 +9,7 @@
#include <fstream>
#include <QCoreApplication>
#include <QDebug>
#define CDROM "/proc/sys/dev/cdrom/info"
MonitorCDROM *MonitorCDROM::m_oInstance = nullptr;
@ -72,6 +72,8 @@ void MonitorCDROM::run()
while (m_bAppRunning)
{
QCoreApplication::processEvents();
qDebug()<<__LINE__<<__func__<<"MonitorCDROM";
//QThread::msleep(200);
::memset(buffer, 0, 256);
if (::read(m_iPreception, buffer, 256) < 0) continue;
rcvMsg = QString::fromUtf8(buffer);
@ -84,7 +86,9 @@ void MonitorCDROM::run()
if (isCDROM(splits.last()))
{
info(_("Calling MAIN to add new inserted CDROM, block name is /dev/%1").arg(splits.last()));
qDebug()<<__LINE__<<__func__<<"Calling MAIN to add new inserted CDROM, block name is /dev/%1"<<splits.last();
emit addCDROM(QString("/dev/%1").arg(splits.last()));
qDebug()<<__LINE__<<__func__<<"Calling MAIN to add new inserted CDROM, block name is /dev/%1"<<splits.last();
}
}
else if (rcvMsg.startsWith("change@/devices")) // change
@ -93,7 +97,9 @@ void MonitorCDROM::run()
if (isCDROM(splits.last()))
{
debug(_("Calling MAIN to change old CDROM, block name is /dev/%1").arg(splits.last()));
qDebug()<<__LINE__<<__func__<<"Calling MAIN to change old CDROM, block name is /dev/%1"<<splits.last();
emit changeCDROM(QString("/dev/%1").arg(splits.last()));
qDebug()<<__LINE__<<__func__<<"Calling MAIN to change old CDROM, block name is /dev/%1"<<splits.last();
}
}
else if (rcvMsg.startsWith("remove@/devices")) // remove
@ -102,7 +108,9 @@ void MonitorCDROM::run()
if (isCDROM(splits.last()))
{
debug(_("Calling MAIN to remove old CDROM, block name is /dev/%1").arg(splits.last()));
qDebug()<<__LINE__<<__func__<<"Calling MAIN to remove old CDROM, block name is /dev/%1"<<splits.last();
emit removeCDROM(QString("/dev/%1").arg(splits.last()));
qDebug()<<__LINE__<<__func__<<"Calling MAIN to remove old CDROM, block name is /dev/%1"<<splits.last();
}
}
else
@ -150,6 +158,7 @@ void MonitorCDROM::update()
QString line;
QStringList splits;
//QThread::msleep(200);
in.open(CDROM);
if (!in.is_open()) // open failed.
{

File diff suppressed because it is too large Load Diff

BIN
src/po/bo_CN.mo Normal file

Binary file not shown.

2280
src/po/bo_CN.po Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

BIN
src/po/zh_CN.mo Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,7 @@ void ProcessBasic::exec()
bool result;
int step;
m_lastErrorMsg = "";
m_oKeep = true;
step = Prepare;
result = true;
@ -108,7 +109,12 @@ void ProcessBasic::exec()
strDes = m_oArguments.at(1);
}
info(_("User") + "=" + strUsr + " , " + _("Destination") + "=" + strDes + " , " + _("Burn result") + "=" + m_oProcessName +" " + _("KylinBurner") + _(" Failed"));
fail(m_oProcessName);
if (m_lastErrorMsg.isEmpty()) {
fail(m_oProcessName);
} else {
fail(m_lastErrorMsg + m_oProcessName);
m_lastErrorMsg = "";
}
MODAL->hide();
eject();
return;
@ -164,6 +170,10 @@ void ProcessBasic::slotsCancel()
{
if (m_bCancel) return;
m_bCancel = true;
if(m_oProcessName==_("Media Info")){
m_bCancel=false;
return;
}
if (m_oProcess->state() != QProcess::NotRunning)
{
debug(_("Stop process when user canceled."));
@ -192,18 +202,4 @@ void ProcessBasic::connection()
}
ProcessBasic::~ProcessBasic()
{
//方案两个1、在finished 的槽函数里delete
//2、kill掉什么时候kill掉呢。
/*如果在这里delete的话运行的QPrcess还没有运行完成便delete了后续有问题。
if(m_oProcess!=nullptr)
{
qDebug() << "~ProcessBasic 析构m_oProcess";
delete m_oProcess;
m_oProcess = nullptr;
}
*/
if(m_oTimer) delete m_oTimer;
m_oTimer = nullptr;
}
{}

View File

@ -58,8 +58,10 @@ protected:
QProcess *m_oProcess;
QTimer *m_oTimer;
QString m_oProcessName;
QString m_oDeviceBlock;
QStringList m_oArguments;
QIcon m_oIcon;
QString m_lastErrorMsg;
};
#endif // PROCESSBASIC_H

View File

@ -6,6 +6,7 @@
#include "src/view/modaldialog.h"
#include "src/view/execdialog.h"
#include "src/frame/signals.h"
#include "src/model/diroptutils.h"
#include <QFileInfo>
#include <QDir>
@ -13,21 +14,48 @@
#include <QStandardPaths>
#include <fstream>
#include <QDebug>
#include <ukuistylehelper.h>
ProcessBurnData::ProcessBurnData(void *root, void *cdrom, QObject *parent) :
ProcessBasic(parent),
m_oFlag(false),
m_bVerficationData(false),
m_oProgressBarTimer_DVD(new QTimer(this))
{
DataCDROM *c;
m_bCreateISO = false;
m_oCDROM = cdrom;
cloneCDROM = ((DataCDROM *)cdrom)->clone();
m_oRoot = root;
c = (DataCDROM *)cdrom;
m_root = (DataDirectory *)m_oRoot;
m_odestination=m_root->destination();
m_ototal=m_root->total();
m_oSize=m_root->size();
m_oNewSize = m_root->nSize()/1024.0/1024.0; // 单位MB
m_oDeviceBlock = cloneCDROM->device();
//m_isSpecialMachine=kdk_system_is_zyj();
auditburner=new QGSettings("org.ukui.kylinburner");
auditlogpath="/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine=auditburner->get("burneraudit-isrunning").toBool();
m_bVerficationData = cloneCDROM->settingVerficationData();
qDebug() << __LINE__ << __func__ << "Verfication Data :" << m_bVerficationData;
qDebug() << __LINE__ << __func__ << "ClossSession :" <<cloneCDROM->settingCloseSession() ;
if (m_bVerficationData) {
//拼接路径
m_oTempPath = cloneCDROM->settingTempPath();
if (m_oTempPath.endsWith("/")) {
m_oTempPath = m_oTempPath + cloneCDROM->settingVolumnID();
} else{
m_oTempPath = m_oTempPath + '/' + cloneCDROM->settingVolumnID();
}
}
m_fSpeed = 0;
connect(m_oProgressBarTimer_DVD, SIGNAL(timeout()), this, SLOT(slotsProcessBarDVD()));
connect(g_user_signal, &GlobalUserSignal::removeDisc, this, &ProcessBurnData::slotsRemoveDisc);
if (c->mediumStatus() == DataMedium::MEDIUM_EMPTY)
if (cloneCDROM->mediumStatus() == DataMedium::MEDIUM_EMPTY)
{
LOGGER->registerName(this, _("PROCESS_BD"));
title(_("Burning Data"));
@ -41,11 +69,10 @@ ProcessBurnData::ProcessBurnData(void *root, void *cdrom, QObject *parent) :
m_oProcessName = _("Append Burn");
m_bAppendBurn = true;
}
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
setRange(0, 100);
setValue(0);
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,true);
}
bool ProcessBurnData::prepare()
@ -69,10 +96,12 @@ bool ProcessBurnData::prepare()
}
if (sysid.isEmpty()) sysid = _("KylinOS");
if (cdrom->mediumType().startsWith("CD"))
if (cloneCDROM->mediumType().startsWith("CD"))
f.setFile("/bin/cdrecord");
else if (cdrom->mediumType().contains("DVD+R DL"))
else if (cloneCDROM->mediumType().contains("DVD+R DL"))
f.setFile("/bin/xorriso");
// else if(cloneCDROM->mediumType().contains("DVD")&&cloneCDROM->settingCloseSession()==true)
// f.setFile("/bin/xorriso");
else
f.setFile("/bin/growisofs");
if (!f.exists() || !f.isExecutable())
@ -83,12 +112,14 @@ bool ProcessBurnData::prepare()
".%2 exiting...")
.arg(f.absoluteFilePath())
.arg("KylinBurner"));
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
return false;
}
connect(this, SIGNAL(cancel(bool)), MODAL, SLOT(cancelEnable(bool)));
m_bCreateISO = cdrom->settingCreateISO();
m_bCreateISO = cloneCDROM->settingCreateISO();
if (m_bCreateISO)
{
qDebug()<<__func__<<__LINE__<<m_bCreateISO;
f.setFile("/bin/mkisofs");
if (!f.exists() || !f.isExecutable())
{
@ -97,38 +128,40 @@ bool ProcessBurnData::prepare()
"the right permissions.%2 exiting...")
.arg(f.absoluteFilePath())
.arg("KylinBurner"));
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
return false;
}
m_oISOOutput = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
m_oISOOutput.append("/").append(cdrom->settingVolumnID()).append(".iso");
m_oISOOutput.append("/").append(cloneCDROM->settingVolumnID()).append(".iso");
f.setFile(m_oISOOutput);
if (f.exists())
{
if (!EXEC->question(_("Create ISO") + " - " + _("Already Exists"),
_("There is already have the iso file named %1,"
"replace it or not?").arg(f.fileName())))
_("There is already have the iso file named %1,"
"replace it or not?").arg(f.fileName()))) {
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
return false;
}
if (f.isFile()) QFile::remove(f.absoluteFilePath());
else { QDir dir(f.absoluteFilePath()); dir.removeRecursively(); }
}
}
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
m_oCreateISO = QString("mkisofs -o %1 -r -R -J -joliet-long -no-pad -no-iso-translate ").arg(m_oISOOutput);
m_oMkisofs = QString("genisoimage -r -R -J -joliet-long -no-pad -no-iso-translate ");
m_oMkisofs.append(QString("-A \"%1\" ").arg(_("KylinBurner")));
m_oCreateISO.append(QString("-A \"%1\" ").arg(_("KylinBurner")));
m_oArguments << "-c";
if (cdrom->mediumType().startsWith("CD"))
if (cloneCDROM->mediumType().startsWith("CD"))
{
m_oCdrecord = QString("cdrecord -v driveropts=burnfree -nopad ");
setValue(++m_iProgress, m_oIcon, _("Prepare to burn data to CD."));
}
else if (cdrom->mediumType().contains("DVD+R DL"))
else if (cloneCDROM->mediumType().contains("DVD+R DL"))
{
//m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close off -commit -eject").arg(cdrom->device()).arg(root->destination()).arg("/").arg(cdrom->settingVolumnID());
//m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close off -commit -eject").arg(cloneCDROM->device()).arg(root->destination()).arg("/").arg(cloneCDROM->settingVolumnID());
setValue(++m_iProgress, m_oIcon, _("Prepare to burn data to DVD+R."));
}
else
@ -150,30 +183,30 @@ bool ProcessBurnData::config()
DataCDROM *cdrom;
cdrom = (DataCDROM *)m_oCDROM;
if (cdrom->mediumStatus() == DataMedium::MEDIUM_EMPTY)
qDebug()<<__LINE__<<__func__<<cloneCDROM->settingCloseSession();
if (cloneCDROM->mediumStatus() == DataMedium::MEDIUM_EMPTY)
{
m_oMkisofs.append(QString("-p \"%1\" ").arg(cdrom->settingPreparer()));
m_oCreateISO.append(QString("-p \"%1\" ").arg(cdrom->settingPreparer()));
m_oGrowisofs.append(QString("-p \"%1\" ").arg(cdrom->settingPreparer()));
m_oMkisofs.append(QString("-P \"%1\" ").arg(cdrom->settingPublisher()));
m_oCreateISO.append(QString("-P \"%1\" ").arg(cdrom->settingPublisher()));
m_oGrowisofs.append(QString("-P \"%1\" ").arg(cdrom->settingPublisher()));
m_oMkisofs.append(QString("-copyright \"%1\" ").arg(cdrom->settingCopyright()));
m_oCreateISO.append(QString("-copyright \"%1\" ").arg(cdrom->settingCopyright()));
m_oGrowisofs.append(QString("-copyright \"%1\" ").arg(cdrom->settingCopyright()));
m_oMkisofs.append(QString("-p \"%1\" ").arg(cloneCDROM->settingPreparer()));
m_oCreateISO.append(QString("-p \"%1\" ").arg(cloneCDROM->settingPreparer()));
m_oGrowisofs.append(QString("-p \"%1\" ").arg(cloneCDROM->settingPreparer()));
m_oMkisofs.append(QString("-P \"%1\" ").arg(cloneCDROM->settingPublisher()));
m_oCreateISO.append(QString("-P \"%1\" ").arg(cloneCDROM->settingPublisher()));
m_oGrowisofs.append(QString("-P \"%1\" ").arg(cloneCDROM->settingPublisher()));
m_oMkisofs.append(QString("-copyright \"%1\" ").arg(cloneCDROM->settingCopyright()));
m_oCreateISO.append(QString("-copyright \"%1\" ").arg(cloneCDROM->settingCopyright()));
m_oGrowisofs.append(QString("-copyright \"%1\" ").arg(cloneCDROM->settingCopyright()));
}
m_oMkisofs.append(QString("-V \"%1\" ").arg(cdrom->settingVolumnID()));
m_oCreateISO.append(QString("-V \"%1\" ").arg(cdrom->settingVolumnID()));
m_oGrowisofs.append(QString("-V \"%1\" ").arg(cdrom->settingVolumnID()));
if (cdrom->settingSpeed())
m_oMkisofs.append(QString("-V \"%1\" ").arg(cloneCDROM->settingVolumnID()));
m_oCreateISO.append(QString("-V \"%1\" ").arg(cloneCDROM->settingVolumnID()));
m_oGrowisofs.append(QString("-V \"%1\" ").arg(cloneCDROM->settingVolumnID()));
if (cloneCDROM->settingSpeed())
{
m_oMkisofs.append(QString("-speed=%1 ").arg(cdrom->settingSpeed()));
m_oGrowisofs.append(QString("-speed=%1 ").arg(cdrom->settingSpeed()));
m_oCdrecord.append(QString("speed=%1 ").arg(cdrom->settingSpeed()));
m_oMkisofs.append(QString("-speed=%1 ").arg(cloneCDROM->settingSpeed()));
m_oGrowisofs.append(QString("-speed=%1 ").arg(cloneCDROM->settingSpeed()));
m_oCdrecord.append(QString("speed=%1 ").arg(cloneCDROM->settingSpeed()));
}
m_oCdrecord.append("-eject ");
if (!cdrom->settingCloseSession())
if (!cloneCDROM->settingCloseSession())
{
m_oCdrecord.append("-multi ");
}
@ -187,12 +220,13 @@ bool ProcessBurnData::config()
bool ProcessBurnData::working()
{
DataCDROM *cdrom;
DataDirectory *root;
//DataDirectory *root;
cdrom = (DataCDROM *)m_oCDROM;
root = (DataDirectory *)m_oRoot;
//root = (DataDirectory *)m_oRoot;
if (root->size() > 2UL * 1024UL * 1024UL * 1024UL)
//if (root->size() > 2UL * 1024UL * 1024UL * 1024UL)
if (m_oSize > 2UL * 1024UL * 1024UL * 1024UL)
{
debug(_("%1 data size more than 2 GB, need allow-limited-size "
"extension").arg(_("CreateISO")));
@ -200,7 +234,8 @@ bool ProcessBurnData::working()
m_oCreateISO.append("-allow-limited-size ");
m_oGrowisofs.append("-allow-limited-size ");
}
if (root->size() > 4UL * 1024UL * 1024UL * 1024UL)
//if (root->size() > 4UL * 1024UL * 1024UL * 1024UL)
if (m_oSize > 4UL * 1024UL * 1024UL * 1024UL)
{
m_oMkisofs.append("-udf ");
m_oCreateISO.append("-udf ");
@ -208,31 +243,66 @@ bool ProcessBurnData::working()
}
m_iCopied = 0;
connect(root, SIGNAL(copied(QString,QString)), this, SLOT(slotsCopy(QString,QString)));
root->copy();
connect(m_root, SIGNAL(copied(QString,QString)), this, SLOT(slotsCopy(QString,QString)));
//connect(root, SIGNAL(copied(QString,QString)), this, SLOT(slotsCopy(QString,QString)));
m_root->copy();
//m_ocopy;
if (m_bVerficationData) {
DirOptUtils *diropt = new DirOptUtils;
diropt->getFileListUnderDir1(m_oTempPath);
diropt->testPrintMap();
diropt->generateCheckFile();
delete diropt;
}
m_oTimer->start(500);
if (m_bCancel) return false;
if (m_bCancel) {
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
return false;
}
if (m_bCreateISO)
{
m_oCreateISO.append(root->destination());
//m_oCreateISO.append(root->destination());
m_oCreateISO.append(m_odestination);
m_oArguments << m_oCreateISO;
m_oProcess->setArguments(m_oArguments);
for (int i = 0; i < m_oArguments.size(); ++i)
{
qDebug() << QString("Arg.%1 - %2").arg(i + 1).arg(m_oArguments.at(i));
}
qDebug() << "";
//cdrom->m_bStart(true);
cloneCDROM->updateCDROMBurnStart(true);
m_oProcess->start();
while (m_oProcess->state() != QProcess::NotRunning)
while (m_oProcess->state() != QProcess::NotRunning){
//qDebug()<<__func__<<__LINE__;
QCoreApplication::processEvents();
}
if(!m_oKeep) return false;
m_bCreateISO = false;
}
if (m_bCancel) return false;
if (m_bCancel) {
qDebug()<<__func__<<__LINE__<<m_bCancel;
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
return false;
}
m_oArguments.clear();
m_oArguments << "-c";
if (cdrom->mediumType().startsWith("CD"))
if (cloneCDROM->mediumType().startsWith("CD"))
{
if (m_bAppendBurn)
{
cdrom->umount();
m_oMSINFO = QString("cdrecord -msinfo dev=%1").arg(cdrom->device());
cloneCDROM->umount();
m_oMSINFO = QString("cdrecord -msinfo dev=%1").arg(cloneCDROM->device());
m_oArguments << m_oMSINFO;
m_oProcess->setArguments(m_oArguments);
for (int i = 0; i < m_oArguments.size(); ++i)
{
qDebug() << QString("Arg.%1 - %2").arg(i + 1).arg(m_oArguments.at(i));
}
qDebug() << "";
m_oProcess->start();
while (m_oProcess->state() != QProcess::NotRunning)
QCoreApplication::processEvents();
@ -241,31 +311,43 @@ bool ProcessBurnData::working()
m_oArguments << "-c";
m_oMkisofs.append(QString("-C \"%1\"").arg(m_oMSINFO));
m_oMkisofs.append(" ");
m_oMkisofs.append(QString("-M \"%1\"").arg(cdrom->device()));
m_oMkisofs.append(QString("-M \"%1\"").arg(cloneCDROM->device()));
m_oMkisofs.append(" ");
}
m_oMkisofs.append(root->destination());
//m_oMkisofs.append(root->destination());
qDebug()<<__func__<<__LINE__<<m_odestination;
m_oMkisofs.append(m_odestination);
m_oMkisofs.append(" ");
m_oCdrecord.append(QString("dev=%1 -").arg(cdrom->device()));
m_oCdrecord.append(QString("dev=%1 -").arg(cloneCDROM->device()));
m_oArguments << QString("%1 | %2").arg(m_oMkisofs).arg(m_oCdrecord);
}
else if (cdrom->mediumType().contains("DVD+R DL"))
else if (cloneCDROM->mediumType().contains("DVD+R DL"))
{
if (!cdrom->settingCloseSession())
m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close off -commit -eject").arg(cdrom->device()).arg(root->destination()).arg("/").arg(cdrom->settingVolumnID());
if (!cloneCDROM->settingCloseSession())
// m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close off -commit -eject").arg(cloneCDROM->device()).arg(root->destination()).arg("/").arg(cloneCDROM->settingVolumnID());
m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close off -commit -eject").arg(cloneCDROM->device()).arg(m_odestination).arg("/").arg(cloneCDROM->settingVolumnID());
else
m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close on -commit -eject").arg(cdrom->device()).arg(root->destination()).arg("/").arg(cdrom->settingVolumnID());
// m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close on -commit -eject").arg(cloneCDROM->device()).arg(root->destination()).arg("/").arg(cloneCDROM->settingVolumnID());
m_oXorriso = QString("xorriso -dev %1 -map \"%2\" \"%3\" -volid \"%4\" -close on -commit -eject").arg(cloneCDROM->device()).arg(m_odestination).arg("/").arg(cloneCDROM->settingVolumnID());
//qDebug() << "m_oXorriso = " << m_oXorriso;
info(_("the command for xorriso is: %1").arg(m_oXorriso));
cdrom->umount(); //xorriso刻录需要先卸载光盘
cloneCDROM->umount(); //xorriso刻录需要先卸载光盘
m_oArguments << m_oXorriso;
}
else
{
if (m_bAppendBurn)
m_oGrowisofs.append(QString("-M %1 \"%2\"").arg(cdrom->device()).arg(root->destination()));
else
m_oGrowisofs.append(QString("-Z %1 \"%2\"").arg(cdrom->device()).arg(root->destination()));
if (m_bAppendBurn){
qDebug()<<"root->destination()"<<m_odestination;
// m_oGrowisofs.append(QString("-M %1 \"%2\"").arg(cloneCDROM->device()).arg(root->destination()));
m_oGrowisofs.append(QString("-M %1 \"%2\"").arg(cloneCDROM->device()).arg(m_odestination));
qDebug()<<"root->destination()"<<m_odestination;
}else{
// m_oGrowisofs.append(QString("-Z %1 \"%2\"").arg(cloneCDROM->device()).arg(root->destination()));
qDebug()<<__func__<<__LINE__<<cloneCDROM->device()<<m_odestination;
m_oGrowisofs.append(QString("-Z %1 \"%2\"").arg(cloneCDROM->device()).arg(m_odestination));
}
m_oArguments << m_oGrowisofs;
}
m_oProcess->setArguments(m_oArguments);
@ -274,7 +356,13 @@ bool ProcessBurnData::working()
{
debug(_("Arg.%1 - %2").arg(i + 1).arg(m_oArguments.at(i)));
}
cdrom->m_bStart = true;
for (int i = 0; i < m_oArguments.size(); ++i)
{
qDebug() << QString("Arg.%1 - %2").arg(i + 1).arg(m_oArguments.at(i));
}
qDebug() << "";
m_oProcess->start();
while (m_oProcess->state() != QProcess::NotRunning)
QCoreApplication::processEvents();
@ -337,6 +425,7 @@ void ProcessBurnData::slotsOutput()
//qDebug() << "slotsOut si = " <<si << " s.at(2)" << s.at(2);
t = s.at(4).toDouble();
if (t==0) t = m_oNewSize;
//qDebug() << "slotsOut t = " <<t<< " s.at(4)" << s.at(4);
if (s.size() > 5)
{
@ -365,10 +454,10 @@ void ProcessBurnData::slotsError()
//qDebug() << "slotsError = " << output;
if (output.contains("OPC failed."))
m_oKeep = false;
if (output.contains("Input/output error"))
m_oKeep = false;
if (output.contains(":-("))
if (output.contains("Input/output error")) {
m_oKeep = false;
m_lastErrorMsg = QString(_("Input/output error. Disc may be damaged, please clean or replace a disc and try again."));
}
if (output.contains("FATAL:"))
m_oKeep = false;
if (output.contains("error"))
@ -377,6 +466,16 @@ void ProcessBurnData::slotsError()
m_oKeep = false;
if (output.contains(":-["))
m_oKeep = false;
if (output.contains(":-(")) {
info(QString("[%1] [%2] 发现错误: [%3]").arg(__func__).arg(__LINE__).arg(output));
if (m_oFlag && output.contains(":-( unable to reload tray")){
m_oKeep = true;
info(QString("[%1] [%2] 出现 :-( unable to reload tray, 不认为是错误输出 设置m_oKeep = [%3]").arg(__func__).arg(__LINE__).arg(m_oKeep));
} else {
m_oKeep = false;
}
}
if (output.contains("xorriso : aborting"))
m_oKeep = false;
if(output.contains("seems to be mounted!")) // CD盘光盘不能卸载
@ -385,8 +484,19 @@ void ProcessBurnData::slotsError()
m_oKeep = false;
if(output.contains("Cannot open busy device")) //xorriso卸载失败
m_oKeep = false;
if(output.contains("No such device")) {
/** CD盘刻录镜像时光驱拔出后报错进程需等待10分钟结束不会立即结束用户感知刻录镜像
*
**/
if (m_oProcess->state() != QProcess::NotRunning)
{
m_oKeep = false;
debug(_("An error occurs when the CD is removed during data burning. The image burning process is terminated."));
m_oProcess->kill();
}
}
if(cdrom->mediumType().contains("DVD+R DL"))
if(cloneCDROM->mediumType().contains("DVD+R DL"))
{
basic = 90 - m_iProgress;
//提取命令返回值的刻录进度值
@ -471,8 +581,13 @@ void ProcessBurnData::slotsError()
{
setValue(99, m_oIcon, _("closing session"));
}
if(output.contains("reloading tray") /*&& cdrom->getVendor().contains("ATAPI")*/){
m_oFlag = true;
info(QString("[%1] [%2] run return value: reloading tray 设置m_oFlag = [%3]").arg(__func__).arg(__LINE__).arg(m_oFlag));
}
}
error(output);
}
@ -482,42 +597,79 @@ void ProcessBurnData::slotsFinished(int code, QProcess::ExitStatus status)
cdrom = (DataCDROM *)m_oCDROM;
info(_("Exit code is %1, status : %2").arg(code).arg(status));
if (m_bAppendBurn && cdrom->mediumType().contains("CD")) return;
info(_("Exit code is %1, status : %2, m_oKeep : %3").arg(code).arg(status).arg(m_oKeep));
if (m_bAppendBurn && cloneCDROM->mediumType().contains("CD")) return;
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
if (!m_bCreateISO) setValue(99, m_oIcon, _("Burn Data"));
if (QProcess::NormalExit == status && 0 == code)
{
if (!m_bCreateISO)
qDebug()<<__func__<<__LINE__<<m_bCreateISO;
if(m_bCreateISO)
{
setValue(100, m_oIcon, _("Burn Data"));
info( QString("file:[%1] line:[%2] : slotsFinished() Medium burn data success.").arg(__FILE__).arg(__LINE__) );
cdrom->eject(false);
//点击“创建镜像”
info( QString("file:[%1] line:[%2] : slotsFinished() create ISO success.").arg(__FILE__).arg(__LINE__) );
return;
} else {
info(QString("file:[%1] line:[%2]: slotsFinished() burner data success.").arg(__FILE__).arg(__LINE__) );
}
else
info( QString("slotsFinished() line[%1] : create ISO success.").arg(__LINE__) );
}
else
{
m_oKeep = false;
if(m_bCreateISO)
{
//点击“创建镜像”
info( QString("file:[%1] line:[%2] : slotsFinished() create ISO failed.").arg(__FILE__).arg(__LINE__) );
error( QString("file:[%1] line:[%2] : slotsFinished() create failure. [%3]").arg(__FILE__).arg(__LINE__).arg(m_oProcess->errorString()) );
m_oCreateIsoLog.ouputCreateResult(cloneCDROM->display(), cloneCDROM->mDisplay(), true==m_oKeep);
m_oKeep = false;
return;
} else {
error( QString("file:[%1] line:[%2] : slotsFinished() Medium burn data failure. [%3]").arg(__FILE__).arg(__LINE__).arg(m_oProcess->errorString()) );
}
qDebug()<<__func__<<__LINE__<<m_bCreateISO;
if (m_oFlag && m_oKeep && (1 == code)){
qDebug() << __LINE__ << __func__ << "出现 :-( unable to reload tray, 不认为是错误输出 m_oFlag = " << m_oFlag << " m_oKeep = " << m_oKeep << "code = " << code;
m_oKeep = true;
} else {
m_oKeep = false;
}
error( QString("file:[%1] line:[%2] : slotsFinished() Medium burn data failure. [%3]").arg(__FILE__).arg(__LINE__).arg(m_oProcess->errorString()) );
}
cdrom->m_bStart = false;
qDebug()<<__func__<<__LINE__<<status;
//cdrom->m_bStart(false);
cloneCDROM->updateCDROMBurnStart(false);
emit g_user_signal->noMedium(cdrom);
cdrom->eject();
cloneCDROM->eject();
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnDataLog.outputResult(cloneCDROM->display(), cloneCDROM->mediumType(), m_oProcessName, true==m_oKeep);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
void ProcessBurnData::slotsCopy(QString src, QString des)
{
qreal v;
int basic;
DataDirectory *root;
//DataDirectory *root;
root = (DataDirectory *)(m_oRoot);
//root = (DataDirectory *)(m_oRoot);
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnDataLog.appendFile(src); //待刻录的源文件
}else{
auditburner->set("burner-os-auditlog-name","");
}
if (m_bCreateISO) basic = 30 - m_iProgress;
else basic = 50 - m_iProgress;
++m_iCopied;
v = ((m_iCopied * 1.0) / (root->total() * 1.0));
//v = ((m_iCopied * 1.0) / (root->total() * 1.0));
v = ((m_iCopied * 1.0) / (m_ototal * 1.0));
v = v * basic;
m_iProgress += v;
setValue(m_iProgress, m_oIcon, _("Copied %1 to %2").arg(src).arg(des));
@ -533,10 +685,27 @@ void ProcessBurnData::slotsProcessBarDVD()
setValue(m_iProgress, m_oIcon, _("closing track"));
}
void ProcessBurnData::slotsRemoveDisc(QString dev)
{
if(dev == cloneCDROM->device()) {
if(m_oProcess->state() != QProcess::NotRunning) {
qDebug() << __func__ << __LINE__ << dev << "被拔出,杀死刻录数据进程";
info(QString("[%1] [%2] : %3 被拔出,杀死刻录数据进程").arg(__func__).arg(__LINE__).arg(dev));
m_oProcess->kill();
}
}
}
ProcessBurnData::~ProcessBurnData()
{
if(m_oProgressBarTimer_DVD!=nullptr)
delete m_oProgressBarTimer_DVD;
m_oProgressBarTimer_DVD = nullptr;
//info(QString("[%1] [%2] : 将要delete cloneCDROM").arg(__func__).arg(__LINE__));
if(cloneCDROM) {
delete cloneCDROM;
//info(QString("[%1] [%2] : 执行delete cloneCDROM").arg(__func__).arg(__LINE__));
}
cloneCDROM = nullptr;
}

View File

@ -2,9 +2,14 @@
#define PROCESSBURNDATA_H
#include "processbasic.h"
#include "src/frame/auditlog.h"
#include "src/data/datadirectory.h"
#include <QObject>
#include <QTimer>
#include "kysdk/kysdk-system/libkysysinfo.h"
#include <QGSettings/QGSettings>
class DataCDROM;
class ProcessBurnData : public ProcessBasic
{
@ -26,12 +31,15 @@ protected slots:
void slotsFinished(int, QProcess::ExitStatus);
void slotsCopy(QString, QString);
void slotsProcessBarDVD();// 使DVD盘进度条按计时器时间走不卡在关盘操作上
void slotsRemoveDisc(QString); // 有光驱被拔出
private:
int m_iCopied;
int m_iProgress;
qreal m_fSpeed;
bool m_bCreateISO;
bool m_bAppendBurn;
bool m_bVerficationData;
bool m_oFlag;
void *m_oCDROM;
void *m_oRoot;
QString m_oCdrecord;
@ -41,7 +49,21 @@ private:
QString m_oXorriso;
QString m_oISOOutput;
QString m_oMSINFO;
AuditLog m_oBurnDataLog;
QTimer *m_oProgressBarTimer_DVD;
QString m_odestination;
unsigned long m_oSize;
unsigned long m_oNewSize; // 需刻录内容的容量
unsigned long m_ototal;
void *m_ocopy;
DataDirectory *m_root;
AuditLog m_oCreateIsoLog;
bool m_isSpecialMachine;
QGSettings *auditburner;
QString auditlogpath;
QString m_oTempPath; // 写光盘前数据存储的临时目录
DataCDROM *cloneCDROM;
};
#endif // PROCESSBURNDATA_H

View File

@ -4,10 +4,10 @@
#include "src/po/translation.h"
#include "src/data/datacdrom.h"
#include "src/view/modaldialog.h"
#include "src/frame/signals.h"
#include <QFileInfo>
#include <QDebug>
#include <ukuistylehelper.h>
ProcessBurnImage::ProcessBurnImage(QString image, void *cdrom, QObject *parent) :
ProcessBasic(parent),
@ -15,26 +15,29 @@ ProcessBurnImage::ProcessBurnImage(QString image, void *cdrom, QObject *parent)
m_oCDROM(cdrom),
m_iProgress(0)
{
// m_isSpecialMachine=kdk_system_is_zyj();
auditburner = new QGSettings("org.ukui.kylinburner");
auditlogpath = "/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine = auditburner->get("burneraudit-isrunning").toBool();
m_oCloneCDROM = ((DataCDROM *)m_oCDROM)->clone();
LOGGER->registerName(this, _("PROCESS_BI"));
title(_("Burning Image"));
m_oProcessName = _("Burn Image");
setRange(0, 100);
setValue(0);
connect(this, SIGNAL(eject()), static_cast<DataCDROM *>(m_oCDROM), SLOT(eject()));
//connect(this, SIGNAL(eject()), m_oCloneCDROM, SLOT(eject()));
connect(g_user_signal, &GlobalUserSignal::removeDisc, this, &ProcessBurnImage::slotsRemoveDisc);
}
bool ProcessBurnImage::prepare()
{
QFileInfo f;
DataCDROM *cdrom;
info(_("Step.%1: preparing...").arg("prepare"));
m_oTimer->setInterval(1000);
setValue(0, m_oIcon, _("Step.%1: preparing...").arg("prepare"));
m_oTimer->start();
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
connect(this, SIGNAL(cancel(bool)), MODAL, SLOT(cancelEnable(bool)));
@ -49,10 +52,12 @@ bool ProcessBurnImage::prepare()
info(_("Checked image already exists."));
setValue(++m_iProgress, m_oIcon, _("Checked image already exists."));
cdrom = (DataCDROM *)getCDROM();
if (nullptr == cdrom) return false;
if (!verifyCDROM()) {
return false;
}
m_oDeviceBlock = m_oCloneCDROM->device();
if (cdrom->mediumType().startsWith("CD"))
if (m_oCloneCDROM->mediumType().startsWith("CD"))
{
f.setFile("/bin/cdrecord");
if (!f.exists())
@ -71,10 +76,10 @@ bool ProcessBurnImage::prepare()
}
m_oProcess->setProgram(f.fileName());
m_oArguments << "-v";
m_oArguments << QString("dev=%1").arg(cdrom->device());
m_oArguments << QString("dev=%1").arg(m_oCloneCDROM->device());
m_oArguments << "driveropts=burnfree";
}
else if (cdrom->mediumType().contains("DVD+R DL"))
else if (m_oCloneCDROM->mediumType().contains("DVD+R DL"))
{
//xorriso -as cdrecord -v dev=/dev/sr0 blank=as_needed -multi -eject /media/kylin/Kylin-Deskt/ISO/ubuntu-14.04.5-server-ppc64el.iso
f.setFile("/bin/xorriso");
@ -93,10 +98,16 @@ bool ProcessBurnImage::prepare()
return false;
}
m_oProcess->setProgram("xorriso");
m_oArguments << "-as" << "cdrecord" << "-v" << QString("dev=%1").arg(cdrom->device()) << "blank=as_needed" << "-multi" << "-eject" << m_oImage;
//m_oArguments << "-as" << "cdrecord" << "-v" << QString("dev=%1").arg(cdrom->device()) << "blank=as_needed" << "-multi" << m_oImage;
m_oArguments << "-as" << "cdrecord" << "-v" << QString("dev=%1").arg(m_oCloneCDROM->device()) << "blank=as_needed" << "-multi" << "-eject" << m_oImage;
//m_oArguments << "-as" << "cdrecord" << "-v" << QString("dev=%1").arg(m_oCloneCDROM->device()) << "blank=as_needed" << "-multi" << m_oImage;
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnImageLog.appendFile(m_oImage);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
else if (cdrom->mediumType().startsWith("DVD"))
else if (m_oCloneCDROM->mediumType().startsWith("DVD"))
{
f.setFile("/bin/growisofs");
if (!f.exists())
@ -116,13 +127,20 @@ bool ProcessBurnImage::prepare()
m_oProcess->setProgram(f.fileName());
m_oArguments << "-dvd-compat";
m_oArguments << "-Z";
m_oArguments << QString("%1=%2").arg(cdrom->device()).arg(m_oImage);
m_oArguments << QString("%1=%2").arg(m_oCloneCDROM->device()).arg(m_oImage);
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnImageLog.appendFile(m_oImage);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
else
{
error(_("Donot suppot medium type %1 in CDROM.").arg(cdrom->mediumType()));
error(_("Donot suppot medium type %1 in CDROM.").arg(m_oCloneCDROM->mediumType()));
setValue(++m_iProgress, QIcon::fromTheme("dialog-error-symbolic"),
_("Donot suppot medium type %1 in CDROM.").arg(cdrom->mediumType()));
_("Donot suppot medium type %1 in CDROM.").arg(m_oCloneCDROM->mediumType()));
return false;
}
info(_("Checking program %1 can be supported.").arg(m_oProcess->program()));
@ -137,29 +155,36 @@ bool ProcessBurnImage::config()
debug(_("Step.%1: getting...").arg("config"));
setValue(++m_iProgress, m_oIcon, _("Step.%1: getting...").arg("config"));
cdrom = (DataCDROM *)getCDROM();
if (nullptr == cdrom) return false;
speed = cdrom->settingSpeed();
if (!verifyCDROM()) {
return false;
}
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,true);
speed = m_oCloneCDROM->settingSpeed();
if (0 == speed)
{
warn(_("Speed config to 0, means auto."));
addValue(++m_iProgress, QIcon::fromTheme("dialog-warning-symbolic"), _("Speed config to 0, means auto."));
}
if (cdrom->mediumType().startsWith("CD"))
if (m_oCloneCDROM->mediumType().startsWith("CD"))
{
if (speed) m_oArguments << QString("speed=%1").arg(speed);
m_oArguments << "-eject";
m_oArguments << m_oImage;
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnImageLog.appendFile(m_oImage);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
else if( cdrom->mediumType().contains("DVD+R DL") )
else if( m_oCloneCDROM->mediumType().contains("DVD+R DL") )
{
}
else if( cdrom->mediumType().startsWith("DVD") )
else if( m_oCloneCDROM->mediumType().startsWith("DVD") )
{
//卸载光盘,没地方写了
cdrom->umount();
m_oCloneCDROM->umount();
if (speed) m_oArguments << QString("-speed=%1").arg(speed);
return m_oKeep;
}
@ -272,18 +297,44 @@ void ProcessBurnImage::slotsError()
m_oKeep = false;
if (output.contains(":-("))
m_oKeep = false;
if (output.contains("OPC failed."))
if (output.contains("OPC failed.")) {
m_oKeep = false;
if (output.contains("Input/output error"))
}
if (output.contains("Input/output error")) {
m_oKeep = false;
if (output.contains("xorriso : aborting"))
m_lastErrorMsg = QString(_("Input/output error. Disc may be damaged, please clean or replace a disc and try again."));
}
if (output.contains("xorriso : aborting")) {
m_oKeep = false;
if(output.contains("seems to be mounted!")) // CD盘光盘不能卸载
m_lastErrorMsg = QString(_("Burning command aborted."));
}
if(output.contains("seems to be mounted!")) {
// CD盘光盘不能卸载
m_oKeep = false;
if(output.contains("target is busy")) // CD盘光盘不能卸载
m_lastErrorMsg = QString(_("Disc umount failed."));
}
if(output.contains("target is busy")) {
// CD盘光盘不能卸载
m_oKeep = false;
if(output.contains("Cannot open busy device")) //xorriso卸载失败
m_lastErrorMsg = QString(_("Disc is busy , umount failed."));
}
if(output.contains("Cannot open busy device")) {
//xorriso卸载失败
m_oKeep = false;
m_lastErrorMsg = QString(_("Disc is busy , umount failed."));
}
if(output.contains("No such device")) {
m_lastErrorMsg = QString(_("No such device."));
/** CD盘刻录镜像时光驱拔出后报错进程需等待10分钟结束不会立即结束用户感知刻录镜像
*
**/
if (m_oProcess->state() != QProcess::NotRunning)
{
m_oKeep = false;
debug(_("An error occurs when the CD is removed during image burning. The image burning process is terminated."));
m_oProcess->kill();
}
}
if (!output.isEmpty())
{
@ -354,12 +405,16 @@ void ProcessBurnImage::slotsError()
}
}
error(output);
if (output.contains("libburn : FATAL : SCSI error on write")) {
m_lastErrorMsg = QString(_("Input/output error. Disc may be damaged, please clean or replace a disc and try again."));
}
cancel(false);
}
void ProcessBurnImage::slotsFinished(int code, QProcess::ExitStatus status)
{
//DataCDROM* cdrom = (DataCDROM *)m_oCDROM;
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
info(_("Exit code is %1, status : %2").arg(code).arg(status));
if ("cdrecord" == m_oProcess->program())
{
@ -367,7 +422,6 @@ void ProcessBurnImage::slotsFinished(int code, QProcess::ExitStatus status)
{
info(QString("file:[%1] line:[%2] : slotsFinished() CD Medium burn image success.").arg(__FILE__).arg(__LINE__));
m_oKeep = true;
//success(_("BurnImage"));
}
else
{
@ -385,33 +439,55 @@ void ProcessBurnImage::slotsFinished(int code, QProcess::ExitStatus status)
else
info(QString("file:[%1] line:[%2] : slotsFinished() DVD Medium burn image success.").arg(__FILE__).arg(__LINE__));
}
//m_oBurnImageLog.outputResult(m_oCloneCDROM->display(), m_oCloneCDROM->mediumType(), m_oProcessName, true==m_oKeep);
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnImageLog.outputResult(m_oCloneCDROM->display(), m_oCloneCDROM->mediumType(), m_oProcessName, true==m_oKeep);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
void *ProcessBurnImage::getCDROM()
void ProcessBurnImage::slotsRemoveDisc(QString dev)
{
DataCDROM *cdrom;
cdrom = (DataCDROM *)(m_oCDROM);
if (nullptr == cdrom)
{
error(_("CDROM doesnot exists any more."));
addValue(0, QIcon::fromTheme("dialog-error-symbolic"), _("CDROM doesnot exists any more."));
return nullptr;
if(dev == m_oCloneCDROM->device()) {
if(m_oProcess->state() != QProcess::NotRunning) {
qDebug() << __func__ << __LINE__ << dev << "被拔出,杀死刻录数据进程";
info(QString("[%1] [%2] : %3 被拔出,杀死刻录数据进程").arg(__func__).arg(__LINE__).arg(dev));
m_oProcess->kill();
}
}
if (!cdrom->isCDROM())
}
bool ProcessBurnImage::verifyCDROM()
{
if (nullptr == m_oCloneCDROM)
{
error(_("CDROM doesnot exists any more."));
addValue(0, QIcon::fromTheme("dialog-error-symbolic"), _("CDROM doesnot exists any more."));
return false;
}
if (!m_oCloneCDROM->isCDROM())
{
error(_("CDROM doesnot a real physical cdrom."));
addValue(0, QIcon::fromTheme("dialog-error-symbolic"), _("CDROM doesnot a real physical cdrom."));
return nullptr;
return false;
}
if (DataMedium::MEDIUM_EMPTY != cdrom->mediumStatus())
if (DataMedium::MEDIUM_EMPTY != m_oCloneCDROM->mediumStatus())
{
error(_("Medium in CDROM is not empty any more."));
addValue(0, QIcon::fromTheme("dialog-error-symbolic"), _("Medium in CDROM is not empty any more."));
return nullptr;
return false;
}
return cdrom;
return true;
}
ProcessBurnImage::~ProcessBurnImage()
{}
{
if (auditburner){
delete auditburner;
auditburner = nullptr;
}
}

View File

@ -2,8 +2,14 @@
#define PROCESSBURNIMAGE_H
#include "src/process/processbasic.h"
#include "src/frame/auditlog.h"
#include "src/data/datacdrom.h"
#include <QObject>
#include "kysdk/kysdk-system/libkysysinfo.h"
#include <QGSettings/QGSettings>
class DataCDROM;
class ProcessBurnImage : public ProcessBasic
{
@ -19,13 +25,20 @@ protected slots:
void slotsOutput() Q_DECL_OVERRIDE;
void slotsError() Q_DECL_OVERRIDE;
void slotsFinished(int,QProcess::ExitStatus) Q_DECL_OVERRIDE;
void slotsRemoveDisc(QString); // 有光驱被拔出
private:
void *getCDROM();
bool verifyCDROM();
private:
void *m_oCDROM;
int m_iProgress;
double m_fSpeed;
QString m_oImage;
void *m_oCDROM;
int m_iProgress;
double m_fSpeed;
QString m_oImage;
AuditLog m_oBurnImageLog;
bool m_isSpecialMachine;
QGSettings *auditburner;
QString auditlogpath;
DataCDROM *m_oCloneCDROM;
};
#endif // PROCESSBURNIMAGE_H

View File

@ -5,21 +5,26 @@
#include "src/data/datadirectory.h"
#include "src/view/modaldialog.h"
#include "src/view/execdialog.h"
#include "src/frame/signals.h"
#include <QFileInfo>
#include <QDir>
#include <QCoreApplication>
#include <QStandardPaths>
#include <fstream>
#include <ukuistylehelper.h>
ProcessBurnUDFData::ProcessBurnUDFData(void *root, void *cdrom, QObject *parent) :
ProcessBasic(parent)
{
// m_isSpecialMachine=kdk_system_is_zyj();
auditburner=new QGSettings("org.ukui.kylinburner");
auditlogpath="/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine=auditburner->get("burneraudit-isrunning").toBool();
DataCDROM *c;
m_oCDROM = cdrom;
m_oRoot = root;
c = (DataCDROM *)cdrom;
m_oDeviceBlock = c->device();
m_fSpeed = 0;
if (c->mediumStatus() == DataMedium::MEDIUM_EMPTY)
{
@ -33,8 +38,6 @@ ProcessBurnUDFData::ProcessBurnUDFData(void *root, void *cdrom, QObject *parent)
error(_("Media Not Empty,Not Burn UDF Format"));
m_bAppendBurn = true;
}
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
setRange(0, 100);
setValue(0);
@ -75,9 +78,8 @@ bool ProcessBurnUDFData::prepare()
}
connect(this, SIGNAL(cancel(bool)), MODAL, SLOT(cancelEnable(bool)));
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,true);
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
m_oGrowisofs = QString("growisofs -udf -r -v -gui ");
@ -139,7 +141,10 @@ bool ProcessBurnUDFData::working()
connect(root, SIGNAL(copied(QString,QString)), this, SLOT(slotsCopy(QString,QString)));
root->copy();
m_oTimer->start(500);
if (m_bCancel) return false;
if (m_bCancel) {
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
return false;
}
m_oArguments.clear();
m_oArguments << "-c";
@ -245,7 +250,7 @@ void ProcessBurnUDFData::slotsFinished(int code, QProcess::ExitStatus status)
DataCDROM *cdrom;
cdrom = (DataCDROM *)m_oCDROM;
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
info(_("Exit code is %1, status : %2").arg(code).arg(status));
@ -259,6 +264,12 @@ void ProcessBurnUDFData::slotsFinished(int code, QProcess::ExitStatus status)
m_oKeep = false;
}
cdrom->eject();
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnUdfDataLog.outputResult(cdrom->display(), cdrom->mediumType(), m_oProcessName, true==m_oKeep);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
void ProcessBurnUDFData::slotsCopy(QString src, QString des)
@ -268,7 +279,12 @@ void ProcessBurnUDFData::slotsCopy(QString src, QString des)
DataDirectory *root;
root = (DataDirectory *)(m_oRoot);
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oBurnUdfDataLog.appendFile(src); //待刻录的源文件
}else{
auditburner->set("burner-os-auditlog-name","");
}
if (m_bCreateISO) basic = 30 - m_iProgress;
else basic = 50 - m_iProgress;
++m_iCopied;

View File

@ -2,9 +2,10 @@
#define PROCESSBURNUDFDATA_H
#include "processbasic.h"
#include "src/frame/auditlog.h"
#include <QObject>
#include "kysdk/kysdk-system/libkysysinfo.h"
#include <QGSettings/QGSettings>
class ProcessBurnUDFData : public ProcessBasic
{
Q_OBJECT
@ -23,7 +24,7 @@ protected slots:
void slotsOutput();
void slotsError();
void slotsFinished(int, QProcess::ExitStatus);
void slotsCopy(QString, QString);
void slotsCopy(QString, QString);
private:
int m_iCopied;
int m_iProgress;
@ -38,6 +39,10 @@ private:
QString m_oCreateISO;
QString m_oISOOutput;
QString m_oMSINFO;
AuditLog m_oBurnUdfDataLog;
bool m_isSpecialMachine;
QGSettings *auditburner;
QString auditlogpath;
};
#endif // PROCESSBURNDATA_H

View File

@ -3,10 +3,11 @@
#include "src/po/translation.h"
#include "src/view/modaldialog.h"
#include "src/data/datacdrom.h"
#include "src/frame/signals.h"
#include "src/frame/auditlog.h"
#include <QFileInfo>
#include <ukuistylehelper.h>
#include <kysdk/kysdk-system/libkysysinfo.h>
#include <QDebug>
ProcessCopyDisk::ProcessCopyDisk(void *src, void *des, QObject *parent) :
ProcessBasic(parent),
m_oSource(src),
@ -28,7 +29,7 @@ bool ProcessCopyDisk::prepare()
m_oProcess->setProgram("/bin/bash");
src = (DataCDROM *)m_oSource;
m_oSrcDeviceBlock = src->device();
m_iProgress = 0;
if (sysid.isEmpty()) sysid = _("KylinOS");
@ -47,12 +48,15 @@ bool ProcessCopyDisk::prepare()
.arg("KylinBurner"));
return false;
}
PROGRESS;
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
connect(this, SIGNAL(cancel(bool)), MODAL, SLOT(cancelEnable(bool)));
des = static_cast<DataCDROM *>(m_oDestination);
m_oDesDeviceBlock = des->device();
g_user_signal->setDeviceBusyStatus(m_oSrcDeviceBlock,true);
g_user_signal->setDeviceBusyStatus(m_oDesDeviceBlock,true);
PROGRESS;
MODAL->show();
connect(this, SIGNAL(cancel(bool)), MODAL, SLOT(cancelEnable(bool)));
if (des->mediumType().startsWith("CD"))
{
@ -210,7 +214,65 @@ void ProcessCopyDisk::slotsError()
}
void ProcessCopyDisk::slotsFinished(int errCode, QProcess::ExitStatus status)
{}
{
bool m_isSpecialMachine;
// m_isSpecialMachine=kdk_system_is_zyj();
auditburner=new QGSettings("org.ukui.kylinburner");
auditlogpath="/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine=auditburner->get("burneraudit-isrunning").toBool();
AuditLog copyDiskLog;
DataCDROM *dest = (DataCDROM*)m_oDestination;
g_user_signal->setDeviceBusyStatus(m_oSrcDeviceBlock,false);
// info(_("Exit code is %1, status : %2").arg(errCode).arg(status));
// if (QProcess::NormalExit == status && 0 == errCode)
// {
// info( QString("slotsFinished() line[%1] : copy disk success.").arg(__LINE__) );
// }
// else
// {
// m_oKeep = false;
// error( QString("slotsFinished() line[%1] : copy disk failure: %2").arg(__LINE__).arg(m_oProcess->errorString()) );
// }
info(_("Exit code is %1, status : %2").arg(errCode).arg(status));
if ("cdrecord" == m_oProcess->program())
{
if (QProcess::NormalExit == status && 0 == errCode)
{
info(QString("file:[%1] line:[%2] : slotsFinished() CD Medium copy disk success.").arg(__FILE__).arg(__LINE__));
m_oKeep = true;
qDebug()<<__LINE__<<__func__<<"ProcessCopyDisk"<<status;
}
else
{
error(QString("file:[%1] line:[%2] : slotsFinished() CD Medium failure in copy disk. [%3]").arg(__FILE__).arg(__LINE__).arg(m_oProcess->errorString()));
m_oKeep = false;
qDebug()<<__LINE__<<__func__<<"ProcessCopyDisk"<<status;
}
}
else //DVD
{
if (QProcess::NormalExit != status || errCode != 0)
{
m_oKeep = false;
qDebug()<<__LINE__<<__func__<<"ProcessCopyDisk"<<status;
error(QString("file:[%1] line:[%2] : slotsFinished() DVD Medium have error in copy disk. [%3]").arg(__FILE__).arg(__LINE__).arg(m_oProcess->errorString()));
}
else{
qDebug()<<__LINE__<<__func__<<"ProcessCopyDisk"<<status;
info(QString("file:[%1] line:[%2] : slotsFinished() DVD Medium copy disk success.").arg(__FILE__).arg(__LINE__));
m_oKeep = true;
}
}
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
copyDiskLog.outputCopyResult("", dest->display(), dest->mediumType(), m_oProcessName, true==m_oKeep);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
ProcessCopyDisk::~ProcessCopyDisk()
{

View File

@ -2,7 +2,8 @@
#define PROCESSCOPYDISK_H
#include "src/process/processbasic.h"
#include "src/frame/auditlog.h"
#include <QGSettings/QGSettings>
class ProcessCopyDisk : public ProcessBasic
{
Q_OBJECT
@ -23,6 +24,10 @@ private:
void *m_oDestination;
QString m_oCdrecord;
QString m_oMkisofs;
QString m_oSrcDeviceBlock;
QString m_oDesDeviceBlock;
QGSettings *auditburner;
QString auditlogpath;
};
#endif // PROCESSCOPYDISK_H

View File

@ -9,7 +9,6 @@
#include <QFileInfo>
#include <fstream>
#include <QStorageInfo>
#include <ukuistylehelper.h>
ProcessCreateISO::ProcessCreateISO(void *r, void *d, QObject *parent) :
ProcessBasic(parent)
@ -21,6 +20,10 @@ ProcessCreateISO::ProcessCreateISO(void *r, void *d, QObject *parent) :
title(m_oProcessName);
setRange(0, 100);
setValue(0);
// m_isSpecialMachine=kdk_system_is_zyj();
auditburner=new QGSettings("org.ukui.kylinburner");
auditlogpath="/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine=auditburner->get("burneraudit-isrunning").toBool();
}
bool ProcessCreateISO::prepare()
@ -35,8 +38,6 @@ bool ProcessCreateISO::prepare()
cdrom = (DataCDROM *)(m_oCDROM);
root = (DataDirectory *)(m_oRoot);
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
connect(this, SIGNAL(cancel(bool)), MODAL, SLOT(cancelEnable(bool)));
@ -206,6 +207,14 @@ void ProcessCreateISO::slotsFinished(int code, QProcess::ExitStatus status)
m_oKeep = false;
error( QString("file:[%1] line:[%2] : slotsFinished() create ISO failure. [%3]").arg(__FILE__).arg(__LINE__).arg(m_oProcess->errorString()) );
}
DataCDROM* cdrom = (DataCDROM*)m_oCDROM;
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
m_oCreateIsoLog.ouputCreateResult(cdrom->display(), cdrom->mDisplay(), true==m_oKeep);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}
void ProcessCreateISO::slotsCopy(QString src, QString des)
@ -214,6 +223,7 @@ void ProcessCreateISO::slotsCopy(QString src, QString des)
DataDirectory *root;
root = (DataDirectory *)(m_oRoot);
m_oCreateIsoLog.appendFile(src); //待刻录的源文件
v = 0;
++m_iCopied;

View File

@ -2,9 +2,10 @@
#define PROCESSCREATEISO_H
#include "processbasic.h"
#include "src/frame/auditlog.h"
#include <QObject>
#include "kysdk/kysdk-system/libkysysinfo.h"
#include <QGSettings/QGSettings>
class ProcessCreateISO : public ProcessBasic
{
Q_OBJECT
@ -28,6 +29,10 @@ private:
int m_iCopied;
void *m_oCDROM;
void *m_oRoot;
AuditLog m_oCreateIsoLog;
bool m_isSpecialMachine;
QGSettings *auditburner;
QString auditlogpath;
};
#endif // PROCESSCREATEISO_H

View File

@ -3,44 +3,45 @@
#include "src/po/translation.h"
#include "src/data/datacdrom.h"
#include "src/view/modaldialog.h"
#include "src/frame/auditlog.h"
#include "src/frame/signals.h"
#include <QFileInfo>
#include <ukuistylehelper.h>
#include <QDebug>
ProcessEarse::ProcessEarse(void *cdrom, QObject *parent) :
ProcessBasic(parent),
m_oPro(new QTimer(this))
m_oCDROM(cdrom),
m_oPro(new QTimer(this))
{
m_oCDROM = cdrom;
// m_isSpecialMachine=kdk_system_is_zyj();
auditburner=new QGSettings("org.ukui.kylinburner");
auditlogpath="/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine=auditburner->get("burneraudit-isrunning").toBool();
m_oCloneCDROM = ((DataCDROM *)cdrom)->clone();
m_oDeviceBlock = m_oCloneCDROM->device();
m_iValue = 0;
LOGGER->registerName(this, _("PROCESS_EARSE"));
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
title(_("Earsing"));
m_oProcessName = _("Earse");
setRange(0, 100);
setValue(0);
connect(m_oPro, SIGNAL(timeout()), this, SLOT(slotsProgress()));
connect(g_user_signal, &GlobalUserSignal::removeDisc, this, &ProcessEarse::slotsRemoveDisc);
m_oPro->setInterval(1000);
}
bool ProcessEarse::prepare()
{
DataCDROM *cdrom;
QFileInfo f;
cdrom = (DataCDROM *)m_oCDROM;
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
connect(this, SIGNAL(cancel(bool)), MODAL, SLOT(cancelEnable(bool)));
m_oTimer->start(500);
if (cdrom->mediumType().contains("CD"))
if (m_oCloneCDROM->mediumType().contains("CD"))
f.setFile("/bin/cdrecord");
else
f.setFile("/bin/xorriso");
@ -59,93 +60,82 @@ bool ProcessEarse::prepare()
bool ProcessEarse::config()
{
DataCDROM *cdrom;
cdrom = (DataCDROM *)m_oCDROM;
if (cdrom->mediumType().contains("CD"))
if (m_oCloneCDROM->mediumType().contains("CD"))
{
cdrom->umount();
m_oCloneCDROM->umount();
m_oArguments << "blank=fast"
<< "driveropts=burnfree"
<< QString("dev=%1").arg(cdrom->device())
<< QString("dev=%1").arg(m_oCloneCDROM->device())
<< "-v"
<< "-eject";
setValue(m_iValue++, m_oIcon, _("Umount CD, and prepare to blank CD."));
}
else
{
cdrom->umount();
m_oArguments << "-dev" << cdrom->device() << "-format" << "full";
m_oCloneCDROM->umount();
m_oArguments << "-dev" << m_oCloneCDROM->device() << "-format" << "full";
}
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,true);
return m_oKeep;
}
bool ProcessEarse::worked()
{
DataCDROM *cdrom;
cdrom = (DataCDROM *)m_oCDROM;
cdrom->eject();
m_oCloneCDROM->eject();
return m_oKeep;
}
void ProcessEarse::slotsOutput()
{
// CD 光盘进行擦除操作
QString output;
output = m_oProcess->readAllStandardOutput();
qDebug() << __func__ << __LINE__ << "output : " << output;
info(QString("[%1] [%2] output: %3").arg(__func__).arg(__LINE__).arg(output));
if (output.contains("Input/output error")) {
m_oKeep = false;
} else if(output.contains("Errno:")) {
m_oKeep = false;
}
if (output.contains("Performing OPC"))
{
cancel(false);
setValue(m_iValue++, m_oIcon, _("Performing OPC"));
}
setValue(m_iValue++, m_oIcon, _("Blanking..."));
m_oPro->start();
if (output.contains("Fixating"))
return;
} else if (output.contains("Fixating")) {
setValue(99, m_oIcon, _("Fixating(Will wait minutes)"));
return;
}
if (!m_oPro->isActive()) {
m_oPro->start();
}
}
void ProcessEarse::slotsError()
{
#if 0
int v;
QString error;
QStringList ss;
error = m_oProcess->readAllStandardError();
v = 0;
if (error.contains("%"))
{
cancel(false);
ss = error.split("\b");
ss = ss.last().split("%");
v = ss.first().toDouble();
if (v < 99)
setValue(v, m_oIcon, _("Blanking..."));
}
else if (error.contains(":-("))
{
m_oKeep = false;
}
else
{
this->error(error);
}
#else
QString eraseCmdOutput;
static int eraseValue = 0;
eraseCmdOutput = m_oProcess->readAllStandardError();
qDebug() << __func__ << __LINE__ << "error : " << eraseCmdOutput;
info(eraseCmdOutput);
if(eraseCmdOutput.contains("Beginning to format medium")){
eraseValue = 1;
cancel(false);
}else if(eraseCmdOutput.contains("Formatting done")){
eraseValue = 100;
}else if(eraseCmdOutput.contains("Formatting")){
}else if(eraseCmdOutput.contains("Device or resource busy")){
this->error("Device or resource busy");
m_oKeep = false;
return;
} else if(eraseCmdOutput.contains("xorriso : aborting")) {
m_oKeep = false;
return;
} else if(eraseCmdOutput.contains("Formatting")){
DataCDROM *cdrom = (DataCDROM*)m_oCDROM;
if(cdrom->mediumType().contains("DVD-RW")){
if(m_oCloneCDROM->mediumType().contains("DVD-RW")){
int currentValue = -1;
currentValue = (int)eraseCmdOutput.split(' ').at(7).mid(0,3).toDouble();
if((currentValue - eraseValue) < 2)
@ -156,21 +146,15 @@ void ProcessEarse::slotsError()
else
eraseValue += 5;
}
}else if(eraseCmdOutput.contains("Device or resource busy")){
this->error("Device or resource busy");
return;
}
setValue(eraseValue, m_oIcon, _("earsing...."));
#endif
}
void ProcessEarse::slotsFinished(int code, QProcess::ExitStatus status)
{
DataCDROM *cdrom;
cdrom = (DataCDROM *)m_oCDROM;
if (m_oPro->isActive()) m_oPro->stop();
g_user_signal->setDeviceBusyStatus( m_oDeviceBlock,false);
info(_("Exit code is %1, status : %2").arg(code).arg(status));
setValue(99, m_oIcon, _("earsing...."));
@ -178,13 +162,19 @@ void ProcessEarse::slotsFinished(int code, QProcess::ExitStatus status)
{
setValue(100, m_oIcon, _("Burn Data"));
info( QString("slotsFinished() line[%1] : earse Medium success.").arg(__LINE__) );
cdrom->eject();
m_oCloneCDROM->eject();
}
else
{
m_oKeep = false;
error( QString("slotsFinished() line[%1] : earse Medium failure. %2").arg(__LINE__).arg(m_oProcess->errorString()) );
}
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
eraseLog.outputResult(m_oCloneCDROM->display(), m_oCloneCDROM->mediumType(), m_oProcessName, true==m_oKeep);
} else {
auditburner->set("burner-os-auditlog-name","");
}
}
void ProcessEarse::slotsProgress()
@ -193,7 +183,29 @@ void ProcessEarse::slotsProgress()
setValue(m_iValue, m_oIcon, _("Blanking..."));
}
void ProcessEarse::slotsRemoveDisc(QString dev)
{
if(dev == m_oCloneCDROM->device()) {
if(m_oProcess->state() != QProcess::NotRunning) {
qDebug() << __func__ << __LINE__ << dev << "被拔出,杀死刻录数据进程";
info(QString("[%1] [%2] : %3 被拔出,杀死刻录数据进程").arg(__func__).arg(__LINE__).arg(dev));
m_oProcess->kill();
}
}
}
ProcessEarse::~ProcessEarse()
{
delete m_oPro;
//info(QString("[%1] [%2] : 析构函数").arg(__func__).arg(__LINE__));
if (auditburner) {
delete auditburner;
auditburner = nullptr;
}
//info(QString("[%1] [%2] : 准备析构m_oCloneCDROM").arg(__func__).arg(__LINE__));
if (m_oCloneCDROM) {
delete m_oCloneCDROM;
m_oCloneCDROM = nullptr;
//info(QString("[%1] [%2] : 已析构m_oCloneCDROM").arg(__func__).arg(__LINE__));
}
//info(QString("[%1] [%2] : 析构函数结束").arg(__func__).arg(__LINE__));
}

View File

@ -4,7 +4,10 @@
#include "processbasic.h"
#include <QObject>
#include "src/data/datacdrom.h"
#include "src/frame/auditlog.h"
#include <kysdk/kysdk-system/libkysysinfo.h>
#include <QGSettings/QGSettings>
class ProcessEarse : public ProcessBasic
{
Q_OBJECT
@ -22,10 +25,17 @@ protected slots:
void slotsFinished(int, QProcess::ExitStatus);
private slots:
void slotsProgress();
void slotsRemoveDisc(QString); // 有光驱被拔出
private:
int m_iValue;
void *m_oCDROM;
QTimer *m_oPro;
int m_iValue;
void *m_oCDROM;
QTimer *m_oPro;
DataCDROM *m_cdrom;
DataCDROM *m_oCloneCDROM;
AuditLog eraseLog;
bool m_isSpecialMachine;
QGSettings *auditburner;
QString auditlogpath;
};
#endif // PROCESSEARSE_H

View File

@ -4,10 +4,12 @@
#include "src/data/datacdrom.h"
#include "src/view/modaldialog.h"
#include "src/view/execdialog.h"
#include "src/frame/signals.h"
#include "src/frame/auditlog.h"
#include <kysdk/kysdk-system/libkysysinfo.h>
#include <QFileInfo>
#include <QDir>
#include <ukuistylehelper.h>
ProcessGetISO::ProcessGetISO(void *src, void *des, QObject *parent) :
ProcessBasic(parent),
@ -76,9 +78,10 @@ bool ProcessGetISO::prepare()
debug(_("File %1 exists.").arg(f.absoluteFilePath()));
}
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
m_oDeviceBlock = src->device();
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,true);
m_oArguments << "-o" << f.absoluteFilePath();
m_oArguments << "-J" << "-r" << "-R" << "-joliet-long" << "-no-iso-translate"
@ -112,8 +115,10 @@ void ProcessGetISO::slotsError()
basic = 99 - m_iProgress;
output = m_oProcess->readAllStandardError();
if (output.contains("Input/output error"))
if (output.contains("Input/output error")) {
m_oKeep = false;
m_lastErrorMsg = QString(_("Bad sector detected, please clean or replace a disc and try again."));
}
if (output.contains("done, estimate")) // 2.50% done, estimate finish Tue Feb 2 17:15:15 2021
{
output = output.left(output.indexOf('%'));
@ -126,7 +131,33 @@ void ProcessGetISO::slotsError()
}
void ProcessGetISO::slotsFinished(int errorCode, QProcess::ExitStatus status)
{}
{
AuditLog getIsoLog;
bool m_isSpecialMachine;
auditburner=new QGSettings("org.ukui.kylinburner");
auditlogpath="/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine=auditburner->get("burneraudit-isrunning").toBool();
// m_isSpecialMachine=kdk_system_is_zyj();
DataCDROM *src = (DataCDROM*)m_oSource;
DataCDROM *dest = (DataCDROM*)m_oDestination;
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
getIsoLog.outputCopyResult(src->mediumMountPoint(), dest->display(), dest->mediumType(), m_oProcessName, true==m_oKeep);
}else{
auditburner->set("burner-os-auditlog-name","");
}
g_user_signal->setDeviceBusyStatus(m_oDeviceBlock,false);
info(_("Exit code is %1, status : %2").arg(errorCode).arg(status));
if (QProcess::NormalExit == status && 0 == errorCode)
{
info( QString("slotsFinished() line[%1] : get ISO success.").arg(__LINE__) );
}
else
{
m_oKeep = false;
error( QString("slotsFinished() line[%1] : get ISO failure: %2").arg(__LINE__).arg(m_oProcess->errorString()) );
}
}
ProcessGetISO::~ProcessGetISO()
{}

View File

@ -4,7 +4,7 @@
#include "src/process/processbasic.h"
#include <QObject>
#include <QGSettings/QGSettings>
class ProcessGetISO : public ProcessBasic
{
Q_OBJECT
@ -22,6 +22,8 @@ private:
int m_iProgress;
void *m_oSource;
void *m_oDestination;
QGSettings *auditburner;
QString auditlogpath;
};
#endif // PROCESSGETISO_H

View File

@ -3,12 +3,11 @@
#include "src/data/datacdrom.h"
#include "src/po/translation.h"
#include "src/view/modaldialog.h"
#include "src/frame/auditlog.h"
#include <kysdk/kysdk-system/libkysysinfo.h>
#include <QDir>
#include <QFileInfo>
#include <QCoreApplication>
#include <ukuistylehelper.h>
ProcessMd5sum::ProcessMd5sum(void *cdrom, QString checkFile, QObject *parent) :
ProcessBasic(parent),
@ -26,8 +25,6 @@ bool ProcessMd5sum::prepare()
DataCDROM *cdrom;
PROGRESS;
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(MODAL);
MODAL->show();
cdrom = static_cast<DataCDROM *>(m_oCDROM);
@ -65,6 +62,7 @@ void ProcessMd5sum::slotsOutput()
{
m_oKeep = false;
m_oProcess->kill();
QDir::setCurrent(QDir::homePath());
}
}
@ -80,12 +78,29 @@ void ProcessMd5sum::slotsError()
void ProcessMd5sum::slotsFinished(int errCode, QProcess::ExitStatus status)
{
if (QProcess::NormalExit == status && 0 == errCode)
if (QProcess::NormalExit == status && 0 == errCode) {
info( QString("file:[%1] line:[%2] : slotsFinished() Medium md5sum data success.").arg(__FILE__).arg(__LINE__) );
QDir::setCurrent(QDir::homePath());
}
else
{
m_oKeep = false;
error( QString("file:[%1] line:[%2] : slotsFinished() Medium md5sum data failure. [%3]").arg(__FILE__).arg(__LINE__).arg(m_oProcess->errorString()) );
QDir::setCurrent(QDir::homePath());
}
bool m_isSpecialMachine;
AuditLog md5checkLog;
// m_isSpecialMachine=kdk_system_is_zyj();
auditburner=new QGSettings("org.ukui.kylinburner");
auditlogpath="/var/log/kylin-burner/os_audit.log";
m_isSpecialMachine=auditburner->get("burneraudit-isrunning").toBool();
if(m_isSpecialMachine==true){
auditburner->set("burner-os-auditlog-name",auditlogpath);
DataCDROM* cdrom = (DataCDROM*)m_oCDROM;
md5checkLog.outputResult(cdrom->display(), cdrom->mediumType(), m_oProcessName, true==m_oKeep);
}else{
auditburner->set("burner-os-auditlog-name","");
}
}

View File

@ -2,7 +2,7 @@
#define PROCESSMD5SUM_H
#include "src/process/processbasic.h"
#include <QGSettings/QGSettings>
class ProcessMd5sum : public ProcessBasic
{
Q_OBJECT
@ -21,6 +21,8 @@ private:
int m_iProgress;
void *m_oCDROM;
QString m_oCheckFile;
QGSettings *auditburner;
QString auditlogpath;
};
#endif // PROCESSMD5SUM_H

View File

@ -2,7 +2,7 @@
#include "src/view/modaldialog.h"
#include "src/data/datacdrom.h"
#include "src/po/translation.h"
#include <QDebug>
#include <QFileInfo>
ProcessMediaInfo::ProcessMediaInfo(void *d, QObject *parent) :
@ -11,19 +11,17 @@ ProcessMediaInfo::ProcessMediaInfo(void *d, QObject *parent) :
m_u64Size(0)
{
m_oProcessName = _("Media Info");
cloneCDROM = ((DataCDROM *)d)->clone();
}
bool ProcessMediaInfo::prepare()
{
DataCDROM *cdrom;
if (!MODAL->isHidden()) MODAL->close();
disconnect(this, SIGNAL(success(QString)), TIP, SIGNAL(success(QString)));
disconnect(this, SIGNAL(fail(QString)), TIP, SIGNAL(fail(QString)));
m_oProcess->setProgram("dvd+rw-mediainfo");
cdrom = static_cast<DataCDROM *>(m_oCDROM);
m_oArguments << cdrom->device();
m_oArguments << cloneCDROM->device();
m_oProcess->setArguments(m_oArguments);
return true;
}
@ -40,7 +38,6 @@ void ProcessMediaInfo::slotsOutput()
int i;
unsigned long t;
unsigned long u;
DataCDROM *cdrom;
QString output;
QStringList ss;
QStringList sss;
@ -53,14 +50,14 @@ void ProcessMediaInfo::slotsOutput()
{
if (ss.at(i).startsWith("READ FORMAT CAPACITIES:")) break;
}
cdrom = static_cast<DataCDROM *>(m_oCDROM);
if (cdrom->mediumType().contains("DVD+RW"))
if (cloneCDROM->mediumType().contains("DVD+RW"))
{
ss = ss.takeAt(i + 1).split("=");
//ss = ss.last().split("=");
m_u64Size = ss.last().toULong();
}
if (cdrom->mediumType().contains("DVD-RW"))
if (cloneCDROM->mediumType().contains("DVD-RW"))
{
//解决bug:70940和83628擦除后总容量显示错误
#if 0
@ -85,6 +82,7 @@ void ProcessMediaInfo::slotsOutput()
ProcessMediaInfo::~ProcessMediaInfo()
{
qDebug() << __func__ << __LINE__ << "----------------";
#if 0
if(m_oProcess!=nullptr)
{
@ -92,6 +90,7 @@ ProcessMediaInfo::~ProcessMediaInfo()
m_oProcess = nullptr;
}
#else
m_oProcess->close();
#endif
}

View File

@ -4,7 +4,7 @@
#include "src/process/processbasic.h"
#include <QObject>
class DataCDROM;
class ProcessMediaInfo : public ProcessBasic
{
Q_OBJECT
@ -23,6 +23,7 @@ protected slots:
private:
void *m_oCDROM;
unsigned long m_u64Size;
DataCDROM *cloneCDROM;
};
#endif // PROCESSMEDIAINFO_H

View File

@ -54,6 +54,7 @@ void DiscRead::workForInitMembers(){
//2. 获取Filesystem dbus对象
mFilesystemInf = new QDBusInterface(DiscBusName,DiscBusObjectPathPrefix+busDevicePath,
DiscBusFilesystem,QDBusConnection::systemBus());
qDebug()<<"["<<mFilesystemInf<<"] new Filesystem object!";
if(!mFilesystemInf->isValid())
qDebug()<<"["<<mDevice<<"] failed to new Filesystem object!";
@ -181,6 +182,7 @@ void DiscRead::workFromFilesystem(){
* 3)
*
*/
qDebug()<<"["<<mDevice<<"]"<<mFilesystemType;
if(mFilesystemType.isEmpty() && (nullptr !=mFilesystemInf && mFilesystemInf->isValid())){
mIsGood = false;
qDebug()<<"["<<mDevice<<"] is not good!";

View File

@ -2,14 +2,16 @@
#include "ui_burndata.h"
#include "src/po/translation.h"
#include "src/frame/logger.h"
#include "src/frame/signals.h"
#include "src/frame/configuration.h"
#include "src/model/menufactory.h"
#include "src/model/logicmain.h"
#include "src/view/execdialog.h"
#include "src/view/modaldialog.h"
#include "src/view/filefilterrules.h"
#include "src/view/viewfilterfiles.h"
#include "src/frame/signals.h"
#include <QDebug>
#include <QMessageBox>
#include <QDragEnterEvent>
#include <QDropEvent>
@ -18,7 +20,6 @@
#include <QFileInfo>
#include <QToolButton>
#include <QFileSystemWatcher>
#include <ukuistylehelper.h>
BurnData *BurnData::m_oInstance = nullptr;
QMutex BurnData::m_oMutex;
@ -51,15 +52,19 @@ BurnData::BurnData(QWidget *parent) :
f.setPixelSize(14);
ui->btnAdd->setFont(f);
ui->btnAdd->setIcon(QIcon::fromTheme("list-add-symbolic"));
ui->btnAdd->setText(_("&Add"));
ui->btnAdd->setText(_("Add(&A)"));
ui->btnAdd->setProperty("useIconHighlightEffect", 0x8);
ui->btnAdd->setIconSize(ICON_SIZE);
ui->btnAdd->setCheckable(true);
connect(ui->btnAdd, SIGNAL(toggled(bool)), this, SLOT(slotsAddFiles(bool)));
connect(g_user_signal, &GlobalUserSignal::secondChangeDiscStatus, this, [&](){
qDebug() << QString("【%1】【%2】我变了").arg(__func__).arg(__LINE__);
ui->btnAdd->setEnabled(true);
});
ui->btnDelete->setFont(f);
ui->btnDelete->setIcon(QIcon::fromTheme("edit-clear-symbolic"));
ui->btnDelete->setText(_("&Delete"));
ui->btnDelete->setText(_("Delete(&D)"));
ui->btnDelete->setProperty("useIconHighlightEffect", 0x8);
ui->btnDelete->setIconSize(ICON_SIZE);
ui->btnDelete->setCheckable(true);
@ -67,7 +72,7 @@ BurnData::BurnData(QWidget *parent) :
ui->btnClean->setFont(f);
ui->btnClean->setIcon(QIcon::fromTheme("edit-delete-symbolic"));
ui->btnClean->setText(_("&Clean"));
ui->btnClean->setText(_("Clean(&C)"));
ui->btnClean->setProperty("useIconHighlightEffect", 0x8);
ui->btnClean->setIconSize(ICON_SIZE);
ui->btnClean->setCheckable(true);
@ -75,7 +80,7 @@ BurnData::BurnData(QWidget *parent) :
ui->btnNewFolder->setFont(f);
ui->btnNewFolder->setIcon(QIcon::fromTheme("folder-new-symbolic"));
ui->btnNewFolder->setText(_("&NewFolder"));
ui->btnNewFolder->setText(_("NewFolder(&N)"));
ui->btnNewFolder->setProperty("useIconHighlightEffect", 0x8);
ui->btnNewFolder->setIconSize(ICON_SIZE);
ui->btnNewFolder->setCheckable(true);
@ -121,16 +126,21 @@ BurnData::BurnData(QWidget *parent) :
ui->tip->installEventFilter(this);
connect(m_oModel, &LogicBurnData::rootIndex, [=](QModelIndex idx){
qDebug()<<__func__<<__LINE__<<"BurnData"<<idx;
if (!idx.isValid())
{
refresh();
return;
}
ui->treeView->setRootIndex(idx);
m_oAddIndex = idx;
if (m_oIndexes.size())
{
if (0 == m_oModel->level(idx)) m_oIndexes.replace(0, idx);
if (0 == m_oModel->level(idx))
{
m_oIndexes.replace(0, idx);
}
}
else m_oIndexes << idx;
refresh();
@ -170,24 +180,18 @@ BurnData::BurnData(QWidget *parent) :
connect(MAIN, SIGNAL(burnUDFData()), m_oModel , SLOT(slotsBurnUDFData()));
// connect(MAIN, SIGNAL(appendableMedium(void*)), m_oModel, SLOT(slotsCreateISO(void *)));
connect(MENU, &MenuFactory::fileFilter, [=](){
if (CFG->get("FilterFile", "range", true).toBool())
qDebug()<<"BurnData"<<__func__<<__LINE__;
if (CFG->get("FilterFile", "range", true).toBool()){
m_oModel->filter();
else
}else{
m_oModel->filter(ui->treeView->rootIndex());
}
if (!FILTERRULES->isHidden())
FILTERRULES->close();
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(FILTERRULES);
FILTERRULES->show();
});
connect(this, SIGNAL(viewFileterFile(bool)), MENU, SIGNAL(setViewFilterFile(bool)));
//connect(MENU, SIGNAL(viewFilterFile(bool)), VIEWFILTERFILE, SLOT(show()));
connect(MENU, &MenuFactory::viewFilterFile, this, [=](){
if(MODAL->isWayland())
kdk::UkuiStyleHelper::self()->removeHeader(VIEWFILTERFILE);
VIEWFILTERFILE->show();
});
connect(MENU, SIGNAL(viewFilterFile(bool)), VIEWFILTERFILE, SLOT(show()));
connect(FILTERRULES, SIGNAL(rangeAll(bool)), this, SLOT(slotsRangeChange(bool)));
connect(FILTERRULES, SIGNAL(hidden(bool)), this, SLOT(slotsFilterHidden(bool)));
connect(FILTERRULES, SIGNAL(broken(bool)), this, SLOT(slotsFilterBroken(bool)));
@ -235,6 +239,10 @@ BurnData::BurnData(QWidget *parent) :
connect(m_oNewFolder, SIGNAL(triggered(bool)), this, SLOT(slotsNewFolder(bool)));
connect(m_oProperties, SIGNAL(triggered(bool)), this, SLOT(slotsProperties()));
connect(g_user_signal, &GlobalUserSignal::iconChange, [=](QIcon icon){
setWindowIcon(icon);
});
refresh();
}
@ -388,6 +396,7 @@ void BurnData::linkEntry(QModelIndex idx)
basic = ui->widget_3->width() / 8;
if (m_oLinks.size() <= level)
{
qDebug()<<__LINE__<<__func__<<"BurnData";
btn = new QToolButton(this);
btn->setAutoRaise(true);
btn->setText(m_oModel->data(idx).toString().append("/"));
@ -474,7 +483,10 @@ void BurnData::slotsLink()
btn = qobject_cast<QToolButton *>(sender());
idx = m_oLinks.indexOf(btn);
if (-1 != idx) slotsEntry(m_oIndexes.at(idx));
if (-1 != idx){
qDebug()<<__LINE__<<"BurnData"<<__func__<<idx;
slotsEntry(m_oIndexes.at(idx));
}
}
void BurnData::slotsSize(unsigned long size)
@ -549,6 +561,7 @@ void BurnData::slotsAddFiles(bool b)
if (b)
{
qDebug()<<__func__<<__LINE__;
fd.reset();
fd.setExtendedSelection();
fd.setDirectory(QDir::currentPath());
@ -559,6 +572,7 @@ void BurnData::slotsAddFiles(bool b)
m_oModel->addDatasToIndex(fd.selectedFiles(), m_oAddIndex);
ui->btnAdd->setChecked(false);
}
qDebug()<<__func__<<__LINE__<<m_oAddIndex<<ui->treeView->rootIndex();
refresh();
}
@ -570,15 +584,8 @@ void BurnData::slotsDeleteFiles(bool b)
if (b || m_oDelete == sender())
{
//使用QMessageBox代替EXEC删除提示弹窗
/*
if (!EXEC->question(_("Delete"), _("Delete item(s) selected?")))
{
ui->btnDelete->setChecked(false);
return;
}
*/
int nRect = QMessageBox::question(this, _("Delete"), _("Delete item(s) selected?"),QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if(QMessageBox::No == nRect)
QScopedPointer<TipsChange> p(new TipsChange);
if(p->question(_("Delete"), _("Delete item(s) selected?")))
{
ui->btnDelete->setChecked(false);
return;
@ -599,12 +606,13 @@ void BurnData::slotsCleanFiles(bool b)
{
if (b)
{
if (EXEC->question(_("Clean"), _("Clean all item(s) under %1?")
.arg(ui->treeView->rootIndex().data().toString())))
{
QScopedPointer<TipsChange> p(new TipsChange);
if(p->question(_("Clean"), _("Clean all item(s) under %1?")
.arg(ui->treeView->rootIndex().data().toString()))){
slotsFilterHidden(false);
slotsFilterBroken(false);
slotsRepleaceSymbolLinks(false);
qDebug()<<__func__<<__LINE__;
m_oModel->clearDatasUnderIndex(ui->treeView->rootIndex());
}
ui->btnClean->setChecked(false);
@ -621,7 +629,8 @@ void BurnData::slotsNewFolder(bool b)
{
do
{
inputed = EXEC->input(folderName, _("NewFolder"), _("Please input new folder name."), _("NewFolder"));
InputChange inputchange;
inputed = inputchange.input(folderName, _("NewFolder"), _("Please input new folder name."), _("NewFolder"));
if (!inputed) break;
ui->btnNewFolder->setChecked(false);
if (folderName.trimmed().isEmpty())
@ -635,7 +644,6 @@ void BurnData::slotsNewFolder(bool b)
EXEC->error(_("NewFolder") + _("Empty Name"),
_("New Folder cannot be named with ""/""."));
continue;
continue;
}
if (folderName.length() > 103)
{
@ -661,31 +669,52 @@ void BurnData::slotsNewFolder(bool b)
void BurnData::slotsRangeChange(bool b)
{
if (b) m_oModel->filter();
else m_oModel->filter(ui->treeView->rootIndex());
if (b) {
qDebug()<<"BurnData隐藏"<<__func__<<__LINE__<<b;
m_oModel->filter();
}
else{
qDebug()<<"BurnData隐藏"<<__func__<<__LINE__<<b;
m_oModel->filter(ui->treeView->rootIndex());
}
}
#include "../data/datadirectory.h"
void BurnData::slotsFilterHidden(bool b)
{
QList<void *> datas;
QModelIndex idx;
DataDirectory::setFilterHidden(b);
if (b)
{
if (CFG->get("FilterFile", "range", true).toBool())
{
qDebug()<<"BurnData隐藏"<<__func__<<__LINE__<<b;
CFG->set("FilterFile","hidden",b);
m_oModel->doFilterHidden();
}
else
{
qDebug()<<"BurnData隐藏"<<__func__<<__LINE__<<b;
m_oModel->doFilterHidden(ui->treeView->rootIndex());
}
}
else
{
idx = QModelIndex();
if (!VIEWFILTERFILE->isHidden() &&
(VIEWFILTERFILE->currentIndex() != m_oModel->index())) return;
if (CFG->get("FilterFile", "range", true).toBool())
if (CFG->get("FilterFile", "range", true).toBool()){
CFG->set("FilterFile","hidden",b);
qDebug()<<"BurnData恢复"<<__func__<<__LINE__<<b;
datas = VIEWFILTERFILE->recoveryHiddenData(m_oModel->index(), m_oModel->level());
}
else
{
qDebug()<<"BurnData恢复"<<__func__<<__LINE__<<b;
idx = ui->treeView->rootIndex();
datas = VIEWFILTERFILE->recoveryHiddenData(m_oModel->index(), m_oModel->level(idx));
}
@ -700,18 +729,24 @@ void BurnData::slotsFilterBroken(bool b)
QList<void *> datas;
QModelIndex idx;
DataDirectory::setFilterBrokenSymbolLinks(b);
if (b)
{
if (CFG->get("FilterFile", "range", true).toBool())
if (CFG->get("FilterFile", "range", true).toBool()){
qDebug()<<__LINE__<<__func__<<b;
CFG->set("FilterFile","broken",b);
m_oModel->doFilterBroken();
else
}else{
m_oModel->doFilterBroken(ui->treeView->rootIndex());
}
}
else
{
idx = QModelIndex();
if (CFG->get("FilterFile", "range", true).toBool())
if (CFG->get("FilterFile", "range", true).toBool()){
CFG->set("FilterFile","broken",b);
datas = VIEWFILTERFILE->recoveryBrokenData(m_oModel->index(), m_oModel->level());
}
else
{
idx = ui->treeView->rootIndex();
@ -726,19 +761,27 @@ void BurnData::slotsFilterBroken(bool b)
void BurnData::slotsRepleaceSymbolLinks(bool b)
{
QList<void *> datas;
DataDirectory::setRepleaceSymbolLinks(b);
if (b)
{
if (CFG->get("FilterFile", "range", true).toBool())
if (CFG->get("FilterFile", "range", true).toBool()){
qDebug()<<__LINE__<<__func__<<b;
CFG->set("FilterFile","Repleace",b);
m_oModel->doFilterRepleace();
else
}else{
m_oModel->doFilterRepleace(ui->treeView->rootIndex());
}
}
else
{
if (CFG->get("FilterFile", "range", true).toBool())
if (CFG->get("FilterFile", "range", true).toBool()){
CFG->set("FilterFile","Repleace",b);
datas = VIEWFILTERFILE->recoveryRepleaceData(m_oModel->index(), m_oModel->level());
else
}else{
datas = VIEWFILTERFILE->recoveryRepleaceData(m_oModel->index(), m_oModel->level(ui->treeView->rootIndex()));
}
m_oModel->doRecoveryRepleace(datas);
}
update();
@ -747,16 +790,25 @@ void BurnData::slotsRepleaceSymbolLinks(bool b)
void BurnData::slotsParent()
{
if (ui->treeView->rootIndex().parent().isValid())
ui->treeView->setRootIndex(ui->treeView->rootIndex().parent());
if (ui->treeView->rootIndex().parent().isValid()){
//ui->treeView->setRootIndex(ui->treeView->rootIndex().parent());
slotsEntry(ui->treeView->rootIndex().parent());
}
refresh();
}
void BurnData::slotsOpen()
{
if (".." == ui->treeView->selectionModel()->selectedIndexes().first().siblingAtColumn(0).data().toString())
if (".." == ui->treeView->selectionModel()->selectedIndexes().first().siblingAtColumn(0).data().toString()){
slotsParent();
else
ui->treeView->setRootIndex(ui->treeView->selectionModel()->selectedIndexes().first());
}else{
slotsEntry(ui->treeView->selectionModel()->selectedIndexes().first());
// ui->treeView->setRootIndex(ui->treeView->selectionModel()->selectedIndexes().first());
// linkEntry(ui->treeView->selectionModel()->selectedIndexes().first());
}
// refresh();
}
void BurnData::slotsOpenLocal()

View File

@ -4,10 +4,12 @@
#include "src/model/logicburndata.h"
#include "src/view/multiselectionfiledialog.h"
#include "src/process/processopenfile.h"
#include "inputchange.h"
#include "tipschange.h"
#include <QWidget>
#include <QMutex>
#include <QAction>
#include <QScopedPointer>
namespace Ui {
class BurnData;

Some files were not shown because too many files have changed in this diff Show More