libQuotient
A Qt library for building matrix clients
Quotient::UriResolverBase Class Referenceabstract

Abstract class to resolve the resource and act on it. More...

#include <uriresolver.h>

Inheritance diagram for Quotient::UriResolverBase:

Public Member Functions

UriResolveResult visitResource (Connection *account, const Uri &uri)
 Resolve the resource and dispatch an action depending on its type. More...
 

Protected Member Functions

virtual ~UriResolverBase ()=0
 
virtual UriResolveResult visitUser (User *user[[maybe_unused]], const QString &action[[maybe_unused]])
 Called by visitResource() when the passed URI identifies a Matrix user. More...
 
virtual void visitRoom (Room *room[[maybe_unused]], const QString &eventId[[maybe_unused]])
 
virtual void joinRoom (Connection *account[[maybe_unused]], const QString &roomAliasOrId[[maybe_unused]], const QStringList &viaServers[[maybe_unused]]={})
 
virtual bool visitNonMatrix (const QUrl &url[[maybe_unused]])
 Called by visitResource() when the passed URI has type() == NonMatrix More...
 

Detailed Description

Abstract class to resolve the resource and act on it.

This class encapsulates the logic of resolving a Matrix identifier or URI into a Quotient object (or objects) and calling an appropriate handler on it. It is a type-safe way of handling a URI with no prior context on its type in cases like, e.g., when a user clicks on a URI in the application.

This class provides empty "handlers" for each type of URI to facilitate gradual implementation. Derived classes are encouraged to override as many of them as possible.

Definition at line 28 of file uriresolver.h.

Constructor & Destructor Documentation

◆ ~UriResolverBase()

virtual Quotient::UriResolverBase::~UriResolverBase ( )
protectedpure virtual

Member Function Documentation

◆ joinRoom()

virtual void Quotient::UriResolverBase::joinRoom ( Connection *account]  [[maybe_unused],
const QString &roomAliasOrId]  [[maybe_unused],
const QStringList &viaServers]  [[maybe_unused] = {} 
)
inlineprotectedvirtual

Called by visitResource() when the passed URI has action() == "join" and identifies a room that the user defined by the Connection argument is not a member of

Definition at line 65 of file uriresolver.h.

◆ visitNonMatrix()

virtual bool Quotient::UriResolverBase::visitNonMatrix ( const QUrl &url]  [[maybe_unused])
inlineprotectedvirtual

Called by visitResource() when the passed URI has type() == NonMatrix

Should return true if the URI is considered resolved, false otherwise. A basic implementation in a graphical client can look like return QDesktopServices::openUrl(url); but it's strongly advised to ask for a user confirmation beforehand.

Definition at line 76 of file uriresolver.h.

◆ visitResource()

UriResolveResult Quotient::UriResolverBase::visitResource ( Connection account,
const Uri uri 
)

Resolve the resource and dispatch an action depending on its type.

This method:

  1. Resolves uri into an actual object (e.g., Room or User), with possible additional data such as event id, in the context of account.
  2. If the resolving is successful, depending on the type of the object, calls the appropriate virtual function (defined in a derived concrete class) to perform an action on the resource (open a room, mention a user etc.).
  3. Returns the result of resolving the resource.

◆ visitRoom()

virtual void Quotient::UriResolverBase::visitRoom ( Room *room]  [[maybe_unused],
const QString &eventId]  [[maybe_unused] 
)
inlineprotectedvirtual

Called by visitResource() when the passed URI identifies a room or an event in a room

Definition at line 59 of file uriresolver.h.

◆ visitUser()

virtual UriResolveResult Quotient::UriResolverBase::visitUser ( User *user]  [[maybe_unused],
const QString &action]  [[maybe_unused] 
)
inlineprotectedvirtual

Called by visitResource() when the passed URI identifies a Matrix user.

Returns
IncorrectAction if the action is not correct or not supported; UriResolved if it is accepted; other values are disallowed

Definition at line 52 of file uriresolver.h.


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