File indexing completed on 2024-12-22 04:41:13

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #pragma once
0019 
0020 #include <QObject>
0021 #include <QDateTime>
0022 #include <QNetworkCookie>
0023 
0024 /**
0025  * @brief The class exposing QNetworkCookie to QML
0026  */
0027 class QmlCookie : public QObject
0028 {
0029     Q_OBJECT
0030 
0031     /**
0032      * @brief domain of the cookie
0033      */
0034     Q_PROPERTY(QString domain READ domain CONSTANT)
0035 
0036     /**
0037      * @brief expiration date of the cookie
0038      */
0039     Q_PROPERTY(QDateTime expirationDate READ expirationDate CONSTANT)
0040 
0041     /**
0042      * @brief name of the cookie
0043      */
0044     Q_PROPERTY(QString name READ name CONSTANT)
0045 
0046     /**
0047      * @brief path of the cookie
0048      */
0049     Q_PROPERTY(QString path READ path CONSTANT)
0050 
0051     /**
0052      * @brief checks if cookie is secure
0053      */
0054     Q_PROPERTY(bool secure READ secure CONSTANT)
0055 
0056     /**
0057      * @brief checks if cookie is a session cookie
0058      */
0059     Q_PROPERTY(bool session READ session CONSTANT)
0060 
0061     /**
0062      * @brief value of the cookie
0063      */
0064     Q_PROPERTY(QString value READ value CONSTANT)
0065 public:
0066     explicit QmlCookie(QNetworkCookie *cookie, QObject *parent = nullptr);
0067 
0068 private:
0069     QNetworkCookie *m_cookie = nullptr;
0070 
0071     QString domain() const;
0072     QDateTime expirationDate() const;
0073     QString name() const;
0074     QString path() const;
0075     bool secure() const;
0076     bool session() const;
0077     QString value() const;
0078 };
0079 
0080 Q_DECLARE_METATYPE(QmlCookie*)