8 #include <QtCore/QObject>
42 UriResolveResult visitResource(Connection* account,
const Uri& uri);
45 virtual ~UriResolverBase() = 0;
52 virtual UriResolveResult visitUser(User* user [[maybe_unused]],
53 const QString& action [[maybe_unused]])
55 return IncorrectAction;
59 virtual void visitRoom(Room* room [[maybe_unused]],
60 const QString& eventId [[maybe_unused]])
65 virtual void joinRoom(Connection* account [[maybe_unused]],
66 const QString& roomAliasOrId [[maybe_unused]],
67 const QStringList& viaServers [[maybe_unused]] = {})
76 virtual bool visitNonMatrix(
const QUrl& url [[maybe_unused]])
109 visitResource(Connection* account,
const Uri& uri,
110 std::function<UriResolveResult(User*, QString)> userHandler,
111 std::function<
void(Room*, QString)> roomEventHandler,
112 std::function<
void(Connection*, QString, QStringList)> joinHandler,
113 std::function<
bool(
const QUrl&)> nonMatrixHandler);
116 inline UriResolveResult checkResource(Connection* account,
const Uri& uri)
118 return visitResource(
119 account, uri, [](
auto,
auto) {
return UriResolved; }, [](
auto,
auto) {},
120 [](
auto,
auto,
auto) {}, [](
auto) {
return false; });
144 class QUOTIENT_API UriDispatcher :
public QObject,
public UriResolverBase {
147 explicit UriDispatcher(QObject* parent =
nullptr) : QObject(parent) {}
150 Q_INVOKABLE UriResolveResult resolveResource(Connection* account,
153 return UriResolverBase::visitResource(account, uri);
158 void userAction(Quotient::User* user, QString action);
161 void roomAction(Quotient::Room* room, QString eventId);
164 void joinAction(Quotient::Connection* account, QString roomAliasOrId,
165 QStringList viaServers);
168 void nonMatrixAction(QUrl url);
171 UriResolveResult visitUser(User* user,
const QString& action) override;
172 void visitRoom(Room* room,
const QString& eventId) override;
173 void joinRoom(Connection* account,
const QString& roomAliasOrId,
174 const QStringList& viaServers = {}) override;
175 bool visitNonMatrix(
const QUrl& url) override;