MailJDTourDownloadDocsQualityTestsCoverage

Which source lines and branches the tests execute. Lines 91.5 %, branches 75.0 % (minimum 85 % and 72 %). main @ 399ffe3d · 21 October 2026 · pipeline 7238.

GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 1 / 0 / 1
Functions: 100.0% 1 / 0 / 1
Branches: -% 0 / 0 / 0

data/ServiceCatalog.h
Line Branch Exec Source
1 #pragma once
2
3 #include <QByteArray>
4 #include <QList>
5 #include <QRegularExpression>
6 #include <QString>
7 #include <QStringList>
8
9 #include "data/ContactModels.h"
10
11 // Social profile and chat services (Sprint 103 S103.1.2, D-8, I-10).
12 //
13 // The catalog is declarative: resources/contacts/services.json lists each
14 // service with its names (en/de), kind (profile, chat, link), a generic
15 // glyph and URL/handle patterns. recognise() turns a pasted URL or handle
16 // ("https://chaos.social/@ana", "@ana@chaos.social", "@ana:matrix.org") into
17 // a typed value; nothing is ever fetched (D-8). Unknown input that is a URL
18 // stays a "website" link; anything else is not recognised.
19 class ServiceCatalog {
20 public:
21 struct Service {
22 QString id;
23 QString kind; // "profile", "chat", "link"
24 QString glyph; // Material Design Icons name
25 uint codepoint = 0; // its code point (QML Runtime.mdi)
26 QString nameEn;
27 QString nameDe;
28 QStringList aliases;
29 struct Pattern {
30 QRegularExpression match;
31 QString requiredKind; // the pattern applies only in a field of this kind
32 };
33 QList<Pattern> patterns;
34 QString handleTemplate;
35 QString urlTemplate;
36 QString uriTemplate; // chat: the IMPP value written
37 };
38
39 struct Recognised {
40 bool recognised = false;
41 QString service;
42 QString kind;
43 QString handle; // shown on the card
44 QString url; // opened on click (profiles; chat: a web link when one exists)
45 QString value; // stored value (profile: url; chat: IMPP URI)
46 };
47
48 // The built-in catalog from the resource ":/contacts/services.json".
49 static const ServiceCatalog &builtIn();
50 static ServiceCatalog fromJson(const QByteArray &json, QString *error = nullptr);
51
52 3 const QList<Service> &services() const { return m_services; }
53 // nullptr for unknown ids; aliases ("jabber", "fediverse") resolve.
54 const Service *find(const QString &id) const;
55 // The services offered for a field kind ("profile" or "chat"), catalog order.
56 QStringList idsForKind(const QString &kind) const;
57 // `kindHint` is the editor field the input came from ("profile", "chat"
58 // or "" for any); it enables chat-only patterns such as a bare
59 // "user@server" for XMPP.
60 Recognised recognise(const QString &input, const QString &kindHint = {}) const;
61 // Card display of a stored value: service name, handle and link.
62 QString displayName(const QString &serviceId, const QString &language = {}) const;
63 Recognised describe(const ContactSocial &social) const;
64 // A stored ContactSocial for a recognised input (sourceIndex -1).
65 static ContactSocial toSocial(const Recognised &recognised);
66
67 private:
68 QList<Service> m_services;
69 };
70