mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(file): add a FileExtractor component (in progress)
This commit is contained in:
parent
a221558d46
commit
ccc6184234
3 changed files with 196 additions and 1 deletions
|
|
@ -145,6 +145,7 @@ set(SOURCES
|
|||
src/components/core/CoreHandlers.cpp
|
||||
src/components/core/CoreManager.cpp
|
||||
src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.cpp
|
||||
src/components/file/FileExtractor.cpp
|
||||
src/components/notifier/Notifier.cpp
|
||||
src/components/other/clipboard/Clipboard.cpp
|
||||
src/components/other/colors/Colors.cpp
|
||||
|
|
@ -201,6 +202,7 @@ set(HEADERS
|
|||
src/components/core/CoreHandlers.hpp
|
||||
src/components/core/CoreManager.hpp
|
||||
src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.hpp
|
||||
src/components/file/FileExtractor.hpp
|
||||
src/components/notifier/Notifier.hpp
|
||||
src/components/other/clipboard/Clipboard.hpp
|
||||
src/components/other/colors/Colors.hpp
|
||||
|
|
@ -218,8 +220,8 @@ set(HEADERS
|
|||
src/components/timeline/TimelineModel.hpp
|
||||
src/components/url-handlers/UrlHandlers.hpp
|
||||
src/utils/LinphoneUtils.hpp
|
||||
src/utils/Utils.hpp
|
||||
src/utils/QExifImageHeader.h
|
||||
src/utils/Utils.hpp
|
||||
)
|
||||
|
||||
set(TESTS
|
||||
|
|
|
|||
112
src/components/file/FileExtractor.cpp
Normal file
112
src/components/file/FileExtractor.cpp
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* FileExtractor.cpp
|
||||
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Created on: March 8, 2018
|
||||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include <mz_strm.h>
|
||||
#include <QDebug>
|
||||
|
||||
#include "FileExtractor.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
void FileExtractor::extract () {
|
||||
// TODO.
|
||||
}
|
||||
|
||||
QString FileExtractor::getFile () const {
|
||||
return mFile;
|
||||
}
|
||||
|
||||
void FileExtractor::setFile (const QString &file) {
|
||||
if (mExtracting) {
|
||||
qWarning() << QStringLiteral("Unable to set file, a file is extracting.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mFile != file) {
|
||||
mFile = file;
|
||||
emit fileChanged(mFile);
|
||||
}
|
||||
}
|
||||
|
||||
QString FileExtractor::getExtractFolder () const {
|
||||
return mExtractFolder;
|
||||
}
|
||||
|
||||
void FileExtractor::setExtractFolder (const QString &extractFolder) {
|
||||
if (mExtracting) {
|
||||
qWarning() << QStringLiteral("Unable to set extract folder, a file is extracting.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mExtractFolder != extractFolder) {
|
||||
mExtractFolder = extractFolder;
|
||||
emit extractFolderChanged(mExtractFolder);
|
||||
}
|
||||
}
|
||||
|
||||
qint64 FileExtractor::getReadBytes () const {
|
||||
return mReadBytes;
|
||||
}
|
||||
|
||||
void FileExtractor::setReadBytes (qint64 readBytes) {
|
||||
if (mReadBytes != readBytes) {
|
||||
mReadBytes = readBytes;
|
||||
emit readBytesChanged(readBytes);
|
||||
}
|
||||
}
|
||||
|
||||
qint64 FileExtractor::getTotalBytes () const {
|
||||
return mTotalBytes;
|
||||
}
|
||||
|
||||
void FileExtractor::setTotalBytes (qint64 totalBytes) {
|
||||
if (mTotalBytes != totalBytes) {
|
||||
mTotalBytes = totalBytes;
|
||||
emit totalBytesChanged(totalBytes);
|
||||
}
|
||||
}
|
||||
|
||||
bool FileExtractor::getExtracting () const {
|
||||
return mExtracting;
|
||||
}
|
||||
|
||||
void FileExtractor::setExtracting (bool extracting) {
|
||||
if (mExtracting != extracting) {
|
||||
mExtracting = extracting;
|
||||
emit extractingChanged(extracting);
|
||||
}
|
||||
}
|
||||
|
||||
void FileExtractor::handleReadyData () {
|
||||
// TODO.
|
||||
}
|
||||
|
||||
void FileExtractor::handleExtractFinished () {
|
||||
// TODO.
|
||||
|
||||
}
|
||||
|
||||
void FileExtractor::handleExtractProgress (qint64 readBytes, qint64 totalBytes) {
|
||||
// TODO.
|
||||
Q_UNUSED(readBytes);
|
||||
Q_UNUSED(totalBytes);
|
||||
}
|
||||
81
src/components/file/FileExtractor.hpp
Normal file
81
src/components/file/FileExtractor.hpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* FileExtractor.hpp
|
||||
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Created on: March 8, 2018
|
||||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#ifndef FILE_EXTRACTOR_H_
|
||||
#define FILE_EXTRACTOR_H_
|
||||
|
||||
#include <QFile>
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class FileExtractor : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
Q_PROPERTY(QString file READ getFile WRITE setFile NOTIFY fileChanged);
|
||||
Q_PROPERTY(QString extractFolder READ getExtractFolder WRITE setExtractFolder NOTIFY extractFolderChanged);
|
||||
Q_PROPERTY(qint64 readBytes READ getReadBytes NOTIFY readBytesChanged);
|
||||
Q_PROPERTY(qint64 totalBytes READ getTotalBytes NOTIFY totalBytesChanged);
|
||||
Q_PROPERTY(bool extracting READ getExtracting NOTIFY extractingChanged);
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void extract ();
|
||||
|
||||
signals:
|
||||
void fileChanged (const QString &file);
|
||||
void extractFolderChanged (const QString &extractFolder);
|
||||
void readBytesChanged (qint64 readBytes);
|
||||
void totalBytesChanged (qint64 totalBytes);
|
||||
void extractingChanged (bool extracting);
|
||||
void extractFinished ();
|
||||
void extractFailed();
|
||||
|
||||
private:
|
||||
QString getFile () const;
|
||||
void setFile (const QString &file);
|
||||
|
||||
QString getExtractFolder () const;
|
||||
void setExtractFolder (const QString &extractFolder);
|
||||
|
||||
qint64 getReadBytes () const;
|
||||
void setReadBytes (qint64 readBytes);
|
||||
|
||||
qint64 getTotalBytes () const;
|
||||
void setTotalBytes (qint64 totalBytes);
|
||||
|
||||
bool getExtracting () const;
|
||||
void setExtracting (bool extracting);
|
||||
|
||||
void handleReadyData ();
|
||||
void handleExtractFinished ();
|
||||
|
||||
void handleExtractProgress (qint64 readBytes, qint64 totalBytes);
|
||||
|
||||
QString mFile;
|
||||
QString mExtractFolder;
|
||||
QFile mDestinationFile;
|
||||
|
||||
qint64 mReadBytes = 0;
|
||||
qint64 mTotalBytes = 0;
|
||||
bool mExtracting = false;
|
||||
};
|
||||
|
||||
#endif // FILE_EXTRACTOR_H_
|
||||
Loading…
Add table
Reference in a new issue