This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
modern-linbo-gui/headers/backend/linbobackend.h

101 lines
3 KiB
C
Raw Normal View History

/****************************************************************************
** Modern Linbo GUI
** Copyright (C) 2020 Dorian Zedler <dorian@itsblue.de>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as published
** by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef LINBOBACKEND_H
#define LINBOBACKEND_H
#include <QObject>
#include <QStringList>
#include <QtDebug>
#include <QProcess>
#include <vector>
#include <iostream>
#include <fstream>
#include <istream>
#include <stdlib.h>
#include "linboconfig.h"
#include "linboos.h"
#include "linboimage.h"
#include "linbodiskpartition.h"
using namespace std;
class LinboBackend : public QObject
{
Q_OBJECT
public:
explicit LinboBackend(QObject *parent = nullptr);
enum LinboState {
Idle,
Root,
Partitioning,
Starting,
Syncing,
Installing
};
LinboConfig* getConfig();
QList<LinboOs*> getOperatingSystems();
protected:
void read_qstring(ifstream* input, QString& tmp );
void read_bool( ifstream* input, bool& tmp);
bool read_pair(ifstream* input, QString& key, QString& value);
bool toBool(const QString& value);
LinboOs* read_os(ifstream* input);
LinboDiskPartition* read_partition(ifstream* input);
void read_globals( ifstream* input, LinboConfig* config );
void saveappend( QStringList& command, const QString& item );
QStringList mksyncstartcommand(LinboConfig& config, LinboOs& os);
QStringList mksynccommand(LinboConfig& config, LinboOs& os);
QStringList mksyncrcommand(LinboConfig& config, LinboOs& os);
QStringList mkpartitioncommand(vector <LinboDiskPartition> &p);
QStringList mkpartitioncommand_noformat(vector <LinboDiskPartition> &p);
QStringList mkcacheinitcommand(LinboConfig& config, vector<LinboOs> &os, const QString& type);
QStringList mklinboupdatecommand(LinboConfig& config);
private:
LinboConfig* config;
QList<LinboOs*> operatingSystems;
QList<LinboDiskPartition*> diskPartitions;
QProcess* process;
void readFromStdout();
void readFromStderr();
void executeCommand(QStringList commandArgs, bool waitForFinished = true);
public slots:
void executeAutostart();
void shutdown();
void reboot();
bool startOs(LinboOs* os);
//bool syncStartOs();
//bool reinstallStartOs();
signals:
};
#endif // LINBOBACKEND_H