QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
TemplateIO Class Reference

Read and write password-store template configuration. More...

#include <templateio.h>

Static Public Member Functions

static auto readTemplates (const QString &storePath) -> QHash< QString, QStringList >
 Read templates from .templates file in password store.
static auto writeTemplates (const QString &storePath, const QHash< QString, QStringList > &templates) -> bool
 Write templates to .templates file in password store.
static auto getFolderTemplate (const QString &folderPath, const QString &storePath) -> QString
 Get default template for a folder. Looks in folder, then parent folders up to root.
static auto secretFieldsIn (const QString &templateText) -> QStringList
 The field names a template marks as secret.
static auto readSecretFields (const QString &storePath) -> QStringList
 The field names the store's .templates file marks as secret, in any of its sections (see secretFieldsIn()).
static auto fieldsIn (const QString &templateText) -> QStringList
 The field names of the template in the settings: one per line, with comment lines (starting with #, such as a # secret: line) left out. Other lines are kept as they are, empty ones too.

Detailed Description

Read and write password-store template configuration.

Extracted from Util. Owns the .templates INI-style file (named template sections with field lists) and the per-folder .default_template lookup used to pick a default template when adding a password.

Definition at line 24 of file templateio.h.

Member Function Documentation

◆ fieldsIn()

auto TemplateIO::fieldsIn ( const QString & templateText) -> QStringList
static

The field names of the template in the settings: one per line, with comment lines (starting with #, such as a # secret: line) left out. Other lines are kept as they are, empty ones too.

Parameters
templateTextThe template's text, newline-separated.
Returns
The field names.

Definition at line 139 of file templateio.cpp.

Here is the caller graph for this function:

◆ getFolderTemplate()

auto TemplateIO::getFolderTemplate ( const QString & folderPath,
const QString & storePath ) -> QString
static

Get default template for a folder. Looks in folder, then parent folders up to root.

Parameters
folderPathPath to folder.
storePathPath to password store root.
Returns
Template name or empty if none found.

Definition at line 176 of file templateio.cpp.

Here is the caller graph for this function:

◆ readSecretFields()

auto TemplateIO::readSecretFields ( const QString & storePath) -> QStringList
static

The field names the store's .templates file marks as secret, in any of its sections (see secretFieldsIn()).

Parameters
storePathPath to password store root.
Returns
The marked names; empty when there is no readable file.

Definition at line 133 of file templateio.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readTemplates()

auto TemplateIO::readTemplates ( const QString & storePath) -> QHash< QString, QStringList >
static

Read templates from .templates file in password store.

Parameters
storePathPath to password store root.
Returns
Hash of template name to field list.

Definition at line 75 of file templateio.cpp.

Here is the caller graph for this function:

◆ secretFieldsIn()

auto TemplateIO::secretFieldsIn ( const QString & templateText) -> QStringList
static

The field names a template marks as secret.

A line # secret: pin, cvv names them, separated by commas; "secret" may be written in any case. It is a comment line, so pass, QtPass 1.8 and the field list skip it. Names are trimmed and empty ones dropped; every other line is ignored. A marked field is hidden like the password (PasswordDisplayPanel), matched by its whole name in any case.

Parameters
templateTextThe text of a template: the store's .templates file or the template in the settings.
Returns
The marked names in the order they appear.

Definition at line 111 of file templateio.cpp.

Here is the caller graph for this function:

◆ writeTemplates()

auto TemplateIO::writeTemplates ( const QString & storePath,
const QHash< QString, QStringList > & templates ) -> bool
static

Write templates to .templates file in password store.

Parameters
storePathPath to password store root.
templatesHash of template name to field list.
Returns
true if write succeeded.

Definition at line 147 of file templateio.cpp.


The documentation for this class was generated from the following files: