Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
qmltemplates_p.h File Reference

The QML template libraries, their headers, and the trust store (design 0023). More...

#include "trust_p.h"
#include <sonde/qmltemplatetrust.h>
#include <sonde/server.h>
#include <sonde/expected.h>
#include <QtCore/QDateTime>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonValue>
#include <QtCore/QUrl>
#include <QtCore/QList>
#include <QtCore/QMutex>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtQml/QQmlAbstractUrlInterceptor>
#include <functional>
#include <optional>

Go to the source code of this file.

Classes

class  Sonde::TrustRequestPrivate
 A request's shared state; TrustRequest is a handle to it. More...
struct  Sonde::QmlTemplates::ObjectSlot
 An object a template expects, from its header. More...
struct  Sonde::QmlTemplates::ParamSlot
 A setting a template declares, from its header (design 0034). More...
struct  Sonde::QmlTemplates::Header
 A template's header. More...
struct  Sonde::QmlTemplates::CompiledLibrary
 A library compiled into the application as Qt resources: read-only, and needing no trust (design 0034). More...
class  Sonde::QmlTemplates::LibraryGuard
 Checks every file the QML engine loads from a library against the trust store. More...
struct  Sonde::QmlTemplates::LibraryFile
 A template or component found in a library. More...
struct  Sonde::QmlTemplates::TemplateEngine
 What the template tools need from ui_open's windows (qmlwindowtools.cpp). More...
struct  Sonde::QmlTemplates::Locations
 Where the libraries and the trust file are. More...
class  Sonde::QmlTemplates::TrustStore
 The trust store: which file contents the user trusts, and where. More...

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Enumerations

enum class  Sonde::QmlTemplates::Library
 The two libraries.

Functions

Locations Sonde::QmlTemplates::locate ()
 Finds the libraries and the trust file now, searching for the project library above the executable, then above the working directory.
QList< Trust::TrustedFile > Sonde::QmlTemplates::trusted (const QList< TrustFile > &files)
 files as the trust store records them.
std::optional< QJsonObject > Sonde::QmlTemplates::windowParams (const Header *header, const QJsonObject &given, QString *error)
 The settings for a window from header's defaults and the call's given: unknown names and values of another type are errors (design 0034).
QList< CompiledLibrary > Sonde::QmlTemplates::compiledLibraries ()
 The compiled-in libraries, in the order they are searched: the application's, in the order they were added, then Sonde's own.
Expected< void > Sonde::QmlTemplates::registerCompiledLibrary (const QString &name, const QString &root)
 Registers a compiled-in library (addTemplateLibrary()).
std::optional< Header > Sonde::QmlTemplates::parseHeader (const QString &qml, QString *error)
 Reads the header at the top of qml.
bool Sonde::QmlTemplates::isTemplateName (const QString &name)
 Whether name can be a template's name: [a-z0-9][a-z0-9-]*, at most 64.
bool Sonde::QmlTemplates::isComponentName (const QString &name)
 Whether name can be a component's name: a QML type name, at most 64.
bool Sonde::QmlTemplates::isObjectName (const QString &name)
 Whether name can be the name of an object a template is given.
std::optional< LibraryFile > Sonde::QmlTemplates::readCompiledFile (const CompiledLibrary &library, const QString &name, bool component)
 Reads template or component name of compiled-in library library, if it has one by that name.
std::optional< LibraryFile > Sonde::QmlTemplates::findTemplate (const Locations &where, const QString &name)
 Finds template name: in the project library, the user library, then the compiled-in libraries, as ui_open does.
LibraryFile Sonde::QmlTemplates::readLibraryFile (const Locations &where, const QString &name, Library library, bool component)
 Reads template or component name of library, with its header and trust.
bool Sonde::QmlTemplates::checkName (const QString &name, bool component, QString *error)
 Checks that name suits a template, or a component if component.
QString Sonde::QmlTemplates::untrustedReply (const QString &templateName, const QList< TrustFile > &files, const Locations &where)
 The refusal for files, with the commands that trust them.
void Sonde::QmlTemplates::installTemplateTools (Server &server, const TemplateEngine &engine)
 Registers ui_template_list, ui_template_save and ui_template_delete (qmltemplatetools.cpp).
QString Sonde::QmlTemplates::canonicalOrClean (const QString &path)
 path made canonical if it exists, otherwise only absolute and clean.
QString Sonde::QmlTemplates::filePath (const QString &directory, const QString &name, bool component)
 The file of template or component name in directory.
QString Sonde::QmlTemplates::libraryName (Library library)
 "project" or "user".
QString Sonde::QmlTemplates::sha256 (const QByteArray &data)
 The SHA-256 of data, in hex.

Variables

constexpr qsizetype Sonde::QmlTemplates::kMaxFileBytes = qsizetype{ 256 } * 1024
 Most bytes in one template or component.

Detailed Description

The QML template libraries, their headers, and the trust store (design 0023).

Function Documentation

◆ parseHeader()

std::optional< Header > Sonde::QmlTemplates::parseHeader ( const QString & qml,
QString * error )

Reads the header at the top of qml.

Returns
The header, or nothing with error set.

◆ windowParams()

std::optional< QJsonObject > Sonde::QmlTemplates::windowParams ( const Header * header,
const QJsonObject & given,
QString * error )

The settings for a window from header's defaults and the call's given: unknown names and values of another type are errors (design 0034).

Without a header (QML text), given as it is.