TreeFrogFramework
2.8
|
#include <tactioncontroller.h>
Public Member Functions | |
TActionController () | |
virtual | ~TActionController () |
QString | name () const override |
QString | activeAction () const override |
QStringList | arguments () const override |
const THttpRequest & | request () const override |
const THttpRequest & | httpRequest () const override |
const THttpResponse & | response () const |
const THttpResponse & | httpResponse () const |
const TSession & | session () const override |
QString | getRenderingData (const QString &templateName, const QVariantMap &vars=QVariantMap()) override |
virtual bool | sessionEnabled () const |
virtual bool | csrfProtectionEnabled () const |
virtual QStringList | exceptionActionsOfCsrfProtection () const |
virtual bool | transactionEnabled () const |
QByteArray | authenticityToken () const override |
QString | flash (const QString &name) const |
QHostAddress | clientAddress () const |
virtual bool | isUserLoggedIn () const override |
virtual QString | identityKeyOfLoginUser () const |
void | setFlash (const QString &name, const QVariant &value) override |
void | reset () override |
Public Member Functions inherited from TAbstractController | |
TAbstractController () | |
virtual | ~TAbstractController () |
virtual QString | className () const |
void | exportVariant (const QString &name, const QVariant &value, bool overwrite=true) |
const TActionContext * | context () const |
TActionContext * | context () |
void | setContext (TActionContext *context) |
Public Member Functions inherited from TActionHelper | |
virtual | ~TActionHelper () |
QUrl | url (const QString &controller=QString(), const QString &action=QString(), const QStringList &args=QStringList(), const QVariantMap &query=QVariantMap()) const |
QUrl | url (const QString &controller, const QString &action, const QStringList &args, const QString &query) const |
QUrl | url (const QString &controller, const QString &action, int arg) const |
QUrl | url (const QString &controller, const QString &action, uint arg) const |
QUrl | url (const QString &controller, const QString &action, int64_t arg) const |
QUrl | url (const QString &controller, const QString &action, uint64_t arg) const |
QUrl | url (const QString &controller, const QString &action, const QString &arg) const |
QUrl | url (const QString &controller, const QString &action, const QVariant &arg) const |
QUrl | url (const QString &controller, const QString &action, const QVariantMap &query) const |
QUrl | urla (const QString &action=QString(), const QStringList &args=QStringList(), const QVariantMap &query=QVariantMap()) const |
QUrl | urla (const QString &action, const QStringList &args, const QString &query) const |
QUrl | urla (const QString &action, int arg) const |
QUrl | urla (const QString &action, uint arg) const |
QUrl | urla (const QString &action, int64_t arg) const |
QUrl | urla (const QString &action, uint64_t arg) const |
QUrl | urla (const QString &action, const QString &arg) const |
QUrl | urla (const QString &action, const QVariant &arg) const |
QUrl | urla (const QString &action, const QVariantMap &query) const |
QUrl | urlq (const QVariantMap &query) const |
QUrl | urlq (const QString &query) const |
Static Public Member Functions | |
static void | setCsrfProtectionInto (TSession &session) |
static const QStringList & | availableControllers () |
static const QStringList & | disabledControllers () |
static QString | loginUserNameKey () |
Static Public Member Functions inherited from TAbstractController | |
static QThread * | currentThread () |
Protected Member Functions | |
virtual bool | preFilter () |
virtual void | postFilter () |
void | setLayoutEnabled (bool enable) |
void | setLayoutDisabled (bool disable) |
bool | layoutEnabled () const |
void | setLayout (const QString &layout) |
QString | layout () const |
void | setStatusCode (int code) |
int | statusCode () const |
void | setFlashValidationErrors (const TFormValidator &validator, const QString &prefix=QString("err_")) |
TSession & | session () override |
void | setSession (const TSession &session) |
bool | addCookie (const TCookie &cookie) override |
bool | addCookie (const QByteArray &name, const QByteArray &value, const QDateTime &expire=QDateTime(), const QString &path=QString(), const QString &domain=QString(), bool secure=false, bool httpOnly=false, const QByteArray &sameSite="Lax") override |
bool | addCookie (const QByteArray &name, const QByteArray &value, int64_t maxAge, const QString &path=QString(), const QString &domain=QString(), bool secure=false, bool httpOnly=false, const QByteArray &sameSite="Lax") override |
QByteArray | contentType () const |
void | setContentType (const QByteArray &type) |
bool | render (const QString &action=QString(), const QString &layout=QString()) |
bool | renderTemplate (const QString &templateName, const QString &layout=QString()) |
bool | renderText (const QString &text, bool layoutEnable=false, const QString &layout=QString()) |
bool | renderXml (const QDomDocument &document) |
bool | renderXml (const QVariantMap &map) |
bool | renderXml (const QVariantList &list) |
bool | renderXml (const QStringList &list) |
bool | renderJson (const QJsonDocument &document) |
bool | renderJson (const QJsonObject &object) |
bool | renderJson (const QJsonArray &array) |
bool | renderJson (const QVariantMap &map) |
bool | renderJson (const QVariantList &list) |
bool | renderJson (const QStringList &list) |
bool | renderAndCache (const QByteArray &key, int seconds, const QString &action=QString(), const QString &layout=QString()) |
bool | renderOnCache (const QByteArray &key) |
void | removeCache (const QByteArray &key) |
bool | renderCbor (const QVariant &variant, QCborValue::EncodingOptions opt=QCborValue::NoTransformation) |
bool | renderCbor (const QVariantMap &map, QCborValue::EncodingOptions opt=QCborValue::NoTransformation) |
bool | renderCbor (const QVariantHash &hash, QCborValue::EncodingOptions opt=QCborValue::NoTransformation) |
bool | renderCbor (const QCborValue &value, QCborValue::EncodingOptions opt=QCborValue::NoTransformation) |
bool | renderCbor (const QCborMap &map, QCborValue::EncodingOptions opt=QCborValue::NoTransformation) |
bool | renderCbor (const QCborArray &array, QCborValue::EncodingOptions opt=QCborValue::NoTransformation) |
bool | renderErrorResponse (int statusCode) |
void | redirect (const QUrl &url, int statusCode=Tf::Found) |
bool | sendFile (const QString &filePath, const QByteArray &contentType, const QString &name=QString(), bool autoRemove=false) |
bool | sendData (const QByteArray &data, const QByteArray &contentType, const QString &name=QString()) |
void | rollbackTransaction () |
void | setAutoRemove (const QString &filePath) |
bool | validateAccess (const TAbstractUser *user) |
void | sendTextToWebSocket (int socket, const QString &text) |
void | sendBinaryToWebSocket (int socket, const QByteArray &binary) |
void | closeWebSokcet (int socket, int closeCode=Tf::NormalClosure) |
void | publish (const QString &topic, const QString &text) |
void | publish (const QString &topic, const QByteArray &binary) |
void | flushResponse () |
virtual bool | userLogin (const TAbstractUser *user) |
virtual void | userLogout () |
virtual void | setAccessRules () |
THttpRequest & | request () |
THttpRequest & | httpRequest () |
THttpResponse & | httpResponse () |
Protected Member Functions inherited from TAbstractController | |
QVariant | variant (const QString &name) const |
void | exportVariants (const QVariantMap &map) |
void | exportValidationErrors (const TFormValidator &validator, const QString &prefix=QString("err_")) |
bool | hasVariant (const QString &name) const |
const QVariantMap & | allVariants () const |
QString | viewClassName (const QString &action=QString()) const |
QString | viewClassName (const QString &contoller, const QString &action) const |
Protected Member Functions inherited from TAccessValidator | |
void | addRules (int type, const QString &key, const QStringList &actions, bool allow) |
TAccessValidator () | |
virtual | ~TAccessValidator () |
void | setAllowDefault (bool allow=true) |
void | setDenyDefault (bool deny=true) |
void | setAllowGroup (const QString &groupKey, const QString &action) |
void | setAllowGroup (const QString &groupKey, const QStringList &actions) |
void | setDenyGroup (const QString &groupKey, const QString &action) |
void | setDenyGroup (const QString &groupKey, const QStringList &actions) |
void | setAllowUser (const QString &identityKey, const QString &action) |
void | setAllowUser (const QString &identityKey, const QStringList &actions) |
void | setDenyUser (const QString &identityKey, const QString &action) |
void | setDenyUser (const QString &identityKey, const QStringList &actions) |
void | setAllowUnauthenticatedUser (const QString &action) |
void | setAllowUnauthenticatedUser (const QStringList &actions) |
void | setDenyUnauthenticatedUser (const QString &action) |
void | setDenyUnauthenticatedUser (const QStringList &actions) |
void | clear () |
virtual bool | validate (const TAbstractUser *user, const TActionController *controller) const |
Friends | |
class | TActionContext |
class | TSessionCookieStore |
Additional Inherited Members | |
Protected Attributes inherited from TAccessValidator | |
bool | allowDefault {true} |
QList< AccessRule > | accessRules |
The TActionController class is the base class of all action controllers.
TActionController::TActionController | ( | ) |
Constructor.
|
virtual |
Destructor.
|
inlineoverridevirtual |
Returns the active action name.
Implements TAbstractController.
|
overrideprotectedvirtual |
Adds the cookie to the internal list of cookies.
Reimplemented from TAbstractController.
|
overrideprotectedvirtual |
Reimplemented from TAbstractController.
|
overrideprotectedvirtual |
Adds the cookie to the internal list of cookies.
Reimplemented from TAbstractController.
|
inlineoverridevirtual |
Reimplemented from TAbstractController.
|
overridevirtual |
Returns the authenticity token.
Reimplemented from TAbstractController.
|
static |
Returns the list of all available controllers.
QHostAddress TActionController::clientAddress | ( | ) | const |
Returns the client address of the current session.
|
protected |
|
inlineprotected |
Returns the content type for a response message.
|
inlinevirtual |
Must be overridden by subclasses to disable CSRF protection.
The function must return false to disable the protection. This function returns true.
|
static |
|
inlinevirtual |
Must be overridden by subclasses to return a string list of actions excluded from CSRF protection when the protection is enabled.
|
inline |
Returns the flash message for name.
|
protected |
Sends a response immediately, and then allows time-consuming processing to continue in the controller.
|
overridevirtual |
Returns the rendering data of the partial template given by templateName.
Reimplemented from TAbstractController.
|
inlineprotected |
|
inlineoverridevirtual |
Reimplemented from TAbstractController.
|
inlineprotected |
Returns a HTTP response to be sent.
|
inline |
Returns a HTTP response to be sent.
|
virtual |
Returns the identity key of the user, i.e., TAbstractUser object, logged in.
This is a virtual function.
|
overridevirtual |
Returns true if a user is logged in to the system; otherwise returns false.
This is a virtual function.
Reimplemented from TAbstractController.
|
inlineprotected |
Returns the name of the layout template.
|
inlineprotected |
Returns true if the layout mechanism is enabled; otherwise returns false.
|
static |
|
overridevirtual |
Returns the controller name.
Implements TAbstractController.
|
inlineprotectedvirtual |
This function is called after actions on the controller are performed.
Can be overridden by subclasses (controllers) in order to post-processing of actions on the controller.
|
inlineprotectedvirtual |
This function is called before actions on the controller are performed, therefore can be overridden by subclasses (controllers) to filter a HTTP request.
If the function returns false, a action on the controller is not executed.
|
protected |
|
protected |
|
protected |
Redirects to the URL url.
|
protected |
Removes the template with the key from the cache.
|
protected |
Renders the template of the action action with the layout layout.
|
protected |
Renders the template of the action with the layout and caches it with the key for seconds.
To use this function, enable cache module in application.ini.
|
protected |
Renders a CBOR array as HTTP response.
|
protected |
Renders a CBOR map as HTTP response.
|
protected |
Renders a CBOR value as HTTP response.
|
protected |
Renders a CBOR object variant as HTTP response.
|
protected |
Renders a CBOR object hash as HTTP response.
|
protected |
Renders a CBOR object map as HTTP response.
|
protected |
Renders a static error page with the status code, which page is [statusCode].html in the public directory.
|
protected |
Renders the JSON array array as HTTP response.
|
protected |
Renders the JSON document document as HTTP response.
|
protected |
Renders the JSON object object as HTTP response.
|
protected |
Renders the list as a JSON array.
|
protected |
Renders the list as a JSON array.
|
protected |
Renders the map as a JSON object.
|
protected |
Renders the template cached with the key.
If no item with the key found, returns false. To use this function, enable cache module in application.ini.
|
protected |
Renders the template given by templateName with the layout layout.
|
protected |
Renders the text text with the layout layout.
|
protected |
Renders the XML document document.
|
protected |
Renders the list of strings list as XML document.
|
protected |
Renders the list of variants list as XML document.
|
protected |
Renders the map as XML document.
|
protected |
Returns the HTTP request being executed.
|
overridevirtual |
Returns the HTTP request being executed.
Reimplemented from TAbstractController.
|
overridevirtual |
Reimplemented from TAbstractController.
|
inline |
|
inlineprotected |
This function is called to rollback a transaction on the database.
|
protected |
|
protected |
Sends the data data as HTTP response.
|
protected |
Sends the file filePath as HTTP response.
|
protected |
|
inlineoverridevirtual |
Returns the current HTTP session, allows associating information with individual visitors.
Reimplemented from TAbstractController.
|
inlineoverrideprotectedvirtual |
Returns the current HTTP session, allows associating information with individual visitors.
Reimplemented from TAbstractController.
|
inlinevirtual |
Must be overridden by subclasses to enable a HTTP session.
The function must return false to disable a session. This function returns true.
|
inlineprotectedvirtual |
Sets rules of access to this controller.
|
protected |
Sets the automatically removing file.
The file filePath is removed when the context is extinguished, after replied the HTTP response.
|
inlineprotected |
Sets the content type specified by type for a response message.
|
static |
Sets CSRF protection informaion into session.
Internal use.
|
overridevirtual |
|
protected |
Sets the validation errors to flash variant.
|
protected |
Sets the layout template to layout.
|
inlineprotected |
Disables the layout mechanism if disable is true, otherwise enables it.
By default the layout mechanism is enabled, and a HTML response is generated with using the current layout.
|
inlineprotected |
Enables the layout mechanism if enable is true, otherwise disables it.
By default the layout mechanism is enabled, and a HTML response is generated with using the current layout.
|
protected |
Sets the HTTP session to session.
|
inlineprotected |
Sets the status code to code.
|
inlineprotected |
Returns the status code of the HTTP response to be sent.
|
inlinevirtual |
Must be overridden by subclasses to disable transaction mechanism.
The function must return false to disable the mechanism. This function returns true.
|
protectedvirtual |
|
protectedvirtual |
|
protected |
Validates the access of the user user.
Returns true if the user access is allowed by rule; otherwise returns false.
|
friend |
|
friend |