File indexing completed on 2024-04-28 04:58:10

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
0004     SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef BROWSERARGUMENTS_H
0010 #define BROWSERARGUMENTS_H
0011 
0012 #include <libkonq_export.h>
0013 
0014 #include <QByteArray>
0015 #include <QStringList>
0016 
0017 # if QT_VERSION_MAJOR == 6
0018 
0019 struct BrowserArgumentsPrivate;
0020 
0021 /**
0022  * @struct BrowserArguments browserarguments.h
0023  *
0024  * @short BrowserArguments is a set of web-browsing-specific arguments,
0025  * which allow specifying how a URL should be opened by openUrl()
0026  * (as a complement to KParts::OpenUrlArguments which are the non-web-specific arguments)
0027  *
0028  * The arguments remain stored in the browser extension after that,
0029  * and can be used for instance to jump to the xOffset/yOffset position
0030  * once the url has finished loading.
0031  *
0032  * The parts (with a browser extension) who care about urlargs will
0033  * use those arguments, others will ignore them.
0034  *
0035  * This can also be used the other way round, when a part asks
0036  * for a URL to be opened (with openUrlRequest or createNewWindow).
0037  */
0038 struct LIBKONQ_EXPORT BrowserArguments {
0039     //TODO KF6: when dropping compatibility with KF5, add a suggestedFileName entry
0040     //to be used for downloads and possibly an id for DownloaderJob
0041     BrowserArguments();
0042     BrowserArguments(const BrowserArguments &args);
0043     BrowserArguments &operator=(const BrowserArguments &args);
0044 
0045     virtual ~BrowserArguments();
0046 
0047     /**
0048      * This buffer can be used by the part to save and restore its contents.
0049      * See KHTMLPart for instance.
0050      */
0051     QStringList docState;
0052 
0053     /**
0054      * @p softReload is set when user just hits reload button. It's used
0055      * currently for two different frameset reload strategies. In case of
0056      * soft reload individual frames are reloaded instead of reloading whole
0057      * frameset.
0058      */
0059     bool softReload;
0060 
0061     /**
0062      * KHTML-specific field, contents of the HTTP POST data.
0063      */
0064     QByteArray postData;
0065 
0066     /**
0067      * KHTML-specific field, header defining the type of the POST data.
0068      */
0069     void setContentType(const QString &contentType);
0070     /**
0071      * KHTML-specific field, header defining the type of the POST data.
0072      */
0073     QString contentType() const;
0074     /**
0075      * KHTML-specific field, whether to do a POST instead of a GET,
0076      * for the next openURL.
0077      */
0078     void setDoPost(bool enable);
0079 
0080     /**
0081      * KHTML-specific field, whether to do a POST instead of a GET,
0082      * for the next openURL.
0083      */
0084     bool doPost() const;
0085 
0086     /**
0087      * Whether to lock the history when opening the next URL.
0088      * This is used during e.g. a redirection, to avoid a new entry
0089      * in the history.
0090      */
0091     void setLockHistory(bool lock);
0092     bool lockHistory() const;
0093 
0094     /**
0095      * Whether the URL should be opened in a new tab instead in a new window.
0096      */
0097     void setNewTab(bool newTab);
0098     bool newTab() const;
0099 
0100     /**
0101      * The frame in which to open the URL. KHTML/Konqueror-specific.
0102      */
0103     QString frameName;
0104 
0105     /**
0106      * If true, the part who asks for a URL to be opened can be 'trusted'
0107      * to execute applications. For instance, the directory views can be
0108      * 'trusted' whereas HTML pages are not trusted in that respect.
0109      */
0110     bool trustedSource;
0111 
0112     /**
0113      * @return true if the request was a result of a META refresh/redirect request or
0114      * HTTP redirect.
0115      */
0116     bool redirectedRequest() const;
0117 
0118     /**
0119      * Set the redirect flag to indicate URL is a result of either a META redirect
0120      * or HTTP redirect.
0121      *
0122      * @param redirected
0123      */
0124     void setRedirectedRequest(bool redirected);
0125 
0126     /**
0127      * Set whether the URL specifies to be opened in a new window.
0128      *
0129      * When openUrlRequest is emitted:
0130      * <ul>
0131      *  <li>normally the url would be opened in the current view.</li>
0132      *  <li>setForcesNewWindow(true) specifies that a new window or tab should be used:
0133      *  setNewTab(true) requests a tab specifically, otherwise the user-preference is followed.
0134      *  This is typically used for target="_blank" in web browsers.</li>
0135      * </ul>
0136      *
0137      * When createNewWindow is emitted:
0138      * <ul>
0139      *  <li>if setNewTab(true) was called, a tab is created.</li>
0140      *  <li>otherwise, if setForcesNewWindow(true) was called, a window is created.</li>
0141      *  <li>otherwise the user preference is followed.</li>
0142      * </ul>
0143      */
0144     void setForcesNewWindow(bool forcesNewWindow);
0145 
0146     /**
0147      * Whether the URL specifies to be opened in a new window
0148      */
0149     bool forcesNewWindow() const;
0150 
0151 private:
0152     BrowserArgumentsPrivate *d;
0153 };
0154 
0155 #else
0156 #include <KParts/BrowserArguments>
0157 using BrowserArguments = KParts::BrowserArguments;
0158 #endif
0159 
0160 #endif