/
alexashkin
/
telegraph
Обзор
Документация
Войти
/
alexashkin
/
telegraph
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/telegraf.cpp
154 строки
6 KB
mbarashkov
Добавили TdLibController
21 фев 2025, 19:57
21 фев 2025, 19:57
563752a
Код
Авторство
О чём код?
#ifdef QT_QML_DEBUG #include <QtQuick> #endif #include <auroraapp.h> #include <QScopedPointer> #include <QQuickView> #include <QtQml> #include <QQmlContext> #include <QQmlEngine> #include <QGuiApplication> #include <QLoggingCategory> #include <QSysInfo> #include <QSettings> #include <QDir> #include <QDirIterator> #include <QFile> #include <QFileInfo> #include "appsettings.h" #include "debuglog.h" #include "debuglogjs.h" #include "tdlibfile.h" #include "tdlib/tdlibresponsehandler.h" #include "tdlib/tdlibrequestsender.h" #include "data/chatpermissionfiltermodel.h" #include "data/chatlistmodel.h" #include "data/chatlistsortedmodel.h" #include "data/chatmodel.h" #include "data/emojiservice.h" #include "namedaction.h" #include "notificationmanager.h" #include "device/mceinterface.h" #include "dbusadaptor.h" #include "processlauncher.h" #include "data/stickermanager.h" #include "textfiltermodel.h" #include "boolfiltermodel.h" #include "tgsplugin.h" #include "telegrafutils.h" #include "data/knownusersmodel.h" #include "data/contactsmodel.h" #include "filevalidator.h" #include "device/fileservice.h" #include "data/chatfoldersmodel.h" #include "network/networkservice.h" #include "dbusinterface.h" #include "tdlib/tdlibcontroller.h" // Правила логирования выставляются в виде набора правил, разделённых \n #ifdef QT_DEBUG #define DEFAULT_LOG_FILTER_RULES "tdlib.json.debug=false\ntdlib.comm.debug=false\ntdlib.files.debug=false" #else #define DEFAULT_LOG_FILTER_RULES "*=false" #endif Q_IMPORT_PLUGIN(TgsIOPlugin) int main(int argc, char *argv[]) { QLoggingCategory::setFilterRules(DEFAULT_LOG_FILTER_RULES); QScopedPointer<QGuiApplication> app(Aurora::Application::application(argc, argv)); QScopedPointer<QQuickView> view(Aurora::Application::createView()); app->setApplicationVersion("0.89.0"); QQmlContext *context = view.data()->rootContext(); const char *uri = "ru.telegrafaurora.telegraf"; qRegisterMetaType<TDLibConstants::ConnectionState>(); qRegisterMetaType<TDLibConstants::UserPrivacySetting>(); qRegisterMetaType<TDLibConstants::UserPrivacySettingRule>(); qmlRegisterType<TDLibFile>(uri, 1, 0, "TDLibFile"); qmlRegisterType<NamedAction>(uri, 1, 0, "NamedAction"); qmlRegisterType<TextFilterModel>(uri, 1, 0, "TextFilterModel"); qmlRegisterType<BoolFilterModel>(uri, 1, 0, "BoolFilterModel"); qmlRegisterType<ChatListSortedModel>(uri, 1, 0, "ChatListSortedModel"); qmlRegisterType<ChatPermissionFilterModel>(uri, 1, 0, "ChatPermissionFilterModel"); qmlRegisterType<FileValidator>(uri, 1, 0, "FileValidator"); qmlRegisterType<ChatFolderModel>(uri, 1, 0, "ChatFolderModel"); qmlRegisterSingletonType<DebugLogJS>(uri, 1, 0, "DebugLog", DebugLogJS::createSingleton); AppSettings *appSettings = new AppSettings(view.data()); context->setContextProperty("appSettings", appSettings); qmlRegisterUncreatableType<AppSettings>(uri, 1, 0, "AppSettings", QString()); EmojiService *emojiService = new EmojiService(view.data()); context->setContextProperty("emojiService", emojiService); NetworkService *networkService = new NetworkService(view.data()); context->setContextProperty("networkService", networkService); TDLibController *tdLibController = new TDLibController(appSettings, view.data()); context->setContextProperty("tdLibController", tdLibController); auto tdLibWrapper = tdLibController->getResponseHandler(); context->setContextProperty("tdLibWrapper", tdLibWrapper); qmlRegisterUncreatableType<TDLibResponseHandler>(uri, 1, 0, "TelegramAPI", QString()); TDLibRequestSender *tdLibRequestSender = tdLibWrapper->getRequestSender(); context->setContextProperty("tdLibRequestSender", tdLibRequestSender); TelegrafUtils *telegrafUtils = new TelegrafUtils(view.data()); context->setContextProperty("telegrafUtils", telegrafUtils); qmlRegisterUncreatableType<TelegrafUtils>(uri, 1, 0, "TelegrafUtilities", QString()); FileService *fileService = new FileService(view.data()); context->setContextProperty("fileService", fileService); auto dbusInterface = new DBusInterface(view.data()); DBusAdaptor *dBusAdaptor = dbusInterface->getDBusAdaptor(); context->setContextProperty("dBusAdaptor", dBusAdaptor); ChatListModel chatListModel(tdLibWrapper, appSettings); context->setContextProperty("chatListModel", &chatListModel); ChatFoldersModel chatFoldersModel(tdLibWrapper); context->setContextProperty("chatFoldersModel", &chatFoldersModel); ChatModel chatModel(tdLibWrapper); context->setContextProperty("chatModel", &chatModel); MceInterface *mceInterface = new MceInterface(view.data()); NotificationManager notificationManager(tdLibWrapper, appSettings, mceInterface, &chatModel); context->setContextProperty("notificationManager", ¬ificationManager); ProcessLauncher processLauncher; context->setContextProperty("processLauncher", &processLauncher); StickerManager stickerManager(tdLibWrapper); context->setContextProperty("stickerManager", &stickerManager); KnownUsersModel knownUsersModel(tdLibWrapper, view.data()); context->setContextProperty("knownUsersModel", &knownUsersModel); QSortFilterProxyModel knownUsersProxyModel(view.data()); knownUsersProxyModel.setSourceModel(&knownUsersModel); knownUsersProxyModel.setFilterRole(KnownUsersModel::RoleFilter); knownUsersProxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive); context->setContextProperty("knownUsersProxyModel", &knownUsersProxyModel); ContactsModel contactsModel(tdLibWrapper, view.data()); context->setContextProperty("contactsModel", &contactsModel); QSortFilterProxyModel contactsProxyModel(view.data()); contactsProxyModel.setSourceModel(&contactsModel); contactsProxyModel.setFilterRole(ContactsModel::RoleFilter); contactsProxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive); context->setContextProperty("contactsProxyModel", &contactsProxyModel); view->setSource(Aurora::Application::pathTo("qml/telegraf.qml")); view->show(); return app->exec(); }