1 /*
2  * Copyright (C) 2018 Matthias Fehring <kontakt@buschmann23.de>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 #ifndef C_UTILS_LANGSELECT_P_H
20 #define C_UTILS_LANGSELECT_P_H
21 
22 #include "langselect.h"
23 
24 namespace Cutelyst {
25 
26 class LangSelectPrivate
27 {
28 public:
29     static void _q_postFork(Application *app);
30 
31     void beforePrepareAction(Context *c, bool *skipMethod) const;
32     bool detectLocale(Context *c, LangSelect::Source _source, bool *skipMethod = nullptr) const;
33     bool getFromQuery(Context *c, const QString &key) const;
34     bool getFromCookie(Context *c, const QString &cookie) const;
35     bool getFromSession(Context *c, const QString &key) const;
36     bool getFromSubdomain(Context *c, const QMap<QString, QLocale> &map) const;
37     bool getFromDomain(Context *c, const QMap<QString,QLocale> &map) const;
38     bool getFromHeader(Context *c, const QString &name = QStringLiteral("Accept-Language")) const;
39     void setToQuery(Context *c, const QString &key) const;
40     void setToCookie(Context *c, const QString &name) const;
41     void setToSession(Context *c, const QString &key) const;
42     void setFallback(Context *c) const;
43     void setContentLanguage(Context *c) const;
44 
45     QVector<QLocale> locales;
46     LangSelect::Source source = LangSelect::Fallback;
47     QMap<QString,QLocale> domainMap;
48     QMap<QString,QLocale> subDomainMap;
49     QStringList redirectDomains;
50     QStringList redirectSubDomains;
51     QString queryKey;
52     QString sessionKey;
53     QString cookieName;
54     QString langStashKey = QStringLiteral("c_langselect_lang");
55     QString dirStashKey = QStringLiteral("c_langselect_dir");
56     QLocale fallbackLocale;
57     bool addContentLanguageHeader = true;
58     bool autoDetect = true;
59     bool detectFromHeader = true;
60 };
61 
62 }
63 
64 #endif // C_UTILS_LANGSELECT_P_H
65