File indexing completed on 2024-05-12 04:58:12

0001 /* ============================================================
0002 * Copyright (C) 2012-2017  S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
0003 * This file is part of Falkon - Qt web browser 2010-2014
0004 * by  David Rosca <nowrep@gmail.com>
0005 *
0006 * This program is free software: you can redistribute it and/or modify
0007 * it under the terms of the GNU General Public License as published by
0008 * the Free Software Foundation, either version 3 of the License, or
0009 * (at your option) any later version.
0010 *
0011 * This program is distributed in the hope that it will be useful,
0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 * GNU General Public License for more details.
0015 *
0016 * You should have received a copy of the GNU General Public License
0017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 * ============================================================ */
0019 #ifndef REGISTERQAPPASSOCIATION_H
0020 #define REGISTERQAPPASSOCIATION_H
0021 
0022 #include <QObject>
0023 #include <QHash>
0024 #include <QPair>
0025 
0026 #include "qzcommon.h"
0027 
0028 class FALKON_EXPORT RegisterQAppAssociation : public QObject
0029 {
0030     Q_OBJECT
0031 public:
0032     explicit RegisterQAppAssociation(QObject* parent = nullptr);
0033     explicit RegisterQAppAssociation(const QString &appRegisteredName, const QString &appPath,
0034                                      const QString &appIcon = QString(), const QString &appDesc = QString(), QObject* parent = nullptr);
0035     ~RegisterQAppAssociation();
0036 
0037     enum AssociationType {
0038         FileAssociation,
0039         UrlAssociation
0040     };
0041 
0042     void addCapability(const QString &assocName, const QString &progId,
0043                        const QString &desc, const QString &iconPath, AssociationType type);
0044     void removeCapability(const QString &assocName);
0045 
0046     void setAppInfo(const QString &appRegisteredName, const QString &appPath,
0047                     const QString &appIcon = QString(), const QString &appDesc = QString());
0048 
0049     bool isPerMachineRegisteration();
0050     void setPerMachineRegisteration(bool enable);
0051     bool registerAppCapabilities();
0052     bool isVistaOrNewer();
0053     bool isWin10OrNewer();
0054     void registerAssociation(const QString &assocName, AssociationType type);
0055     void createProgId(const QString &progId);
0056 
0057     bool isDefaultApp(const QString &assocName, AssociationType type);
0058     bool isDefaultForAllCapabilities();
0059     void registerAllAssociation();
0060 
0061     bool showNativeDefaultAppSettingsUi();
0062 
0063 private:
0064     QString _appRegisteredName;
0065     QString _appPath;
0066     QString _appIcon;
0067     QString _appDesc;
0068     QString _UserRootKey;
0069 
0070     QHash<QString, QString> _fileAssocHash; // (extension, progId)
0071     QHash<QString, QString> _urlAssocHash; // (protocol, progId)
0072     QHash<QString, QPair<QString, QString> > _assocDescHash; // (progId, (desc, icon))
0073 };
0074 
0075 #endif // REGISTERQAPPASSOCIATION_H