File indexing completed on 2024-05-19 05:49:20

0001 /***************************************************************************
0002  *   Copyright © 2009 Jonathan Thomas <echidnaman@kubuntu.org>             *
0003  *   Copyright © 2009-2021 Harald Sitter <apachelogger@kubuntu.org>        *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or         *
0006  *   modify it under the terms of the GNU General Public License as        *
0007  *   published by the Free Software Foundation; either version 2 of        *
0008  *   the License or (at your option) version 3 or any later version        *
0009  *   accepted by the membership of KDE e.V. (or its successor approved     *
0010  *   by the membership of KDE e.V.), which shall act as a proxy            *
0011  *   defined in Section 14 of version 3 of the license.                    *
0012  *                                                                         *
0013  *   This program is distributed in the hope that it will be useful,       *
0014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0016  *   GNU General Public License for more details.                          *
0017  *                                                                         *
0018  *   You should have received a copy of the GNU General Public License     *
0019  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0020  ***************************************************************************/
0021 
0022 #ifndef APPORTEVENT_H
0023 #define APPORTEVENT_H
0024 
0025 #include "../event.h"
0026 
0027 #include <QtCore/QFileInfo>
0028 
0029 class CrashFile
0030 {
0031 public:
0032     CrashFile(const QString &path)
0033         : m_path(path)
0034         , m_info(QFileInfo(path))
0035     {
0036     }
0037 
0038     CrashFile(const QFileInfo &info)
0039         : m_path(info.absoluteFilePath())
0040         , m_info(info)
0041     {
0042     }
0043 
0044     bool isAutoUploadAllowed() const {
0045         QString acceptPath = m_path;
0046         acceptPath.replace(QLatin1String(".crash"), QLatin1String(".drkonqi-accept"));
0047         return QFile(acceptPath).exists();
0048     }
0049 
0050     bool isValid() const {
0051         QString uploadPath = m_path; // Marked for upload -> ignore.
0052         uploadPath.replace(QLatin1String(".crash"), QLatin1String(".upload"));
0053         QString uploadedPath = m_path; // Alraedy uploaded -> ignore even more.
0054         uploadedPath.replace(QLatin1String(".crash"), QLatin1String(".uploaded"));
0055         return (!QFile(uploadPath).exists() &&
0056                 !QFile(uploadedPath).exists() &&
0057                 ((m_info.suffix() == QLatin1String("crash")) &&
0058                  (m_info.permission(QFile::ReadUser))));
0059     }
0060 
0061 private:
0062     QString m_path;
0063     QFileInfo m_info;
0064 };
0065 
0066 class ApportEvent : public Event
0067 {
0068     Q_OBJECT
0069 public:
0070     ApportEvent(QObject* parent);
0071 
0072     virtual ~ApportEvent();
0073 
0074 public slots:
0075     void show();
0076     void batchUploadAllowed();
0077 
0078 private slots:
0079     bool reportsAvailable();
0080     void run();
0081     void onDirty(const QString &path);
0082 private:
0083     void apportDirEvent();
0084 };
0085 
0086 #endif