You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

#include <QObject>
#include <QDir>
#include <QMessageBox>
#include <QCommandLineParser>
#include <QStandardPaths>
#include "conversations.h"
#include "lib/utils.h"
#include "lib/globals.h"
Conversations::Conversations(QCommandLineParser *cmdargs) {
this->cmdargs = cmdargs;
// Paths
pathGenericData = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
configRoot = QDir::homePath();
accountName = Utils::getUnixAccountName();
homeDir = QDir::homePath();
configDirectory = QString("%1/.config/%2/").arg(configRoot, QCoreApplication::applicationName());
// Create some directories
createConfigDirectory(configDirectory);
// flags, iso codes, etc
countries = new Countries();
if(this->isDebug) {
qDebug() << "configRoot: " << configRoot;
qDebug() << "homeDir: " << homeDir;
qDebug() << "configDirectory: " << configDirectory;
}
// https://stackoverflow.com/q/53018492
}
void Conversations::getMessages(const QString &contact_uid, int limit, int offset) {
}
void Conversations::setWindowTitle(const QString &title) {
emit setTitle(title);
}
void Conversations::createConfigDirectory(const QString &dir) {
QStringList createDirs({dir});
for(const auto &d: createDirs) {
if(!Utils::dirExists(d)) {
qDebug() << QString("Creating directory: %1").arg(d);
if (!QDir().mkpath(d))
throw std::runtime_error("Could not create directory " + d.toStdString());
}
}
}
Conversations::~Conversations() {}