diff --git a/autotests/ktcpsockettest.h b/autotests/ktcpsockettest.h index 69662a85..36a2b109 100644 --- a/autotests/ktcpsockettest.h +++ b/autotests/ktcpsockettest.h @@ -1,75 +1,75 @@ /* * This file is part of the KDE libraries * Copyright (C) 2007 Andreas Hartmetz * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KTCPSOCKETTEST_H #define KTCPSOCKETTEST_H #include class Server; class KTcpSocketTest : public QObject { Q_OBJECT public: Server *server; KTcpSocketTest(); ~KTcpSocketTest(); private: void invokeOnServer(const char *); private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void connectDisconnect(); void read(); void write(); void statesIana(); void statesLocalHost(); void statesManyHosts(); void errors(); public Q_SLOTS: //auxiliary slots to check signal emission from the socket void states_hostFound(); private: QThread *m_thread; }; class QTcpServer; class QTcpSocket; class Server : public QObject { Q_OBJECT public: QTcpServer *listener; QTcpSocket *socket; quint16 port; - Server(quint16 _port); + explicit Server(quint16 _port); ~Server(); private: void cleanupSocket(); public Q_SLOTS: void connectDisconnect(); void read(); void write(); void states(); void errors(); }; #endif diff --git a/src/core/klocalsocket_p.h b/src/core/klocalsocket_p.h index f892d8c0..c2643b36 100644 --- a/src/core/klocalsocket_p.h +++ b/src/core/klocalsocket_p.h @@ -1,78 +1,78 @@ /* * This file is part of the KDE libraries * Copyright (C) 2007 Thiago Macieira * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KLOCALSOCKET_P_H #define KLOCALSOCKET_P_H #include #include #include "klocalsocket.h" #define MIN_SOCKADDR_UN_LEN (sizeof(quint16) + sizeof(char)) class QSocketNotifier; class KLocalSocketPrivate { public: KLocalSocket *const q; - KLocalSocketPrivate(KLocalSocket *qq) + explicit KLocalSocketPrivate(KLocalSocket *qq) : q(qq), type(KLocalSocket::UnknownLocalSocketType) { } QString localPath; QString peerPath; KLocalSocket::LocalSocketType type; void connectToPath(const QString &path, KLocalSocket::LocalSocketType type, QAbstractSocket::OpenMode openMode); void emitError(QAbstractSocket::SocketError, const QString &errorString); static inline KLocalSocketPrivate *d(KLocalSocket *aq) { return aq->d; } }; class KLocalSocketServerPrivate { public: KLocalSocketServer *const q; - KLocalSocketServerPrivate(KLocalSocketServer *qq); + explicit KLocalSocketServerPrivate(KLocalSocketServer *qq); int descriptor; int maxPendingConnections; QAbstractSocket::SocketState state; QAbstractSocket::SocketError error; KLocalSocket::LocalSocketType type; QString localPath; QString errorString; QSocketNotifier *readNotifier; QQueue pendingConnections; bool listen(const QString &path, KLocalSocket::LocalSocketType type); void close(); bool waitForNewConnection(int msec, bool *timedOut); bool processSocketActivity(); void _k_newConnectionActivity(); void emitError(QAbstractSocket::SocketError, const QString &errorString); }; #endif diff --git a/src/core/kprotocolinfo_p.h b/src/core/kprotocolinfo_p.h index 8d05bd19..c9923136 100644 --- a/src/core/kprotocolinfo_p.h +++ b/src/core/kprotocolinfo_p.h @@ -1,74 +1,74 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Torben Weis Copyright (C) 2000-2001 Waldo Bastian Copyright 2012 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPROTOCOLINFOPRIVATE_H #define KPROTOCOLINFOPRIVATE_H #include "kprotocolinfo.h" #include /** * @internal */ class KProtocolInfoPrivate { public: - KProtocolInfoPrivate(const QString &path); + explicit KProtocolInfoPrivate(const QString &path); KProtocolInfoPrivate(const QString &name, const QString &exec, const QJsonObject &json); QString m_name; QString m_exec; KProtocolInfo::Type m_inputType; KProtocolInfo::Type m_outputType; QStringList m_listing; bool m_isSourceProtocol : 1; bool m_isHelperProtocol : 1; bool m_supportsListing : 1; bool m_supportsReading : 1; bool m_supportsWriting : 1; bool m_supportsMakeDir : 1; bool m_supportsDeleting : 1; bool m_supportsLinking : 1; bool m_supportsMoving : 1; bool m_supportsOpening : 1; bool m_determineMimetypeFromExtension : 1; bool m_canCopyFromFile : 1; bool m_canCopyToFile : 1; bool m_showPreviews : 1; bool m_canRenameFromFile : 1; bool m_canRenameToFile : 1; bool m_canDeleteRecursive : 1; QString m_defaultMimetype; QString m_icon; QString m_config; int m_maxSlaves; QString m_docPath; QString m_protClass; QStringList m_archiveMimeTypes; KProtocolInfo::ExtraFieldList m_extraFields; KProtocolInfo::FileNameUsedForCopying m_fileNameUsedForCopying; QStringList m_capabilities; QStringList m_slaveHandlesNotify; QString m_proxyProtocol; int m_maxSlavesPerHost; }; #endif diff --git a/src/core/ksambashare_p.h b/src/core/ksambashare_p.h index c16b2c84..766f3a87 100644 --- a/src/core/ksambashare_p.h +++ b/src/core/ksambashare_p.h @@ -1,75 +1,75 @@ /* * Copyright 2010 Rodrigo Belem * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see */ #ifndef ksambashare_p_h #define ksambashare_p_h #include #include "ksambasharedata.h" class QString; class KSambaShare; class KSambaSharePrivate { public: - KSambaSharePrivate(KSambaShare *parent); + explicit KSambaSharePrivate(KSambaShare *parent); ~KSambaSharePrivate(); static bool isSambaInstalled(); bool findSmbConf(); void setUserSharePath(); static int runProcess(const QString &progName, const QStringList &args, QByteArray &stdOut, QByteArray &stdErr); static QString testparmParamValue(const QString ¶meterName); QByteArray getNetUserShareInfo(); QStringList shareNames() const; QStringList sharedDirs() const; KSambaShareData getShareByName(const QString &shareName) const; QList getSharesByPath(const QString &path) const; bool isShareNameValid(const QString &name) const; bool isDirectoryShared(const QString &path) const; bool isShareNameAvailable(const QString &name) const; KSambaShareData::UserShareError isPathValid(const QString &path) const; KSambaShareData::UserShareError isAclValid(const QString &acl) const; KSambaShareData::UserShareError guestsAllowed(const KSambaShareData::GuestPermission &guestok) const; KSambaShareData::UserShareError add(const KSambaShareData &shareData); KSambaShareData::UserShareError remove(const KSambaShareData &shareName) const; static QMap parse(const QByteArray &usershareData); void _k_slotFileChange(const QString &path); private: KSambaShare *const q_ptr; Q_DECLARE_PUBLIC(KSambaShare) QMap data; QString smbConf; QString userSharePath; bool skipUserShare; }; #endif diff --git a/src/core/usernotificationhandler_p.h b/src/core/usernotificationhandler_p.h index 55cd2a39..5d4996be 100644 --- a/src/core/usernotificationhandler_p.h +++ b/src/core/usernotificationhandler_p.h @@ -1,73 +1,73 @@ /* This file is part of the KDE libraries Copyright (C) 2012 Dawit Alemayehu This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef USERNOTIFICATIONHANDLER_P_H #define USERNOTIFICATIONHANDLER_P_H #include #include #include #include #include namespace KIO { class Slave; class SlaveInterface; class UserNotificationHandler : public QObject { Q_OBJECT public: enum MessageBoxDataType { MSG_TEXT, MSG_CAPTION, MSG_YES_BUTTON_TEXT, MSG_NO_BUTTON_TEXT, MSG_YES_BUTTON_ICON, MSG_NO_BUTTON_ICON, MSG_DONT_ASK_AGAIN, MSG_META_DATA }; class Request { public: QString key() const; int type; QPointer slave; QHash data; }; - UserNotificationHandler(QObject *parent = nullptr); + explicit UserNotificationHandler(QObject *parent = nullptr); virtual ~UserNotificationHandler(); void requestMessageBox(SlaveInterface *iface, int type, const QHash &data); private Q_SLOTS: void processRequest(); private: QCache m_cachedResults; QList m_pendingRequests; }; } #endif diff --git a/src/filewidgets/kdiroperatordetailview_p.h b/src/filewidgets/kdiroperatordetailview_p.h index 757bbd92..2f177cd5 100644 --- a/src/filewidgets/kdiroperatordetailview_p.h +++ b/src/filewidgets/kdiroperatordetailview_p.h @@ -1,55 +1,55 @@ /***************************************************************************** * Copyright (C) 2007 by Peter Penz * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License version 2 as published by the Free Software Foundation. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *****************************************************************************/ #ifndef KDIROPERATORDETAILVIEW_P_H #define KDIROPERATORDETAILVIEW_P_H #include #include class QAbstractItemModel; /** * Default detail view for KDirOperator using * custom resizing options and columns. */ class KDirOperatorDetailView : public QTreeView { Q_OBJECT public: - KDirOperatorDetailView(QWidget *parent = nullptr); + explicit KDirOperatorDetailView(QWidget *parent = nullptr); virtual ~KDirOperatorDetailView(); /** * Displays either Detail, Tree or DetailTree modes. */ virtual bool setViewMode(KFile::FileView viewMode); protected: bool event(QEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; private: bool m_hideDetailColumns; }; #endif diff --git a/src/filewidgets/kfilemetapreview_p.h b/src/filewidgets/kfilemetapreview_p.h index 86f4c774..3ba39d50 100644 --- a/src/filewidgets/kfilemetapreview_p.h +++ b/src/filewidgets/kfilemetapreview_p.h @@ -1,54 +1,54 @@ /* * This file is part of the KDE project. * Copyright (C) 2003 Carsten Pfeiffer * * You can Freely distribute this program under the GNU Library General Public * License. See the file "COPYING" for the exact licensing terms. */ #ifndef KFILEMETAPREVIEW_H #define KFILEMETAPREVIEW_H #include #include #include #include // Internal, but exported for KDirOperator (kfile) and KPreviewProps (kdelibs4support) class KIOFILEWIDGETS_EXPORT KFileMetaPreview : public KPreviewWidgetBase { Q_OBJECT public: - KFileMetaPreview(QWidget *parent); + explicit KFileMetaPreview(QWidget *parent); ~KFileMetaPreview(); virtual void addPreviewProvider(const QString &mimeType, KPreviewWidgetBase *provider); virtual void clearPreviewProviders(); public Q_SLOTS: void showPreview(const QUrl &url) override; void clearPreview() override; protected: virtual KPreviewWidgetBase *previewProviderFor(const QString &mimeType); private: void initPreviewProviders(); KPreviewWidgetBase *findExistingProvider(const QString &mimeType, const QMimeType &mimeInfo) const; QStackedWidget *m_stack; QHash m_previewProviders; bool haveAudioPreview; // may return 0L static KPreviewWidgetBase *createAudioPreview(QWidget *parent); static bool s_tryAudioPreview; private: class KFileMetaPreviewPrivate; KFileMetaPreviewPrivate *d; }; #endif // KFILEMETAPREVIEW_H diff --git a/src/filewidgets/kfileplacesview_p.h b/src/filewidgets/kfileplacesview_p.h index 548c026f..f9c97d7f 100644 --- a/src/filewidgets/kfileplacesview_p.h +++ b/src/filewidgets/kfileplacesview_p.h @@ -1,109 +1,109 @@ /* This file is part of the KDE project Copyright (C) 2008 Rafael Fernández López This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KFILEPLACESVIEW_P_H #define KFILEPLACESVIEW_P_H #include class KFilePlacesEventWatcher : public QObject { Q_OBJECT public: - KFilePlacesEventWatcher(QObject *parent = nullptr) + explicit KFilePlacesEventWatcher(QObject *parent = nullptr) : QObject(parent) {} const QModelIndex &hoveredIndex() const { return m_hoveredIndex; } const QModelIndex &focusedIndex() const { return m_focusedIndex; } Q_SIGNALS: void entryEntered(const QModelIndex &index); void entryLeft(const QModelIndex &index); public Q_SLOTS: void currentIndexChanged(const QModelIndex &index) { if (m_focusedIndex.isValid() && m_focusedIndex != m_hoveredIndex) { emit entryLeft(m_focusedIndex); } if (index == m_hoveredIndex) { m_focusedIndex = m_hoveredIndex; return; } if (index.isValid()) { emit entryEntered(index); } m_focusedIndex = index; } protected: bool eventFilter(QObject *watched, QEvent *event) override { switch (event->type()) { case QEvent::MouseMove: { QAbstractItemView *view = qobject_cast(watched->parent()); const QModelIndex index = view->indexAt(static_cast(event)->pos()); if (index != m_hoveredIndex) { if (m_hoveredIndex.isValid() && m_hoveredIndex != m_focusedIndex) { emit entryLeft(m_hoveredIndex); } if (index.isValid() && index != m_focusedIndex) { emit entryEntered(index); } m_hoveredIndex = index; } } break; case QEvent::Leave: if (m_hoveredIndex.isValid() && m_hoveredIndex != m_focusedIndex) { emit entryLeft(m_hoveredIndex); } m_hoveredIndex = QModelIndex(); break; case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: { // Prevent the selection clearing by clicking on the viewport directly QAbstractItemView *view = qobject_cast(watched->parent()); if (!view->indexAt(static_cast(event)->pos()).isValid()) { return true; } } break; default: return false; } return false; } private: QPersistentModelIndex m_hoveredIndex; QPersistentModelIndex m_focusedIndex; }; #endif diff --git a/src/ioslaves/file/fdreceiver.h b/src/ioslaves/file/fdreceiver.h index f8d818b8..d7af18a1 100644 --- a/src/ioslaves/file/fdreceiver.h +++ b/src/ioslaves/file/fdreceiver.h @@ -1,47 +1,47 @@ /*** Copyright (C) 2017 by Chinmoy Ranjan Pradhan This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ***/ #ifndef FDRECEIVER_H #define FDRECEIVER_H #include class QSocketNotifier; class FdReceiver : public QObject { Q_OBJECT public: - FdReceiver(const std::string &path, QObject *parent = nullptr); + explicit FdReceiver(const std::string &path, QObject *parent = nullptr); ~FdReceiver(); bool isListening() const; int fileDescriptor() const; private: Q_SLOT void receiveFileDescriptor(); QSocketNotifier *m_readNotifier; std::string m_path; int m_socketDes; int m_fileDes; }; #endif diff --git a/src/ioslaves/file/kauth/fdsender.h b/src/ioslaves/file/kauth/fdsender.h index 9e7258eb..f0dbb871 100644 --- a/src/ioslaves/file/kauth/fdsender.h +++ b/src/ioslaves/file/kauth/fdsender.h @@ -1,37 +1,37 @@ /*** Copyright (C) 2017 by Chinmoy Ranjan Pradhan This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ***/ #ifndef FDSENDER_H #define FDSENDER_H class FdSender { public: - FdSender(const std::string &path); + explicit FdSender(const std::string &path); ~FdSender(); bool sendFileDescriptor(int fd); bool isConnected() const; private: int m_socketDes; }; #endif diff --git a/src/ioslaves/file/sharefd_p.h b/src/ioslaves/file/sharefd_p.h index ba1136c2..08a98101 100644 --- a/src/ioslaves/file/sharefd_p.h +++ b/src/ioslaves/file/sharefd_p.h @@ -1,99 +1,99 @@ /*** Copyright (C) 2017 by Chinmoy Ranjan Pradhan This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ***/ #include #include #include #include #include #include // fix SOCK_NONBLOCK for e.g. macOS #ifndef SOCK_NONBLOCK #include #define SOCK_NONBLOCK O_NONBLOCK #endif class SocketAddress { const sockaddr_un addr; public: - SocketAddress(const std::string &path) + explicit SocketAddress(const std::string &path) : addr(make_address(path)) { } int length() const { return offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path) + 1; } const sockaddr *address() const { return addr.sun_path[0] ? reinterpret_cast(&addr) : nullptr; } private: static sockaddr_un make_address(const std::string& path) { sockaddr_un a; memset(&a, 0, sizeof a); a.sun_family = AF_UNIX; const size_t pathSize = path.size(); if (pathSize > 0 && pathSize < sizeof(a.sun_path) - 1) { memcpy(a.sun_path, path.c_str(), pathSize + 1); } return a; } }; class FDMessageHeader { char io_buf[2]; char cmsg_buf[CMSG_SPACE(sizeof(int))]; iovec io; msghdr msg; public: FDMessageHeader() : io_buf{0} , cmsg_buf{0} { memset(&io, 0, sizeof io); io.iov_base = &io_buf; io.iov_len = sizeof io_buf; memset(&msg, 0, sizeof msg); msg.msg_iov = &io; msg.msg_iovlen = 1; msg.msg_control = &cmsg_buf; msg.msg_controllen = sizeof cmsg_buf; } msghdr *message() { return &msg; } cmsghdr *cmsgHeader() { return CMSG_FIRSTHDR(&msg); } }; diff --git a/src/ioslaves/http/httpauthentication.h b/src/ioslaves/http/httpauthentication.h index e39643ba..cd3c447f 100644 --- a/src/ioslaves/http/httpauthentication.h +++ b/src/ioslaves/http/httpauthentication.h @@ -1,295 +1,295 @@ /* This file is part of the KDE libraries Copyright (C) 2008, 2009 Andreas Hartmetz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef HTTPAUTHENTICATION_H #define HTTPAUTHENTICATION_H #include #include #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(KIO_HTTP_AUTH) namespace KIO { class AuthInfo; } class KConfigGroup; class KAbstractHttpAuthentication { public: - KAbstractHttpAuthentication(KConfigGroup *config = nullptr); + explicit KAbstractHttpAuthentication(KConfigGroup *config = nullptr); virtual ~KAbstractHttpAuthentication(); /** * Choose the best authentication mechanism from the offered ones * * This will return the most secure mechanism from the list of * mechanisms returned by the server. */ static QByteArray bestOffer(const QList &offers); /** * Returns authentication object instance appropriate for @p offer. * * @param offer the header from which an authentication object is created. * @param config the config object to read stored authentication information. */ static KAbstractHttpAuthentication *newAuth(const QByteArray &offer, KConfigGroup *config = nullptr); /** * Split all headers containing multiple authentication offers. * * @param offers the offers from multiple HTTP authentication header lines. * @return a list where each entry contains only a single offer */ static QList splitOffers(const QList &offers); /** * reset to state after default construction. */ void reset(); /** * the authentication scheme: "Negotiate", "Digest", "Basic", "NTLM" */ virtual QByteArray scheme() const = 0; /** * initiate authentication with challenge string (from HTTP header) */ virtual void setChallenge(const QByteArray &c, const QUrl &resource, const QByteArray &httpMethod); /** * return value updated by setChallenge() * * if this is false user and password passed to generateResponse * will be ignored and may be empty. */ bool needCredentials() const { return m_needCredentials; } /** * KIO compatible data to find cached credentials. * * Note that username and/or password as well as UI text will NOT be filled in. */ virtual void fillKioAuthInfo(KIO::AuthInfo *ai) const = 0; /** * what to do in response to challenge */ virtual void generateResponse(const QString &user, const QString &password) = 0; /** * returns true when the final stage of authentication is reached. * * Unless the authentication scheme requires multiple stages like NTLM this * function will always return true. */ bool wasFinalStage() const { return m_finalAuthStage; } /** * Returns true if the authentication scheme supports path matching to identify * resources that belong to the same protection space (realm). * * See RFC 2617. */ virtual bool supportsPathMatching() const { return false; } // the following accessors return useful data after generateResponse() has been called. // clients process the following fields top to bottom: highest priority is on top // malformed challenge and similar problems - it is advisable to reconnect bool isError() const { return m_isError; } /** * force keep-alive connection because the authentication method requires it */ bool forceKeepAlive() const { return m_forceKeepAlive; } /** * force disconnection because the authentication method requires it */ bool forceDisconnect() const { return m_forceDisconnect; } /** * insert this into the next request header after "Authorization: " * or "Proxy-Authorization: " */ QByteArray headerFragment() const { return m_headerFragment; } /** * Returns the realm sent by the server. * * This is mainly for GUI shown to the user. This is the identification of * the protected area on the server (e.g. "Konquis home directory" or * "KDE files"). */ QString realm() const; /** * Sets the cache password flag to @p enable. */ void setCachePasswordEnabled(bool enable) { m_keepPassword = enable; } #ifdef ENABLE_HTTP_AUTH_NONCE_SETTER // NOTE: FOR USE in unit testing ONLY. virtual void setDigestNonceValue(const QByteArray &) {} #endif protected: void authInfoBoilerplate(KIO::AuthInfo *a) const; /** * Returns any authentication data that should be cached for future use. * * NOTE: Do not reimplement this function for connection based authentication * schemes such as NTLM. */ virtual QByteArray authDataToCache() const { return QByteArray(); } void generateResponseCommon(const QString &user, const QString &password); KConfigGroup *m_config; QByteArray m_scheme; ///< this is parsed from the header and not necessarily == scheme(). QByteArray m_challengeText; QList m_challenge; QUrl m_resource; QByteArray m_httpMethod; bool m_isError; bool m_needCredentials; bool m_forceKeepAlive; bool m_forceDisconnect; bool m_finalAuthStage; bool m_keepPassword; QByteArray m_headerFragment; QString m_username; QString m_password; }; class KHttpBasicAuthentication : public KAbstractHttpAuthentication { public: QByteArray scheme() const override; void fillKioAuthInfo(KIO::AuthInfo *ai) const override; void generateResponse(const QString &user, const QString &password) override; bool supportsPathMatching() const override { return true; } protected: QByteArray authDataToCache() const override { return m_challengeText; } private: friend class KAbstractHttpAuthentication; KHttpBasicAuthentication(KConfigGroup *config = nullptr) : KAbstractHttpAuthentication(config) {} }; class KHttpDigestAuthentication : public KAbstractHttpAuthentication { public: QByteArray scheme() const override; void setChallenge(const QByteArray &c, const QUrl &resource, const QByteArray &httpMethod) override; void fillKioAuthInfo(KIO::AuthInfo *ai) const override; void generateResponse(const QString &user, const QString &password) override; bool supportsPathMatching() const override { return true; } #ifdef ENABLE_HTTP_AUTH_NONCE_SETTER void setDigestNonceValue(const QByteArray &) override; #endif protected: QByteArray authDataToCache() const override { return m_challengeText; } private: friend class KAbstractHttpAuthentication; KHttpDigestAuthentication(KConfigGroup *config = nullptr) : KAbstractHttpAuthentication(config) {} #ifdef ENABLE_HTTP_AUTH_NONCE_SETTER QByteArray m_nonce; #endif }; class KHttpNtlmAuthentication : public KAbstractHttpAuthentication { public: QByteArray scheme() const override; void setChallenge(const QByteArray &c, const QUrl &resource, const QByteArray &httpMethod) override; void fillKioAuthInfo(KIO::AuthInfo *ai) const override; void generateResponse(const QString &user, const QString &password) override; private: friend class KAbstractHttpAuthentication; - KHttpNtlmAuthentication(KConfigGroup *config = nullptr) + explicit KHttpNtlmAuthentication(KConfigGroup *config = nullptr) : KAbstractHttpAuthentication(config), m_stage1State(Init) {} enum Stage1State { Init = 0, SentNTLMv1, SentNTLMv2 }; Stage1State m_stage1State; }; #if HAVE_LIBGSSAPI class KHttpNegotiateAuthentication : public KAbstractHttpAuthentication { public: QByteArray scheme() const override; void setChallenge(const QByteArray &c, const QUrl &resource, const QByteArray &httpMethod) override; void fillKioAuthInfo(KIO::AuthInfo *ai) const override; void generateResponse(const QString &user, const QString &password) override; private: friend class KAbstractHttpAuthentication; - KHttpNegotiateAuthentication(KConfigGroup *config = nullptr) + explicit KHttpNegotiateAuthentication(KConfigGroup *config = nullptr) : KAbstractHttpAuthentication(config) {} }; #endif // HAVE_LIBGSSAPI #endif // HTTPAUTHENTICATION_H diff --git a/src/ioslaves/http/httpfilter.h b/src/ioslaves/http/httpfilter.h index 0a0cf644..dd965e86 100644 --- a/src/ioslaves/http/httpfilter.h +++ b/src/ioslaves/http/httpfilter.h @@ -1,107 +1,107 @@ /* This file is part of the KDE libraries Copyright (c) 2002 Waldo Bastian Copyright 2009 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _HTTPFILTER_H_ #define _HTTPFILTER_H_ class KFilterBase; #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(KIO_HTTP_FILTER) class HTTPFilterBase : public QObject { Q_OBJECT public: HTTPFilterBase(); ~HTTPFilterBase(); void chain(HTTPFilterBase *previous); public Q_SLOTS: virtual void slotInput(const QByteArray &d) = 0; Q_SIGNALS: void output(const QByteArray &d); void error(const QString &); protected: HTTPFilterBase *last; }; class HTTPFilterChain : public HTTPFilterBase { Q_OBJECT public: HTTPFilterChain(); void addFilter(HTTPFilterBase *filter); public Q_SLOTS: void slotInput(const QByteArray &d) override; private: HTTPFilterBase *first; }; class HTTPFilterMD5 : public HTTPFilterBase { Q_OBJECT public: HTTPFilterMD5(); QString md5(); public Q_SLOTS: void slotInput(const QByteArray &d) override; private: QCryptographicHash context; }; class HTTPFilterGZip : public HTTPFilterBase { Q_OBJECT public: - HTTPFilterGZip(bool deflate = false /* for subclass HTTPFilterDeflate */); + explicit HTTPFilterGZip(bool deflate = false /* for subclass HTTPFilterDeflate */); ~HTTPFilterGZip(); public Q_SLOTS: void slotInput(const QByteArray &d) override; private: bool m_deflateMode; bool m_firstData; bool m_finished; KFilterBase *m_gzipFilter; }; class HTTPFilterDeflate : public HTTPFilterGZip { Q_OBJECT public: HTTPFilterDeflate(); }; #endif diff --git a/src/ioslaves/http/parsinghelpers.h b/src/ioslaves/http/parsinghelpers.h index a49b0bad..e721a2b9 100644 --- a/src/ioslaves/http/parsinghelpers.h +++ b/src/ioslaves/http/parsinghelpers.h @@ -1,90 +1,90 @@ /* This file is part of the KDE libraries Copyright (C) 2008 Andreas Hartmetz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PARSINGHELPERS_H #define PARSINGHELPERS_H #include #include #include struct HeaderField { HeaderField(bool multiValued) { isMultiValued = multiValued; } // QHash requires a default constructor HeaderField() { isMultiValued = false; } bool isMultiValued; QList > beginEnd; }; class HeaderTokenizer; class TokenIterator { public: inline bool hasNext() const { return m_currentToken < m_tokens.count(); } QByteArray next(); QByteArray current() const; QList all() const; private: friend class HeaderTokenizer; QList > m_tokens; int m_currentToken; const char *m_buffer; TokenIterator(const QList > &tokens, const char *buffer) : m_tokens(tokens), m_currentToken(0), m_buffer(buffer) {} }; class HeaderTokenizer : public QHash { public: - HeaderTokenizer(char *buffer); + explicit HeaderTokenizer(char *buffer); // note that buffer is not const - in the parsed area CR/LF will be overwritten // with spaces if there is a line continuation. /// @return: index of first char after header or end int tokenize(int begin, int end); // after tokenize() has been called use the QHash part of this class to // ask for a list of begin-end indexes in buffer for header values. TokenIterator iterator(const char *key) const; private: char *m_buffer; struct HeaderFieldTemplate { const char *name; bool isMultiValued; }; QList > m_nullTokens; //long-lived, allows us to pass out references. }; #endif //PARSINGHELPERS_H diff --git a/src/ioslaves/trash/kinterprocesslock.h b/src/ioslaves/trash/kinterprocesslock.h index 1276e2f8..3b0d51fe 100644 --- a/src/ioslaves/trash/kinterprocesslock.h +++ b/src/ioslaves/trash/kinterprocesslock.h @@ -1,118 +1,118 @@ /* This file is part of the KDE Copyright (C) 2009 Tobias Koenig (tokoe@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KINTERPROCESSLOCK_H #define KINTERPROCESSLOCK_H #include class KInterProcessLockPrivate; /** * @short A class for serializing access to a resource that is shared between multiple processes. * * This class can be used to serialize access to a resource between * multiple processes. Instead of using lock files, which could * become stale easily, the registration of dummy dbus services is used * to allow only one process at a time to access the resource. * * Example: * * @code * * KInterProcessLock *lock = new KInterProcessLock("myresource"); * connect(lock, SIGNAL(lockGranted(KInterProcessLock *)), * this, SLOT(doCriticalTask(KInterProcessLock *))); * lock->lock(); * * ... * * ... ::doCriticalTask(KInterProcessLock *lock) * { * // change common resource * * lock->unlock(); * } * * @endcode * * @author Tobias Koenig */ class KInterProcessLock : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(KInterProcessLock) public: /** * Creates a new inter process lock object. * * @param resource The identifier of the resource that shall be locked. * This identifier can be any string, however it must be unique for * the resource and every client that wants to access the resource must * know it. */ - KInterProcessLock(const QString &resource); + explicit KInterProcessLock(const QString &resource); /** * Destroys the inter process lock object. */ ~KInterProcessLock(); /** * Returns the identifier of the resource the lock is set on. */ QString resource() const; /** * Requests the lock. * * The lock is granted as soon as the lockGranted() signal is emitted. */ void lock(); /** * Releases the lock. * * @note This method should be called as soon as the critical area is left * in your code path and the lock is no longer needed. */ void unlock(); /** * Waits for the granting of a lock by starting an internal event loop. */ void waitForLockGranted(); Q_SIGNALS: /** * This signal is emitted when the requested lock has been granted. * * @param lock The lock that has been granted. */ void lockGranted(KInterProcessLock *lock); private: KInterProcessLockPrivate *const d_ptr; Q_PRIVATE_SLOT(d_func(), void _k_serviceRegistered(const QString &)) }; #endif diff --git a/src/ioslaves/trash/trashsizecache.h b/src/ioslaves/trash/trashsizecache.h index 0eb2d029..1c1400f0 100644 --- a/src/ioslaves/trash/trashsizecache.h +++ b/src/ioslaves/trash/trashsizecache.h @@ -1,74 +1,74 @@ /* This file is part of the KDE project Copyright (C) 2009 Tobias Koenig Copyright (C) 2014 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef TRASHSIZECACHE_H #define TRASHSIZECACHE_H #include #include /** * @short A class that encapsulates the directory size cache. * * The directory size cache is used to speed up the determination of the trash size. * * Since version 1.0, http://standards.freedesktop.org/trash-spec/trashspec-latest.html specifies this cache * as a standard way to cache this information. * */ class TrashSizeCache { public: /** * Creates a new trash size cache object for the given trash @p path. */ - TrashSizeCache(const QString &path); + explicit TrashSizeCache(const QString &path); /** * Adds a directory to the cache. * @param directoryName fileId of the directory * @param directorySize size in bytes */ void add(const QString &directoryName, qulonglong directorySize); /** * Removes a directory from the cache. */ void remove(const QString &directoryName); /** * Sets the trash size to 0 bytes. */ void clear(); /** * Calculates and returns the current trash size. */ qulonglong calculateSize(); private: QString mTrashSizeCachePath; QString mTrashPath; }; #endif diff --git a/src/kcms/kio/kcookiesmanagement.h b/src/kcms/kio/kcookiesmanagement.h index 981cd86c..2560b939 100644 --- a/src/kcms/kio/kcookiesmanagement.h +++ b/src/kcms/kio/kcookiesmanagement.h @@ -1,93 +1,93 @@ /** * kcookiesmanagement.h - Cookies manager * * Copyright 2000-2001 Marco Pinelli * Copyright 2000-2001 Dawit Alemayehu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KCOOKIESMANAGEMENT_H #define KCOOKIESMANAGEMENT_H #include #include #include #include #include #include "ui_kcookiesmanagement.h" struct CookieProp; class CookieListViewItem : public QTreeWidgetItem { public: CookieListViewItem(QTreeWidget *parent, const QString &dom); CookieListViewItem(QTreeWidgetItem *parent, CookieProp *cookie); ~CookieListViewItem(); QString domain() const { return mDomain; } CookieProp* cookie() const { return mCookie; } CookieProp* leaveCookie(); void setCookiesLoaded() { mCookiesLoaded = true; } bool cookiesLoaded() const { return mCookiesLoaded; } private: void init( CookieProp* cookie, const QString &domain = QString(), bool cookieLoaded=false ); CookieProp *mCookie; QString mDomain; bool mCookiesLoaded; }; class KCookiesManagement : public KCModule { Q_OBJECT public: - KCookiesManagement(/*const KComponentData &componentData,*/ QWidget *parent ); + explicit KCookiesManagement(/*const KComponentData &componentData,*/ QWidget *parent ); ~KCookiesManagement(); void load() override; void save() override; void defaults() override; QString quickHelp() const override; private Q_SLOTS: void on_deleteButton_clicked(); void on_deleteAllButton_clicked(); void on_reloadButton_clicked(); void on_cookiesTreeWidget_itemExpanded(QTreeWidgetItem*); void on_cookiesTreeWidget_currentItemChanged(QTreeWidgetItem*); void on_configPolicyButton_clicked(); private: void reset (bool deleteAll = false); bool cookieDetails(CookieProp *cookie); void clearCookieDetails(); bool policyenabled(); bool mDeleteAllFlag; QWidget* mMainWidget; Ui::KCookiesManagementUI mUi; QStringList mDeletedDomains; typedef QList CookiePropList; QHash mDeletedCookies; }; #endif // KCOOKIESMANAGEMENT_H diff --git a/src/kcms/kio/kcookiespolicies.h b/src/kcms/kio/kcookiespolicies.h index 85377102..c68a608e 100644 --- a/src/kcms/kio/kcookiespolicies.h +++ b/src/kcms/kio/kcookiespolicies.h @@ -1,78 +1,78 @@ /** * kcookiespolicies.h - Cookies configuration * * Original Authors * Copyright (c) Waldo Bastian * Copyright (c) 1999 David Faure * * Re-written by: * Copyright (c) 2000- Dawit Alemayehu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KCOOKIESPOLICIES_H #define KCOOKIESPOLICIES_H #include #include #include "kcookiespolicyselectiondlg.h" #include "ui_kcookiespolicies.h" class QTreeWidgetItem; class KCookiesPolicies : public KCModule { Q_OBJECT public: - KCookiesPolicies(/*const KComponentData &componentData,*/ QWidget *parent); + explicit KCookiesPolicies(/*const KComponentData &componentData,*/ QWidget *parent); ~KCookiesPolicies(); void load() override; void save() override; void defaults() override; QString quickHelp() const override; void setPolicy(const QString& domain); protected Q_SLOTS: void cookiesEnabled( bool ); void configChanged(); void selectionChanged(); void updateButtons(); void deleteAllPressed(); void deletePressed(); void changePressed(); void addPressed(); void changePressed(QTreeWidgetItem*, bool state = true); void addPressed(const QString&, bool state = true); private: void updateDomainList(const QStringList& list); bool handleDuplicate( const QString& domain, int ); void splitDomainAdvice (const QString& configStr, QString &domain, KCookieAdvice::Value &advice); private: quint64 mSelectedItemsCount; Ui::KCookiePoliciesUI mUi; QMap mDomainPolicyMap; }; #endif // KCOOKIESPOLICIES_H diff --git a/src/kpac/discovery.h b/src/kpac/discovery.h index df301e60..e64d5a87 100644 --- a/src/kpac/discovery.h +++ b/src/kpac/discovery.h @@ -1,51 +1,51 @@ /* Copyright (c) 2003 Malte Starostik This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPAC_DISCOVERY_H #define KPAC_DISCOVERY_H #include "downloader.h" class QProcess; namespace KPAC { class Discovery : public Downloader { Q_OBJECT public: - Discovery(QObject *); + explicit Discovery(QObject *); protected Q_SLOTS: void failed() override; private Q_SLOTS: void helperOutput(); private: bool initDomainName(); bool checkDomain() const; QProcess *m_helper; QString m_domainName; }; } #endif // KPAC_DISCOVERY_H diff --git a/src/kpac/downloader.h b/src/kpac/downloader.h index fd56b296..ec6124b0 100644 --- a/src/kpac/downloader.h +++ b/src/kpac/downloader.h @@ -1,76 +1,76 @@ /* Copyright (c) 2003 Malte Starostik This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPAC_DOWNLOADER_H #define KPAC_DOWNLOADER_H #include #include class KJob; namespace KIO { class Job; } namespace KPAC { class Downloader : public QObject { Q_OBJECT public: - Downloader(QObject *); + explicit Downloader(QObject *); void download(const QUrl &); const QUrl &scriptUrl() { return m_scriptURL; } const QString &script() { return m_script; } const QString &error() { return m_error; } Q_SIGNALS: void result(bool); protected: virtual void failed(); void setError(const QString &); private Q_SLOTS: void redirection(KIO::Job *, const QUrl &); void data(KIO::Job *, const QByteArray &); void result(KJob *); private: QByteArray m_data; QUrl m_scriptURL; QString m_script; QString m_error; }; } #endif // KPAC_DOWNLOADER_H diff --git a/src/kpac/script.h b/src/kpac/script.h index 822ab024..35e40e40 100644 --- a/src/kpac/script.h +++ b/src/kpac/script.h @@ -1,58 +1,58 @@ /* Copyright (c) 2003 Malte Starostik Copyright (c) 2011 Dawit Alemayehu This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPAC_SCRIPT_H #define KPAC_SCRIPT_H #include class QUrl; class QScriptEngine; namespace KPAC { class Script { public: class Error { public: - Error(const QString &message) + explicit Error(const QString &message) : m_message(message) {} const QString &message() const { return m_message; } private: QString m_message; }; - Script(const QString &code); + explicit Script(const QString &code); ~Script(); QString evaluate(const QUrl &); private: QScriptEngine *m_engine; }; } #endif // KPAC_SCRIPT_H diff --git a/src/kpasswdserver/kpasswdserver.h b/src/kpasswdserver/kpasswdserver.h index 62d920b7..cad73691 100644 --- a/src/kpasswdserver/kpasswdserver.h +++ b/src/kpasswdserver/kpasswdserver.h @@ -1,137 +1,137 @@ /* This file is part of the KDE Password Server Copyright (C) 2002 Waldo Bastian (bastian@kde.org) Copyright (C) 2012 Dawit Alemayehu (adawit@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //---------------------------------------------------------------------------- // // KDE Password Server #ifndef KPASSWDSERVER_H #define KPASSWDSERVER_H #include #include #include #include #include #include #include namespace KWallet { class Wallet; } class KPasswdServer : public KDEDModule, protected QDBusContext { Q_OBJECT public: - KPasswdServer(QObject* parent, const QList& = QList()); + explicit KPasswdServer(QObject* parent, const QList& = QList()); ~KPasswdServer(); // Called by the unit test void setWalletDisabled(bool d) { m_walletDisabled = d; } public Q_SLOTS: qlonglong checkAuthInfoAsync(KIO::AuthInfo, qlonglong, qlonglong); qlonglong queryAuthInfoAsync(const KIO::AuthInfo &, const QString &, qlonglong, qlonglong, qlonglong); void addAuthInfo(const KIO::AuthInfo &, qlonglong); void removeAuthInfo(const QString& host, const QString& protocol, const QString& user); // legacy methods provided for compatibility with old clients QByteArray checkAuthInfo(const QByteArray &, qlonglong, qlonglong); QByteArray queryAuthInfo(const QByteArray &, const QString &, qlonglong, qlonglong, qlonglong); void addAuthInfo(const QByteArray &, qlonglong); void processRequest(); // Remove all authentication info associated with windowId void removeAuthForWindowId(qlonglong windowId); Q_SIGNALS: void checkAuthInfoAsyncResult(qlonglong requestId, qlonglong seqNr, const KIO::AuthInfo &); void queryAuthInfoAsyncResult(qlonglong requestId, qlonglong seqNr, const KIO::AuthInfo &); private Q_SLOTS: void passwordDialogDone(int); void retryDialogDone(int); void windowRemoved(WId); private: struct AuthInfoContainer { AuthInfoContainer() : expire( expNever ), seqNr( 0 ), isCanceled( false ) {} KIO::AuthInfo info; QString directory; enum { expNever, expWindowClose, expTime } expire; QList windowList; qulonglong expireTime; qlonglong seqNr; bool isCanceled; struct Sorter { bool operator() (AuthInfoContainer* n1, AuthInfoContainer* n2) const; }; }; struct Request { bool isAsync; // true for async requests qlonglong requestId; // set for async requests only QDBusMessage transaction; // set for sync requests only QString key; KIO::AuthInfo info; QString errorMsg; qlonglong windowId; qlonglong seqNr; bool prompt; }; QString createCacheKey( const KIO::AuthInfo &info ); const AuthInfoContainer *findAuthInfoItem(const QString &key, const KIO::AuthInfo &info); void removeAuthInfoItem(const QString &key, const KIO::AuthInfo &info); void addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, qlonglong windowId, qlonglong seqNr, bool canceled); void copyAuthInfo(const AuthInfoContainer*, KIO::AuthInfo&); void updateAuthExpire(const QString &key, const AuthInfoContainer *, qlonglong windowId, bool keep); #ifdef HAVE_KF5WALLET bool openWallet( qlonglong windowId ); #endif bool hasPendingQuery(const QString &key, const KIO::AuthInfo &info); void sendResponse (Request* request); void showPasswordDialog(Request* request); void updateCachedRequestKey(QList&, const QString& oldKey, const QString& newKey); typedef QList AuthInfoContainerList; QHash m_authDict; QList m_authPending; QList m_authWait; QHash mWindowIdList; QHash m_authInProgress; QHash m_authRetryInProgress; QStringList m_authPrompted; KWallet::Wallet* m_wallet; bool m_walletDisabled; qlonglong m_seqNr; }; #endif diff --git a/src/kssld/kssld_adaptor.h b/src/kssld/kssld_adaptor.h index af537c06..0c98d007 100644 --- a/src/kssld/kssld_adaptor.h +++ b/src/kssld/kssld_adaptor.h @@ -1,73 +1,73 @@ /* This file is part of the KDE libraries Copyright (C) 2007 Andreas Hartmetz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KSSLD_ADAPTOR_H #define KSSLD_ADAPTOR_H #include #include #include #include #include "kssld_dbusmetatypes.h" class KSSLDAdaptor: public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KSSLD") public: - KSSLDAdaptor(KSSLD *parent) + explicit KSSLDAdaptor(KSSLD *parent) : QDBusAbstractAdaptor(parent) { Q_ASSERT(parent); registerMetaTypesForKSSLD(); } private: inline KSSLD *p() { return static_cast(parent()); } public Q_SLOTS: inline Q_NOREPLY void setRule(const KSslCertificateRule &rule) { return p()->setRule(rule); } inline Q_NOREPLY void clearRule__rule(const KSslCertificateRule &rule) { return p()->clearRule(rule); } inline Q_NOREPLY void clearRule__certHost(const QSslCertificate &cert, const QString &hostName) { return p()->clearRule(cert, hostName); } inline KSslCertificateRule rule(const QSslCertificate &cert, const QString &hostName) { return p()->rule(cert, hostName); } }; #endif //KSSLD_ADAPTOR_H diff --git a/src/widgets/delegateanimationhandler_p.h b/src/widgets/delegateanimationhandler_p.h index 57dc2ba8..bf12f2e6 100644 --- a/src/widgets/delegateanimationhandler_p.h +++ b/src/widgets/delegateanimationhandler_p.h @@ -1,173 +1,173 @@ /* This file is part of the KDE project Copyright © 2007 Fredrik Höglund This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DELEGATEANIMATIONHANDLER_P_H #define DELEGATEANIMATIONHANDLER_P_H #include #include #include #include #include #include #include #include class QAbstractItemView; namespace KIO { class CachedRendering : public QObject { Q_OBJECT public: CachedRendering(QStyle::State state, const QSize &size, QModelIndex validityIndex, qreal devicePixelRatio = 1.0); bool checkValidity(QStyle::State current) const { return state == current && valid; } QStyle::State state; QPixmap regular; QPixmap hover; bool valid; QPersistentModelIndex validityIndex; private Q_SLOTS: void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void modelReset(); }; class AnimationState { public: ~AnimationState(); //Progress of the mouse hovering animation qreal hoverProgress() const; //Progress of the icon fading animation qreal fadeProgress() const; //Angle of the painter, to paint the animation for a file job on an item qreal jobAnimationAngle() const; void setJobAnimation(bool value); bool hasJobAnimation() const; CachedRendering *cachedRendering() const { return renderCache; } //The previous render-cache is deleted, if there was one void setCachedRendering(CachedRendering *rendering) { delete renderCache; renderCache = rendering; } //Returns current cached rendering, and removes it from this state. //The caller has the ownership. CachedRendering *takeCachedRendering() { CachedRendering *ret = renderCache; renderCache = nullptr; return ret; } CachedRendering *cachedRenderingFadeFrom() const { return fadeFromRenderCache; } //The previous render-cache is deleted, if there was one void setCachedRenderingFadeFrom(CachedRendering *rendering) { delete fadeFromRenderCache; fadeFromRenderCache = rendering; if (rendering) { m_fadeProgress = 0; } else { m_fadeProgress = 1; } } private: - AnimationState(const QModelIndex &index); + explicit AnimationState(const QModelIndex &index); bool update(); QPersistentModelIndex index; QTimeLine::Direction direction; bool animating; bool jobAnimation; qreal progress; qreal m_fadeProgress; qreal m_jobAnimationAngle; QTime time; QTime creationTime; CachedRendering *renderCache; CachedRendering *fadeFromRenderCache; friend class DelegateAnimationHandler; }; class DelegateAnimationHandler : public QObject { Q_OBJECT typedef QLinkedList AnimationList; typedef QMapIterator AnimationListsIterator; typedef QMutableMapIterator MutableAnimationListsIterator; public: - DelegateAnimationHandler(QObject *parent = nullptr); + explicit DelegateAnimationHandler(QObject *parent = nullptr); ~DelegateAnimationHandler(); AnimationState *animationState(const QStyleOption &option, const QModelIndex &index, const QAbstractItemView *view); void restartAnimation(AnimationState *state); void gotNewIcon(const QModelIndex &index); private Q_SLOTS: void viewDeleted(QObject *view); void sequenceTimerTimeout(); private: void eventuallyStartIteration(QModelIndex index); AnimationState *findAnimationState(const QAbstractItemView *view, const QModelIndex &index) const; void addAnimationState(AnimationState *state, const QAbstractItemView *view); void startAnimation(AnimationState *state); int runAnimations(AnimationList *list, const QAbstractItemView *view); void timerEvent(QTimerEvent *event) override; void setSequenceIndex(int arg1); private: QMap animationLists; QTime fadeInAddTime; QBasicTimer timer; //Icon sequence handling: QPersistentModelIndex sequenceModelIndex; QTimer iconSequenceTimer; int currentSequenceIndex; }; } #endif diff --git a/src/widgets/dropjob.cpp b/src/widgets/dropjob.cpp index 3530f584..47298f83 100644 --- a/src/widgets/dropjob.cpp +++ b/src/widgets/dropjob.cpp @@ -1,571 +1,571 @@ /* This file is part of the KDE libraries Copyright (C) 2014 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or, at the discretion of KDE e.V. (which shall act as a proxy as in section 14 of the GPLv3), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "dropjob.h" #include "job_p.h" #include "pastejob.h" #include "pastejob_p.h" #include "jobuidelegate.h" #include "jobuidelegateextension.h" #include "kio_widgets_debug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace KIO; Q_DECLARE_METATYPE(Qt::DropAction) namespace KIO { class DropMenu; } class KIO::DropMenu : public QMenu { public: - DropMenu(QWidget *parent = nullptr); + explicit DropMenu(QWidget *parent = nullptr); ~DropMenu(); void addCancelAction(); void addExtraActions(const QList &appActions, const QList &pluginActions); private: QList m_appActions; QList m_pluginActions; QAction *m_lastSeparator; QAction *m_extraActionsSeparator; QAction *m_cancelAction; }; class KIO::DropJobPrivate : public KIO::JobPrivate { public: DropJobPrivate(const QDropEvent *dropEvent, const QUrl &destUrl, JobFlags flags) : JobPrivate(), // Extract everything from the dropevent, since it will be deleted before the job starts m_mimeData(dropEvent->mimeData()), m_urls(KUrlMimeData::urlsFromMimeData(m_mimeData, KUrlMimeData::PreferLocalUrls, &m_metaData)), m_dropAction(dropEvent->dropAction()), m_relativePos(dropEvent->pos()), m_keyboardModifiers(dropEvent->keyboardModifiers()), m_destUrl(destUrl), m_destItem(KCoreDirLister::cachedItemForUrl(destUrl)), m_flags(flags), m_triggered(false) { // Check for the drop of a bookmark -> we want a Link action if (m_mimeData->hasFormat(QStringLiteral("application/x-xbel"))) { m_keyboardModifiers |= Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier); m_dropAction = Qt::LinkAction; } if (m_destItem.isNull() && m_destUrl.isLocalFile()) { m_destItem = KFileItem(m_destUrl); } if (!(m_flags & KIO::NoPrivilegeExecution)) { m_privilegeExecutionEnabled = true; switch (m_dropAction) { case Qt::CopyAction: m_operationType = Copy; break; case Qt::MoveAction: m_operationType = Move; break; case Qt::LinkAction: m_operationType = Symlink; break; default: m_operationType = Other; break; } } } bool destIsDirectory() const { if (!m_destItem.isNull()) { return m_destItem.isDir(); } // We support local dir, remote dir, local desktop file, local executable. // So for remote URLs, we just assume they point to a directory, the user will get an error from KIO::copy if not. return true; } void handleCopyToDirectory(); void handleDropToDesktopFile(); void handleDropToExecutable(); int determineDropAction(); void fillPopupMenu(KIO::DropMenu *popup); void addPluginActions(KIO::DropMenu *popup, const KFileItemListProperties &itemProps); void doCopyToDirectory(); const QMimeData *m_mimeData; const QList m_urls; QMap m_metaData; Qt::DropAction m_dropAction; QPoint m_relativePos; Qt::KeyboardModifiers m_keyboardModifiers; QUrl m_destUrl; KFileItem m_destItem; // null for remote URLs not found in the dirlister cache const JobFlags m_flags; QList m_appActions; QList m_pluginActions; bool m_triggered; // Tracks whether an action has been triggered in the popup menu. QSet m_menus; Q_DECLARE_PUBLIC(DropJob) void slotStart(); void slotTriggered(QAction *); void slotAboutToHide(); static inline DropJob *newJob(const QDropEvent *dropEvent, const QUrl &destUrl, JobFlags flags) { DropJob *job = new DropJob(*new DropJobPrivate(dropEvent, destUrl, flags)); job->setUiDelegate(KIO::createDefaultJobUiDelegate()); // Note: never KIO::getJobTracker()->registerJob here. // We don't want a progress dialog during the copy/move/link popup, it would in fact close // the popup return job; } }; DropMenu::DropMenu(QWidget *parent) : QMenu(parent), m_extraActionsSeparator(nullptr) { m_cancelAction = new QAction(i18n("C&ancel") + '\t' + QKeySequence(Qt::Key_Escape).toString(), this); m_cancelAction->setIcon(QIcon::fromTheme(QStringLiteral("process-stop"))); m_lastSeparator = new QAction(this); m_lastSeparator->setSeparator(true); } DropMenu::~DropMenu() { } void DropMenu::addExtraActions(const QList &appActions, const QList &pluginActions) { removeAction(m_lastSeparator); removeAction(m_cancelAction); removeAction(m_extraActionsSeparator); for (QAction *action : qAsConst(m_appActions)) { removeAction(action); } for (QAction *action : qAsConst(m_pluginActions)) { removeAction(action); } m_appActions = appActions; m_pluginActions = pluginActions; if (!m_appActions.isEmpty() || !m_pluginActions.isEmpty()) { if (!m_extraActionsSeparator) { m_extraActionsSeparator = new QAction(this); m_extraActionsSeparator->setSeparator(true); } addAction(m_extraActionsSeparator); addActions(appActions); addActions(pluginActions); } addAction(m_lastSeparator); addAction(m_cancelAction); } DropJob::DropJob(DropJobPrivate &dd) : Job(dd) { QTimer::singleShot(0, this, SLOT(slotStart())); } DropJob::~DropJob() { } void DropJobPrivate::slotStart() { Q_Q(DropJob); if (!m_urls.isEmpty()) { if (destIsDirectory()) { handleCopyToDirectory(); } else { // local file const QString destFile = m_destUrl.toLocalFile(); if (KDesktopFile::isDesktopFile(destFile)) { handleDropToDesktopFile(); } else if (QFileInfo(destFile).isExecutable()) { handleDropToExecutable(); } else { // should not happen, if KDirModel::flags is correct q->setError(KIO::ERR_ACCESS_DENIED); q->emitResult(); } } } else { // Dropping raw data KIO::PasteJob *job = KIO::PasteJobPrivate::newJob(m_mimeData, m_destUrl, KIO::HideProgressInfo, false /*not clipboard*/); QObject::connect(job, &KIO::PasteJob::itemCreated, q, &KIO::DropJob::itemCreated); q->addSubjob(job); } } // Input: m_dropAction as set by Qt at the time of the drop event // Output: m_dropAction possibly modified // Returns a KIO error code, in case of error. int DropJobPrivate::determineDropAction() { Q_Q(DropJob); if (!KProtocolManager::supportsWriting(m_destUrl)) { return KIO::ERR_CANNOT_WRITE; } if (!m_destItem.isNull() && !m_destItem.isWritable() && (m_flags & KIO::NoPrivilegeExecution)) { return KIO::ERR_WRITE_ACCESS_DENIED; } bool allItemsAreFromTrash = true; bool containsTrashRoot = false; foreach (const QUrl &url, m_urls) { const bool local = url.isLocalFile(); if (!local /*optimization*/ && url.scheme() == QLatin1String("trash")) { if (url.path().isEmpty() || url.path() == QLatin1String("/")) { containsTrashRoot = true; } } else { allItemsAreFromTrash = false; } if (url.matches(m_destUrl, QUrl::StripTrailingSlash)) { return KIO::ERR_DROP_ON_ITSELF; } } const bool trashing = m_destUrl.scheme() == QLatin1String("trash"); if (trashing) { m_dropAction = Qt::MoveAction; if (!q->uiDelegateExtension()->askDeleteConfirmation(m_urls, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { return KIO::ERR_USER_CANCELED; } return KJob::NoError; // ok } const bool implicitCopy = m_destUrl.scheme() == QLatin1String("stash"); if (implicitCopy) { m_dropAction = Qt::CopyAction; return KJob::NoError; // ok } if (containsTrashRoot) { // Dropping a link to the trash: don't move the full contents, just make a link (#319660) m_dropAction = Qt::LinkAction; return KJob::NoError; // ok } if (allItemsAreFromTrash) { // No point in asking copy/move/link when using dragging from the trash, just move the file out. m_dropAction = Qt::MoveAction; return KJob::NoError; // ok } if (m_keyboardModifiers & (Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier)) { // Qt determined m_dropAction from the modifiers already return KJob::NoError; // ok } // We need to ask the user with a popup menu. Let the caller know. return KIO::ERR_UNKNOWN; } void DropJobPrivate::fillPopupMenu(KIO::DropMenu *popup) { Q_Q(DropJob); // Check what the source can do // TODO: Determining the mimetype of the source URLs is difficult for remote URLs, // we would need to KIO::stat each URL in turn, asynchronously.... KFileItemList fileItems; foreach (const QUrl &url, m_urls) { fileItems.append(KFileItem(url)); } const KFileItemListProperties itemProps(fileItems); emit q->popupMenuAboutToShow(itemProps); const bool sReading = itemProps.supportsReading(); const bool sDeleting = itemProps.supportsDeleting(); const bool sMoving = itemProps.supportsMoving(); QString seq = QKeySequence(Qt::ShiftModifier).toString(); Q_ASSERT(seq.endsWith('+')); seq.chop(1); // chop superfluous '+' QAction* popupMoveAction = new QAction(i18n("&Move Here") + '\t' + seq, popup); popupMoveAction->setIcon(QIcon::fromTheme(QStringLiteral("go-jump"))); popupMoveAction->setData(QVariant::fromValue(Qt::MoveAction)); seq = QKeySequence(Qt::ControlModifier).toString(); Q_ASSERT(seq.endsWith('+')); seq.chop(1); QAction* popupCopyAction = new QAction(i18n("&Copy Here") + '\t' + seq, popup); popupCopyAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); popupCopyAction->setData(QVariant::fromValue(Qt::CopyAction)); seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString(); Q_ASSERT(seq.endsWith('+')); seq.chop(1); QAction* popupLinkAction = new QAction(i18n("&Link Here") + '\t' + seq, popup); popupLinkAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-link"))); popupLinkAction->setData(QVariant::fromValue(Qt::LinkAction)); if (sMoving || (sReading && sDeleting)) { bool equalDestination = true; foreach (const QUrl &src, m_urls) { if (!m_destUrl.matches(src.adjusted(QUrl::RemoveFilename), QUrl::StripTrailingSlash)) { equalDestination = false; break; } } if (!equalDestination) { popup->addAction(popupMoveAction); } } if (sReading) { popup->addAction(popupCopyAction); } popup->addAction(popupLinkAction); addPluginActions(popup, itemProps); popup->addSeparator(); } void DropJobPrivate::addPluginActions(KIO::DropMenu *popup, const KFileItemListProperties &itemProps) { const QVector plugin_offers = KPluginLoader::findPlugins(QStringLiteral("kf5/kio_dnd")); foreach (const KPluginMetaData &service, plugin_offers) { KPluginFactory *factory = KPluginLoader(service.fileName()).factory(); if (factory) { KIO::DndPopupMenuPlugin *plugin = factory->create(); if (plugin) { auto actions = plugin->setup(itemProps, m_destUrl); foreach (auto action, actions) { action->setParent(popup); } m_pluginActions += actions; } } } popup->addExtraActions(m_appActions, m_pluginActions); } void DropJob::setApplicationActions(const QList &actions) { Q_D(DropJob); d->m_appActions = actions; for (KIO::DropMenu *menu : qAsConst(d->m_menus)) { menu->addExtraActions(d->m_appActions, d->m_pluginActions); } } void DropJobPrivate::slotTriggered(QAction *action) { Q_Q(DropJob); if (m_appActions.contains(action) || m_pluginActions.contains(action)) { q->emitResult(); return; } const QVariant data = action->data(); if (!data.canConvert()) { q->setError(KIO::ERR_USER_CANCELED); q->emitResult(); return; } m_dropAction = data.value(); doCopyToDirectory(); } void DropJobPrivate::slotAboutToHide() { Q_Q(DropJob); // QMenu emits aboutToHide before triggered. // So we need to give the menu time in case it needs to emit triggered. // If it does, the cleanup will be done by slotTriggered. QTimer::singleShot(0, q, [=]() { if (!m_triggered) { q->setError(KIO::ERR_USER_CANCELED); q->emitResult(); } }); } void DropJobPrivate::handleCopyToDirectory() { Q_Q(DropJob); if (int error = determineDropAction()) { if (error == KIO::ERR_UNKNOWN) { auto window = KJobWidgets::window(q); KIO::DropMenu *menu = new KIO::DropMenu(window); QObject::connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater); // If the user clicks outside the menu, it will be destroyed without emitting the triggered signal. QObject::connect(menu, &QMenu::aboutToHide, q, [this]() { slotAboutToHide(); }); fillPopupMenu(menu); QObject::connect(menu, &QMenu::triggered, q, [this](QAction* action) { m_triggered = true; slotTriggered(action); }); menu->popup(window ? window->mapToGlobal(m_relativePos) : QCursor::pos()); m_menus.insert(menu); QObject::connect(menu, &QObject::destroyed, q, [this, menu]() { m_menus.remove(menu); }); } else { q->setError(error); q->emitResult(); } } else { doCopyToDirectory(); } } void DropJobPrivate::doCopyToDirectory() { Q_Q(DropJob); KIO::CopyJob * job = nullptr; switch (m_dropAction) { case Qt::MoveAction: job = KIO::move(m_urls, m_destUrl, m_flags); KIO::FileUndoManager::self()->recordJob( m_destUrl.scheme() == QLatin1String("trash") ? KIO::FileUndoManager::Trash : KIO::FileUndoManager::Move, m_urls, m_destUrl, job); break; case Qt::CopyAction: job = KIO::copy(m_urls, m_destUrl, m_flags); KIO::FileUndoManager::self()->recordCopyJob(job); break; case Qt::LinkAction: job = KIO::link(m_urls, m_destUrl, m_flags); KIO::FileUndoManager::self()->recordCopyJob(job); break; default: qCWarning(KIO_WIDGETS) << "Unknown drop action" << int(m_dropAction); q->setError(KIO::ERR_UNSUPPORTED_ACTION); q->emitResult(); return; } Q_ASSERT(job); job->setParentJob(q); job->setMetaData(m_metaData); QObject::connect(job, &KIO::CopyJob::copyingDone, q, [q](KIO::Job*, const QUrl &, const QUrl &to) { emit q->itemCreated(to); }); QObject::connect(job, &KIO::CopyJob::copyingLinkDone, q, [q](KIO::Job*, const QUrl&, const QString&, const QUrl &to) { emit q->itemCreated(to); }); q->addSubjob(job); emit q->copyJobStarted(job); } void DropJobPrivate::handleDropToDesktopFile() { Q_Q(DropJob); const QString urlKey = QStringLiteral("URL"); const QString destFile = m_destUrl.toLocalFile(); const KDesktopFile desktopFile(destFile); const KConfigGroup desktopGroup = desktopFile.desktopGroup(); if (desktopFile.hasApplicationType()) { // Drop to application -> start app with urls as argument KService service(destFile); if (!KRun::runService(service, m_urls, KJobWidgets::window(q))) { q->setError(KIO::ERR_CANNOT_LAUNCH_PROCESS); q->setErrorText(destFile); } q->emitResult(); } else if (desktopFile.hasLinkType() && desktopGroup.hasKey(urlKey)) { // Drop to link -> adjust destination directory m_destUrl = QUrl::fromUserInput(desktopGroup.readPathEntry(urlKey, QString())); handleCopyToDirectory(); } else { if (desktopFile.hasDeviceType()) { qCWarning(KIO_WIDGETS) << "Not re-implemented; please email kde-frameworks-devel@kde.org if you need this."; // take code from libkonq's old konq_operations.cpp // for now, fallback } // Some other kind of .desktop file (service, servicetype...) q->setError(KIO::ERR_UNSUPPORTED_ACTION); q->emitResult(); } } void DropJobPrivate::handleDropToExecutable() { Q_Q(DropJob); // Launch executable for each of the files QStringList args; Q_FOREACH(const QUrl &url, m_urls) { args << url.toLocalFile(); // assume local files } QProcess::startDetached(m_destUrl.toLocalFile(), args); q->emitResult(); } void DropJob::slotResult(KJob *job) { if (job->error()) { KIO::Job::slotResult(job); // will set the error and emit result(this) return; } removeSubjob(job); emitResult(); } DropJob * KIO::drop(const QDropEvent *dropEvent, const QUrl &destUrl, JobFlags flags) { return DropJobPrivate::newJob(dropEvent, destUrl, flags); } #include "moc_dropjob.cpp" diff --git a/src/widgets/fileundomanager_p.h b/src/widgets/fileundomanager_p.h index cdb51d33..3b350aac 100644 --- a/src/widgets/fileundomanager_p.h +++ b/src/widgets/fileundomanager_p.h @@ -1,179 +1,179 @@ /* This file is part of the KDE project Copyright (C) 2000 Simon Hausmann Copyright (C) 2006, 2008 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FILEUNDOMANAGER_P_H #define FILEUNDOMANAGER_P_H #include "fileundomanager.h" #include #include #include class KJob; namespace KIO { class FileUndoManagerAdaptor; struct BasicOperation { typedef QList Stack; BasicOperation() { m_valid = false; } bool m_valid; bool m_renamed; enum Type { File, Link, Directory }; Type m_type: 2; QUrl m_src; QUrl m_dst; QString m_target; QDateTime m_mtime; }; class UndoCommand { public: typedef QList Stack; UndoCommand() { m_valid = false; } // TODO: is ::TRASH missing? bool isMoveCommand() const { return m_type == FileUndoManager::Move || m_type == FileUndoManager::Rename; } bool m_valid; FileUndoManager::CommandType m_type; BasicOperation::Stack m_opStack; QList m_src; QUrl m_dst; quint64 m_serialNumber; }; // This class listens to a job, collects info while it's running (for copyjobs) // and when the job terminates, on success, it calls addCommand in the undomanager. class CommandRecorder : public QObject { Q_OBJECT public: CommandRecorder(FileUndoManager::CommandType op, const QList &src, const QUrl &dst, KIO::Job *job); virtual ~CommandRecorder(); private Q_SLOTS: void slotResult(KJob *job); void slotCopyingDone(KIO::Job *, const QUrl &from, const QUrl &to, const QDateTime &, bool directory, bool renamed); void slotCopyingLinkDone(KIO::Job *, const QUrl &from, const QString &target, const QUrl &to); void slotDirectoryCreated(const QUrl &url); void slotBatchRenamingDone(const QUrl &from, const QUrl &to); private: UndoCommand m_cmd; }; enum UndoState { MAKINGDIRS = 0, MOVINGFILES, STATINGFILE, REMOVINGDIRS, REMOVINGLINKS }; // The private class is, exceptionally, a real QObject // so that it can be the class with the DBUS adaptor forwarding its signals. class FileUndoManagerPrivate : public QObject { Q_OBJECT public: - FileUndoManagerPrivate(FileUndoManager *qq); + explicit FileUndoManagerPrivate(FileUndoManager *qq); ~FileUndoManagerPrivate() { delete m_uiInterface; } void pushCommand(const UndoCommand &cmd); void addDirToUpdate(const QUrl &url); void stepMakingDirectories(); void stepMovingFiles(); void stepRemovingLinks(); void stepRemovingDirectories(); /// called by FileUndoManagerAdaptor QByteArray get() const; friend class UndoJob; /// called by UndoJob void stopUndo(bool step); friend class UndoCommandRecorder; /// called by UndoCommandRecorder void addCommand(const UndoCommand &cmd); bool m_lock; UndoCommand::Stack m_commands; UndoCommand m_current; KIO::Job *m_currentJob; UndoState m_undoState; QStack m_dirStack; QStack m_dirCleanupStack; QStack m_fileCleanupStack; // files and links QList m_dirsToUpdate; FileUndoManager::UiInterface *m_uiInterface; UndoJob *m_undoJob; quint64 m_nextCommandIndex; FileUndoManager *q; // DBUS interface Q_SIGNALS: /// DBUS signal void push(const QByteArray &command); /// DBUS signal void pop(); /// DBUS signal void lock(); /// DBUS signal void unlock(); public Q_SLOTS: // Those four slots are connected to DBUS signals void slotPush(QByteArray); void slotPop(); void slotLock(); void slotUnlock(); void undoStep(); void slotResult(KJob *); }; } // namespace #endif /* FILEUNDOMANAGER_P_H */ diff --git a/src/widgets/kacleditwidget_p.h b/src/widgets/kacleditwidget_p.h index 1b058765..8263c809 100644 --- a/src/widgets/kacleditwidget_p.h +++ b/src/widgets/kacleditwidget_p.h @@ -1,220 +1,220 @@ /*************************************************************************** * Copyright (C) 2005 by Sean Harmer * * 2005 - 2007 Till Adam * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef KACLEDITWIDGET_P_H #define KACLEDITWIDGET_P_H #include #if HAVE_POSIX_ACL || defined(Q_MOC_RUN) #include #include #include #include #include #include #include #include class KACLListViewItem; class QButtonGroup; class KACLListView; class QStackedWidget; class QCheckBox; class QAbstractButton; class QColorGroup; /** @author Sean Harmer */ class KACLListView : public QTreeWidget { Q_OBJECT friend class KACLListViewItem; public: enum Types { OWNER_IDX = 0, GROUP_IDX, OTHERS_IDX, MASK_IDX, NAMED_USER_IDX, NAMED_GROUP_IDX, LAST_IDX }; enum EntryType { User = 1, Group = 2, Others = 4, Mask = 8, NamedUser = 16, NamedGroup = 32, AllTypes = 63 }; - KACLListView(QWidget *parent = nullptr); + explicit KACLListView(QWidget *parent = nullptr); ~KACLListView(); bool hasMaskEntry() const { return m_hasMask; } bool hasDefaultEntries() const; bool allowDefaults() const { return m_allowDefaults; } void setAllowDefaults(bool v) { m_allowDefaults = v; } unsigned short maskPermissions() const; void setMaskPermissions(unsigned short maskPerms); acl_perm_t maskPartialPermissions() const; void setMaskPartialPermissions(acl_perm_t maskPerms); bool maskCanBeDeleted() const; bool defaultMaskCanBeDeleted() const; const KACLListViewItem *findDefaultItemByType(EntryType type) const; const KACLListViewItem *findItemByType(EntryType type, bool defaults = false) const; unsigned short calculateMaskValue(bool defaults) const; void calculateEffectiveRights(); QStringList allowedUsers(bool defaults, KACLListViewItem *allowedItem = nullptr); QStringList allowedGroups(bool defaults, KACLListViewItem *allowedItem = nullptr); KACL getACL(); KACL getDefaultACL(); QPixmap getYesPixmap() const { return *m_yesPixmap; } QPixmap getYesPartialPixmap() const { return *m_yesPartialPixmap; } public Q_SLOTS: void slotAddEntry(); void slotEditEntry(); void slotRemoveEntry(); void setACL(const KACL &anACL); void setDefaultACL(const KACL &anACL); protected Q_SLOTS: void slotItemClicked(QTreeWidgetItem *pItem, int col); void slotItemDoubleClicked(QTreeWidgetItem *item, int col); protected: void contentsMousePressEvent(QMouseEvent *e); private: void fillItemsFromACL(const KACL &pACL, bool defaults = false); KACL itemsToACL(bool defaults) const; KACL m_ACL; KACL m_defaultACL; unsigned short m_mask; bool m_hasMask; bool m_allowDefaults; QStringList m_allUsers; QStringList m_allGroups; QPixmap *m_yesPixmap; QPixmap *m_yesPartialPixmap; }; class EditACLEntryDialog : public QDialog { Q_OBJECT public: EditACLEntryDialog(KACLListView *listView, KACLListViewItem *item, const QStringList &users, const QStringList &groups, const QStringList &defaultUsers, const QStringList &defaultGroups, int allowedTypes = KACLListView::AllTypes, int allowedDefaultTypes = KACLListView::AllTypes, bool allowDefault = false); KACLListViewItem *item() const { return m_item; } public Q_SLOTS: void slotOk(); void slotSelectionChanged(QAbstractButton *); private Q_SLOTS: void slotUpdateAllowedUsersAndGroups(); void slotUpdateAllowedTypes(); private: KACLListView *m_listView; KACLListViewItem *m_item; QStringList m_users; QStringList m_groups; QStringList m_defaultUsers; QStringList m_defaultGroups; int m_allowedTypes; int m_allowedDefaultTypes; QButtonGroup *m_buttonGroup; KComboBox *m_usersCombo; KComboBox *m_groupsCombo; QStackedWidget *m_widgetStack; QCheckBox *m_defaultCB; QHash m_buttonIds; }; class KACLListViewItem : public QTreeWidgetItem { public: KACLListViewItem(QTreeWidget *parent, KACLListView::EntryType type, unsigned short value, bool defaultEntry, const QString &qualifier = QString()); virtual ~KACLListViewItem(); QString key() const; bool operator< (const QTreeWidgetItem &other) const override; void calcEffectiveRights(); bool isDeletable() const; bool isAllowedToChangeType() const; void togglePerm(acl_perm_t perm); #if 0 virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment); #endif void updatePermPixmaps(); void repaint(); KACLListView::EntryType type; unsigned short value; bool isDefault; QString qualifier; bool isPartial; private: KACLListView *m_pACLListView; }; #endif #endif diff --git a/src/widgets/kdynamicjobtracker_p.h b/src/widgets/kdynamicjobtracker_p.h index 82944262..69d61e31 100644 --- a/src/widgets/kdynamicjobtracker_p.h +++ b/src/widgets/kdynamicjobtracker_p.h @@ -1,69 +1,69 @@ /* * Copyright 2008 by Rob Scheepmaker * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ #ifndef KDYNAMICJOBTRACKER_H #define KDYNAMICJOBTRACKER_H #include /** * This class implements a simple job tracker which registers any job to the KWidgetJobTracker if a * kuiserver isn't available on the DBus, or to the KUiServerJobTracker, if a kuiserver is * available. This way, we have the old dialogs as fallback when the user doesn't use a kuiserver * applet or application. */ class KDynamicJobTracker : public KJobTrackerInterface { Q_OBJECT public: /** * Creates a new KDynamicJobTracker * * @param parent the parent of this object. */ - KDynamicJobTracker(QObject *parent = nullptr); + explicit KDynamicJobTracker(QObject *parent = nullptr); /** * Destroys this KDynamicJobTracker */ virtual ~KDynamicJobTracker(); public Q_SLOTS: /** * Register a new job in this tracker. This call will get forwarded to either KWidgetJobTracker * or KUiServerJobTracker, depending on the availability of the Kuiserver. * * @param job the job to register */ void registerJob(KJob *job) override; /** * Unregister a job from the tracker it was registered to. * * @param job the job to unregister */ void unregisterJob(KJob *job) override; private: class Private; Private *const d; }; #endif diff --git a/src/widgets/kfileitemactions_p.h b/src/widgets/kfileitemactions_p.h index c240e59c..550bb63d 100644 --- a/src/widgets/kfileitemactions_p.h +++ b/src/widgets/kfileitemactions_p.h @@ -1,94 +1,94 @@ /* This file is part of the KDE project Copyright (C) 1998-2009 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KFILEITEMACTIONS_P_H #define KFILEITEMACTIONS_P_H #include #include #include #include #include #include #include class KFileItemActions; typedef QList ServiceList; class KFileItemActionsPrivate : public QObject { Q_OBJECT public: - KFileItemActionsPrivate(KFileItemActions *qq); + explicit KFileItemActionsPrivate(KFileItemActions *qq); ~KFileItemActionsPrivate(); int insertServicesSubmenus(const QMap &list, QMenu *menu, bool isBuiltin); int insertServices(const ServiceList &list, QMenu *menu, bool isBuiltin); // For "open with" KService::List associatedApplications(const QString &traderConstraint); QAction *createAppAction(const KService::Ptr &service, bool singleOffer); struct ServiceRank { int score; KService::Ptr service; }; // Inline function for sorting lists of ServiceRank static bool lessRank(const ServiceRank &id1, const ServiceRank &id2) { return id1.score < id2.score; } QStringList listMimeTypes(const KFileItemList &items); QStringList listPreferredServiceIds(const QStringList &mimeTypeList, const QString &traderConstraint); public Q_SLOTS: void slotRunPreferredApplications(); private: void openWithByMime(const KFileItemList &fileItems); private Q_SLOTS: // For servicemenus void slotExecuteService(QAction *act); // For "open with" applications void slotRunApplication(QAction *act); void slotOpenWithDialog(); public: KFileItemActions *const q; KFileItemListProperties m_props; QStringList m_mimeTypeList; QString m_traderConstraint; KFileItemList m_fileOpenList; QActionGroup m_executeServiceActionGroup; QActionGroup m_runApplicationActionGroup; QWidget *m_parentWidget; KConfig m_config; }; Q_DECLARE_METATYPE(KService::Ptr) Q_DECLARE_METATYPE(KServiceAction) #endif /* KFILEITEMACTIONS_P_H */ diff --git a/src/widgets/kopenwithdialog_p.h b/src/widgets/kopenwithdialog_p.h index f906b2df..8f29857c 100644 --- a/src/widgets/kopenwithdialog_p.h +++ b/src/widgets/kopenwithdialog_p.h @@ -1,110 +1,110 @@ /* This file is part of the KDE libraries Copyright (C) 2000 David Faure Copyright (C) 2007 Pino Toscano This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef OPENWITHDIALOG_P_H #define OPENWITHDIALOG_P_H #include #include #include class KApplicationModelPrivate; /** * @internal */ class KApplicationModel : public QAbstractItemModel { Q_OBJECT public: - KApplicationModel(QObject *parent = nullptr); + explicit KApplicationModel(QObject *parent = nullptr); virtual ~KApplicationModel(); bool canFetchMore(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; void fetchMore(const QModelIndex &parent) override; // Qt::ItemFlags flags(const QModelIndex &index) const override; bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QString entryPathFor(const QModelIndex &index) const; QString execFor(const QModelIndex &index) const; bool isDirectory(const QModelIndex &index) const; void fetchAll(const QModelIndex &parent); private: friend class KApplicationModelPrivate; KApplicationModelPrivate *const d; Q_DISABLE_COPY(KApplicationModel) }; /** * @internal */ class QTreeViewProxyFilter : public QSortFilterProxyModel { Q_OBJECT public: - QTreeViewProxyFilter(QObject *parent = nullptr); + explicit QTreeViewProxyFilter(QObject *parent = nullptr); bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; }; class KApplicationViewPrivate; /** * @internal */ class KApplicationView : public QTreeView { Q_OBJECT public: - KApplicationView(QWidget *parent = nullptr); + explicit KApplicationView(QWidget *parent = nullptr); ~KApplicationView(); void setModels(KApplicationModel *model, QSortFilterProxyModel *proxyModel); QSortFilterProxyModel* proxyModel(); bool isDirSel() const; Q_SIGNALS: void selected(const QString &_name, const QString &_exec); void highlighted(const QString &_name, const QString &_exec); protected Q_SLOTS: void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; private Q_SLOTS: void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); private: friend class KApplicationViewPrivate; KApplicationViewPrivate *const d; Q_DISABLE_COPY(KApplicationView) }; #endif diff --git a/src/widgets/kpropertiesdialog_p.h b/src/widgets/kpropertiesdialog_p.h index 0d5d2a20..13105b6f 100644 --- a/src/widgets/kpropertiesdialog_p.h +++ b/src/widgets/kpropertiesdialog_p.h @@ -1,301 +1,301 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis Copyright (c) 1999, 2000 Preston Brown Copyright (c) 2000 Simon Hausmann Copyright (c) 2000 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * This file holds the definitions for all classes used to * display a properties dialog. */ #ifndef KPROPERTIESDIALOGP_H #define KPROPERTIESDIALOGP_H #include "kpropertiesdialog.h" #include class QComboBox; class QLabel; namespace KDEPrivate { /** * 'General' plugin * This plugin displays the name of the file, its size and access times. * @internal */ class KFilePropsPlugin : public KPropertiesDialogPlugin { Q_OBJECT public: /** * Constructor */ - KFilePropsPlugin(KPropertiesDialog *_props); + explicit KFilePropsPlugin(KPropertiesDialog *_props); virtual ~KFilePropsPlugin(); /** * Applies all changes made. This plugin must be always the first * plugin in the dialog, since this function may rename the file which * may confuse other applyChanges functions. */ void applyChanges() override; /** * Tests whether the files specified by _items need a 'General' plugin. */ static bool supports(const KFileItemList &_items); /** * Called after all plugins applied their changes */ void postApplyChanges(); void setFileNameReadOnly(bool ro); protected Q_SLOTS: void slotEditFileType(); void slotCopyFinished(KJob *); void slotFileRenamed(KIO::Job *, const QUrl &, const QUrl &); void slotDirSizeUpdate(); void slotDirSizeFinished(KJob *); void slotFreeSpaceResult(KIO::Job *job, KIO::filesize_t size, KIO::filesize_t available); void slotSizeStop(); void slotSizeDetermine(); Q_SIGNALS: void leaveModality(); private Q_SLOTS: void nameFileChanged(const QString &text); void slotIconChanged(); private: bool enableIconButton() const; void determineRelativePath(const QString &path); void applyIconChanges(); class KFilePropsPluginPrivate; KFilePropsPluginPrivate *const d; }; /** * 'Permissions' plugin * In this plugin you can modify permissions and change * the owner of a file. * @internal */ class KFilePermissionsPropsPlugin : public KPropertiesDialogPlugin { Q_OBJECT public: enum PermissionsMode { PermissionsOnlyFiles = 0, PermissionsOnlyDirs = 1, PermissionsOnlyLinks = 2, PermissionsMixed = 3 }; enum PermissionsTarget { PermissionsOwner = 0, PermissionsGroup = 1, PermissionsOthers = 2 }; /** * Constructor */ - KFilePermissionsPropsPlugin(KPropertiesDialog *_props); + explicit KFilePermissionsPropsPlugin(KPropertiesDialog *_props); virtual ~KFilePermissionsPropsPlugin(); void applyChanges() override; /** * Tests whether the file specified by _items needs a 'Permissions' plugin. */ static bool supports(const KFileItemList &_items); private Q_SLOTS: void slotChmodResult(KJob *); void slotShowAdvancedPermissions(); Q_SIGNALS: void leaveModality(); private: void setComboContent(QComboBox *combo, PermissionsTarget target, mode_t permissions, mode_t partial); bool isIrregular(mode_t permissions, bool isDir, bool isLink); void enableAccessControls(bool enable); void updateAccessControls(); void getPermissionMasks(mode_t &andFilePermissions, mode_t &andDirPermissions, mode_t &orFilePermissions, mode_t &orDirPermissions); static const mode_t permissionsMasks[3]; static const mode_t standardPermissions[4]; static const char *const permissionsTexts[4][4]; static const mode_t fperm[3][4]; class KFilePermissionsPropsPluginPrivate; KFilePermissionsPropsPluginPrivate *const d; }; class KChecksumsPlugin : public KPropertiesDialogPlugin { Q_OBJECT public: - KChecksumsPlugin(KPropertiesDialog *dialog); + explicit KChecksumsPlugin(KPropertiesDialog *dialog); virtual ~KChecksumsPlugin(); static bool supports(const KFileItemList &items); private Q_SLOTS: void slotInvalidateCache(); void slotShowMd5(); void slotShowSha1(); void slotShowSha256(); /** * Compare @p input (required to be lowercase) with the checksum in cache. */ void slotVerifyChecksum(const QString &input); private: static bool isMd5(const QString &input); static bool isSha1(const QString &input); static bool isSha256(const QString &input); static QString computeChecksum(QCryptographicHash::Algorithm algorithm, const QString &path); static QCryptographicHash::Algorithm detectAlgorithm(const QString &input); void setDefaultState(); void setInvalidChecksumState(); void setMatchState(); void setMismatchState(); void setVerifyState(); void showChecksum(QCryptographicHash::Algorithm algorithm, QLabel *label, QPushButton *copyButton); QString cachedChecksum(QCryptographicHash::Algorithm algorithm) const; void cacheChecksum(const QString &checksum, QCryptographicHash::Algorithm algorithm); class KChecksumsPluginPrivate; KChecksumsPluginPrivate *const d; }; /** * Used to edit the files containing * [Desktop Entry] * URL=.... * * Such files are used to represent a program in kicker and konqueror. * @internal */ class KUrlPropsPlugin : public KPropertiesDialogPlugin { Q_OBJECT public: /** * Constructor */ - KUrlPropsPlugin(KPropertiesDialog *_props); + explicit KUrlPropsPlugin(KPropertiesDialog *_props); virtual ~KUrlPropsPlugin(); void applyChanges() override; void setFileNameReadOnly(bool ro); static bool supports(const KFileItemList &_items); private: class KUrlPropsPluginPrivate; KUrlPropsPluginPrivate *const d; }; /** * Properties plugin for device .desktop files * @internal */ class KDevicePropsPlugin : public KPropertiesDialogPlugin { Q_OBJECT public: - KDevicePropsPlugin(KPropertiesDialog *_props); + explicit KDevicePropsPlugin(KPropertiesDialog *_props); virtual ~KDevicePropsPlugin(); void applyChanges() override; static bool supports(const KFileItemList &_items); private Q_SLOTS: void slotActivated(int); void slotDeviceChanged(); void slotFoundMountPoint(const QString &mp, quint64 kibSize, quint64 kibUsed, quint64 kibAvail); private: void updateInfo(); private: class KDevicePropsPluginPrivate; KDevicePropsPluginPrivate *const d; }; /** * Used to edit the files containing * [Desktop Entry] * Type=Application * * Such files are used to represent a program in kicker and konqueror. * @internal */ class KDesktopPropsPlugin : public KPropertiesDialogPlugin { Q_OBJECT public: /** * Constructor */ - KDesktopPropsPlugin(KPropertiesDialog *_props); + explicit KDesktopPropsPlugin(KPropertiesDialog *_props); virtual ~KDesktopPropsPlugin(); void applyChanges() override; static bool supports(const KFileItemList &_items); public Q_SLOTS: void slotAddFiletype(); void slotDelFiletype(); void slotBrowseExec(); void slotAdvanced(); private: void checkCommandChanged(); private: class KDesktopPropsPluginPrivate; KDesktopPropsPluginPrivate *const d; }; } #endif