-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #99. Added language and token update in Survey Editor
- Loading branch information
Showing
10 changed files
with
81 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "WebPageRequestInterceptor.h" | ||
#include "Utils.h" | ||
|
||
WebPageRequestInterceptor::WebPageRequestInterceptor(bool inject_client, QObject *p) : | ||
QWebEngineUrlRequestInterceptor(p) | ||
,m_injectClient(inject_client) | ||
{ | ||
// Cache OS information | ||
if (m_injectClient){ | ||
m_osName = Utils::getOsName(); | ||
m_osVersion = Utils::getOsVersion(); | ||
} | ||
} | ||
|
||
WebPageRequestInterceptor::~WebPageRequestInterceptor() | ||
{ | ||
|
||
} | ||
|
||
void WebPageRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) | ||
{ | ||
// Inject client name and version | ||
if (m_injectClient){ | ||
info.setHttpHeader("X-Client-Name", QByteArray(OPENTERAPLUS_CLIENT_NAME)); | ||
info.setHttpHeader("X-Client-Version", QByteArray(OPENTERAPLUS_VERSION)); | ||
info.setHttpHeader("X-OS-Name", m_osName.toUtf8()); | ||
info.setHttpHeader("X-OS-Version", m_osVersion.toUtf8()); | ||
} | ||
|
||
// Inject required language | ||
QString localeString = QLocale().bcp47Name(); | ||
//qDebug() << "localeString : " << localeString; | ||
info.setHttpHeader(QByteArray("Accept-Language"), localeString.toUtf8()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef WEBPAGEREQUESTINTERCEPTOR_H | ||
#define WEBPAGEREQUESTINTERCEPTOR_H | ||
|
||
#include <QObject> | ||
#include <QWebEngineUrlRequestInterceptor> | ||
|
||
class WebPageRequestInterceptor : public QWebEngineUrlRequestInterceptor | ||
{ | ||
Q_OBJECT | ||
public: | ||
WebPageRequestInterceptor(bool inject_client = false, QObject *p = nullptr); | ||
~WebPageRequestInterceptor(); | ||
void interceptRequest(QWebEngineUrlRequestInfo &info) override; | ||
private: | ||
QString m_osName; | ||
QString m_osVersion; | ||
bool m_injectClient = false; | ||
}; | ||
|
||
#endif // WEBPAGEREQUESTINTERCEPTOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters