TreeFrogFramework: TActionController Class Reference
#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 |
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.
◆ ~TActionController()
|
virtual |
Destructor.
◆ activeAction()
|
inlineoverridevirtual |
◆ addCookie() [1/3]
|
overrideprotectedvirtual |
◆ addCookie() [2/3]
|
overrideprotectedvirtual |
◆ addCookie() [3/3]
|
overrideprotectedvirtual |
◆ arguments()
|
inlineoverridevirtual |
◆ authenticityToken()
|
overridevirtual |
◆ availableControllers()
|
static |
Returns the list of all available controllers.
◆ clientAddress()
| QHostAddress TActionController::clientAddress | ( | ) | const |
Returns the client address of the current session.
◆ closeWebSokcet()
|
protected |
◆ contentType()
|
inlineprotected |
Returns the content type for a response message.
◆ csrfProtectionEnabled()
|
inlinevirtual |
Must be overridden by subclasses to disable CSRF protection.
The function must return false to disable the protection. This function returns true.
◆ disabledControllers()
|
static |
◆ exceptionActionsOfCsrfProtection()
|
inlinevirtual |
Must be overridden by subclasses to return a string list of actions excluded from CSRF protection when the protection is enabled.
- See also
- csrfProtectionEnabled()
◆ flash()
|
inline |
Returns the flash message for name.
- See also
- setFlash()
◆ flushResponse()
|
protected |
Sends a response immediately, and then allows time-consuming processing to continue in the controller.
◆ getRenderingData()
|
overridevirtual |
Returns the rendering data of the partial template given by templateName.
Reimplemented from TAbstractController.
◆ httpRequest() [1/2]
|
inlineprotected |
◆ httpRequest() [2/2]
|
inlineoverridevirtual |
◆ httpResponse() [1/2]
|
inlineprotected |
Returns a HTTP response to be sent.
◆ httpResponse() [2/2]
|
inline |
Returns a HTTP response to be sent.
◆ identityKeyOfLoginUser()
|
virtual |
Returns the identity key of the user, i.e., TAbstractUser object, logged in.
This is a virtual function.
- See also
- userLogin()
◆ isUserLoggedIn()
|
overridevirtual |
Returns true if a user is logged in to the system; otherwise returns false.
This is a virtual function.
- See also
- userLogin()
Reimplemented from TAbstractController.
◆ layout()
|
inlineprotected |
Returns the name of the layout template.
- See also
- setLayout()
◆ layoutEnabled()
|
inlineprotected |
Returns true if the layout mechanism is enabled; otherwise returns false.
- See also
- setLayoutEnabled()
◆ loginUserNameKey()
|
static |
◆ name()
|
overridevirtual |
◆ postFilter()
|
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.
◆ preFilter()
|
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.
◆ publish() [1/2]
|
protected |
◆ publish() [2/2]
|
protected |
◆ redirect()
|
protected |
Redirects to the URL url.
◆ removeCache()
|
protected |
◆ render()
|
protected |
Renders the template of the action action with the layout layout.
◆ renderAndCache()
|
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.
- See also
- render()
- renderOnCache()
- removeCache()
◆ renderCbor() [1/6]
|
protected |
Renders a CBOR array as HTTP response.
◆ renderCbor() [2/6]
|
protected |
Renders a CBOR map as HTTP response.
◆ renderCbor() [3/6]
|
protected |
Renders a CBOR value as HTTP response.
◆ renderCbor() [4/6]
|
protected |
Renders a CBOR object variant as HTTP response.
◆ renderCbor() [5/6]
|
protected |
Renders a CBOR object hash as HTTP response.
◆ renderCbor() [6/6]
|
protected |
Renders a CBOR object map as HTTP response.
◆ renderErrorResponse()
|
protected |
Renders a static error page with the status code, which page is [statusCode].html in the public directory.
◆ renderJson() [1/6]
|
protected |
Renders the JSON array array as HTTP response.
◆ renderJson() [2/6]
|
protected |
Renders the JSON document document as HTTP response.
◆ renderJson() [3/6]
|
protected |
Renders the JSON object object as HTTP response.
◆ renderJson() [4/6]
|
protected |
Renders the list as a JSON array.
◆ renderJson() [5/6]
|
protected |
Renders the list as a JSON array.
◆ renderJson() [6/6]
|
protected |
Renders the map as a JSON object.
◆ renderOnCache()
|
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.
- See also
- renderAndCache()
◆ renderTemplate()
|
protected |
Renders the template given by templateName with the layout layout.
◆ renderText()
|
protected |
Renders the text text with the layout layout.
◆ renderXml() [1/4]
|
protected |
Renders the XML document document.
◆ renderXml() [2/4]
|
protected |
Renders the list of strings list as XML document.
◆ renderXml() [3/4]
|
protected |
Renders the list of variants list as XML document.
◆ renderXml() [4/4]
|
protected |
Renders the map as XML document.
◆ request() [1/2]
Returns the HTTP request being executed.
◆ request() [2/2]
|
overridevirtual |
◆ reset()
|
overridevirtual |
◆ response()
|
inline |
◆ rollbackTransaction()
|
inlineprotected |
This function is called to rollback a transaction on the database.
◆ sendBinaryToWebSocket()
|
protected |
◆ sendData()
|
protected |
Sends the data data as HTTP response.
◆ sendFile()
|
protected |
Sends the file filePath as HTTP response.
◆ sendTextToWebSocket()
|
protected |
◆ session() [1/2]
|
inlineoverridevirtual |
◆ session() [2/2]
|
inlineoverrideprotectedvirtual |
◆ sessionEnabled()
|
inlinevirtual |
Must be overridden by subclasses to enable a HTTP session.
The function must return false to disable a session. This function returns true.
- See also
- session()
◆ setAccessRules()
|
inlineprotectedvirtual |
◆ setAutoRemove()
|
protected |
Sets the automatically removing file.
The file filePath is removed when the context is extinguished, after replied the HTTP response.
◆ setContentType()
|
inlineprotected |
Sets the content type specified by type for a response message.
◆ setCsrfProtectionInto()
|
static |
Sets CSRF protection informaion into session.
Internal use.
◆ setFlash()
|
overridevirtual |
◆ setFlashValidationErrors()
|
protected |
Sets the validation errors to flash variant.
◆ setLayout()
|
protected |
Sets the layout template to layout.
- See also
- layout()
◆ setLayoutDisabled()
|
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.
- See also
- layoutEnabled()
◆ setLayoutEnabled()
|
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.
- See also
- layoutEnabled()
◆ setSession()
|
protected |
Sets the HTTP session to session.
◆ setStatusCode()
|
inlineprotected |
◆ statusCode()
|
inlineprotected |
Returns the status code of the HTTP response to be sent.
- See also
- setStatusCode()
◆ transactionEnabled()
|
inlinevirtual |
Must be overridden by subclasses to disable transaction mechanism.
The function must return false to disable the mechanism. This function returns true.
◆ userLogin()
|
protectedvirtual |
◆ userLogout()
|
protectedvirtual |
◆ validateAccess()
|
protected |
◆ TActionContext
|
friend class TActionContext |
friend |
◆ TSessionCookieStore
|
friend class TSessionCookieStore |
friend |
The documentation for this class was generated from the following files:
Public Member Functions inherited from