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 #include "qmlcookie.h"
0019 #include <QQmlEngine>
0020 
0021 QmlCookie::QmlCookie(QNetworkCookie *cookie, QObject *parent)
0022     : QObject(parent)
0023     , m_cookie(cookie)
0024 {
0025     QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
0026 }
0027 
0028 QString QmlCookie::domain() const
0029 {
0030     if (!m_cookie) {
0031         return {};
0032     }
0033     return m_cookie->domain();
0034 }
0035 
0036 QDateTime QmlCookie::expirationDate() const
0037 {
0038     if (!m_cookie) {
0039         return {};
0040     }
0041     return m_cookie->expirationDate();
0042 }
0043 
0044 QString QmlCookie::name() const
0045 {
0046     if (!m_cookie) {
0047         return {};
0048     }
0049     return QString(QString::fromUtf8(m_cookie->name()));
0050 }
0051 
0052 QString QmlCookie::path() const
0053 {
0054     if (!m_cookie) {
0055         return {};
0056     }
0057     return m_cookie->path();
0058 }
0059 
0060 bool QmlCookie::secure() const
0061 {
0062     if (!m_cookie) {
0063         return false;
0064     }
0065     return m_cookie->isSecure();
0066 }
0067 
0068 bool QmlCookie::session() const
0069 {
0070     if (!m_cookie) {
0071         return false;
0072     }
0073     return m_cookie->isSessionCookie();
0074 }
0075 
0076 QString QmlCookie::value() const
0077 {
0078     if (!m_cookie) {
0079         return {};
0080     }
0081     return QString(QString::fromUtf8(m_cookie->value()));
0082 }