/
lmaxyz
/
telegraf
Обзор
Документация
Войти
/
lmaxyz
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/tdlib/tdlibcontroller.cpp
93 строки
4 KB
mbarashkov
Revert "Упрощаем систему папок для БД, мигрируем данные при необходимости автоматически"
08 апр 2025, 13:08
08 апр 2025, 13:08
631a89e
Код
Авторство
О чём код?
#include "tdlibcontroller.h" #include <QDir> #include <QStandardPaths> #include "../debuglog.h" TDLibController::TDLibController(QObject *parent) : QObject(parent), networkConfigurationManager(new QNetworkConfigurationManager(this)), responseHandler(new TDLibResponseHandler(getApplicationDataPath(), this)) { createDBDirectoryIfNeeded(); handleOpenWithChanged(); connect(AppSettings::getInstance(), SIGNAL(useOpenWithChanged()), this, SLOT(handleOpenWithChanged())); connect( networkConfigurationManager, SIGNAL(configurationChanged(QNetworkConfiguration)), this, SLOT(handleNetworkConfigurationChanged(QNetworkConfiguration)) ); TDLibRequestService::getInstance()->sendRequest(TDLibRequestFactory::getInstance()->setLogVerbosityLevelRequest()); TDLibRequestSender::getInstance()->callSetOptionInteger("notification_group_count_max", 5); } void TDLibController::handleOpenWithChanged() { AppSettings::getInstance()->getUseOpenWith() ? osService.initializeOpenWith() : osService.removeOpenWith(); } void TDLibController::createDBDirectoryIfNeeded() const { QString tdLibDatabaseDirectoryPath = getApplicationDataPath() + "/tdlib"; QDir tdLibDatabaseDirectory(tdLibDatabaseDirectoryPath); if (!tdLibDatabaseDirectory.exists()) { tdLibDatabaseDirectory.mkpath(tdLibDatabaseDirectoryPath); } } void TDLibController::handleNetworkConfigurationChanged(const QNetworkConfiguration&) { bool wifiFound = false; bool mobileFound = false; QList<QNetworkConfiguration> activeConfigurations = networkConfigurationManager->allConfigurations(QNetworkConfiguration::Active); QListIterator<QNetworkConfiguration> configurationIterator(activeConfigurations); while (configurationIterator.hasNext()) { QNetworkConfiguration activeConfiguration = configurationIterator.next(); if (activeConfiguration.bearerType() == QNetworkConfiguration::BearerWLAN || activeConfiguration.bearerType() == QNetworkConfiguration::BearerEthernet) { wifiFound = true; break; } if ( activeConfiguration.bearerType() == QNetworkConfiguration::Bearer2G || activeConfiguration.bearerType() == QNetworkConfiguration::Bearer3G || activeConfiguration.bearerType() == QNetworkConfiguration::Bearer4G || activeConfiguration.bearerType() == QNetworkConfiguration::BearerCDMA2000 || activeConfiguration.bearerType() == QNetworkConfiguration::BearerEVDO || activeConfiguration.bearerType() == QNetworkConfiguration::BearerHSPA || activeConfiguration.bearerType() == QNetworkConfiguration::BearerLTE || activeConfiguration.bearerType() == QNetworkConfiguration::BearerWCDMA) { mobileFound = true; } } if (wifiFound) { TDLibRequestSender::getInstance()->callSetNetworkType(TDLibConstants::NetworkType::WiFi); } else if (mobileFound) { TDLibRequestSender::getInstance()->callSetNetworkType(TDLibConstants::NetworkType::Mobile); } else { TDLibRequestSender::getInstance()->callSetNetworkType(TDLibConstants::NetworkType::None); } } QString TDLibController::getApplicationDataPath() const { #ifdef DEV_BUILD return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/.ru.telegrafaurora"; #else return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); #endif }