File indexing completed on 2024-04-21 04:57:52

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 1999-2006 David Faure <faure@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KFMCLIENT_H
0008 #define KFMCLIENT_H
0009 
0010 #include <QObject>
0011 class KJob;
0012 class QUrl;
0013 class QString;
0014 class QCommandLineParser;
0015 
0016 class ClientApp : public QObject
0017 {
0018     Q_OBJECT
0019 public:
0020     ClientApp();
0021 
0022     /** Parse command-line arguments and "do it" */
0023     bool doIt(const QCommandLineParser &parser);
0024 
0025     /** Make konqueror open a window for @p url */
0026     bool createNewWindow(const QUrl &url, bool newTab, bool tempFile, const QString &mimetype = QString());
0027 
0028     /** Make konqueror open a window for @p profile, @p url and @p mimetype, deprecated */
0029     bool openProfile(const QString &profile, const QUrl &url, const QString &mimetype = QString());
0030 
0031 private Q_SLOTS:
0032     void slotResult(KJob *job);
0033 
0034 private:
0035 
0036     //Stores the result of parsing the BrowserApplication option
0037     struct BrowserApplicationParsingResult {
0038         //The string was parsed successfully
0039         bool isValid = false;
0040         //True if the string represents a command and false if it represents a service
0041         bool isCommand = false;
0042         //A string describing errors occurred while parsing the option
0043         QString error;
0044         //The command executable or service name
0045         QString commandOrService;
0046         //The arguments to pass to command. It's empty if isCommand is false
0047         QStringList args;
0048     };
0049 
0050     void delayedQuit();
0051 
0052     bool launchExternalBrowser(const BrowserApplicationParsingResult& parseResult, const QUrl &url, bool tempFile);
0053 
0054     //Parses the content of the BrowserApplication option
0055     static BrowserApplicationParsingResult parseBrowserApplicationString(const QString &str);
0056 
0057 
0058 private:
0059     bool m_interactive = true;
0060 };
0061 
0062 #endif