/* The session's stored images as a QML image provider: * * image://cstattach/ (see cst_attach.h: "img-1a2b3c4d.png") * * The files live in the current session's attachment directory, which is what * AgentCore::attachmentDir() names. Only that directory is served, and only * names that pass the engine's own cst_attach_rel_ok() -- a transcript can * carry hand-edited JSON, and nothing in it may reach outside the store. * * requestImage() runs on Quick's render thread while setDir() comes from the * window's thread, hence the mutex. */ #ifndef CST_APP_SESSION_IMAGES_H #define CST_APP_SESSION_IMAGES_H #include #include #include #include class QQmlApplicationEngine; namespace app { class SessionImages : public QQuickImageProvider { public: SessionImages(); /* The directory holding the current session's images; "" disables serving. */ void setDir(const QString &dir); QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override; private: mutable QMutex m_mu; QString m_dir; }; /* Registers image://cstattach/ on the engine and hands the provider back, so * the caller can keep its directory in step with the agent's session. */ SessionImages *installSessionImages(QQmlApplicationEngine *engine); } // namespace app #endif // CST_APP_SESSION_IMAGES_H