| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2008 David Faure <[email protected]> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #ifndef KMIMEASSOCIATIONS_H |
| 9 | #define KMIMEASSOCIATIONS_Hcxx . . $ `src/sycoca/kmimeassociations_p.h:9:9`! |
| 10 | |
| 11 | #include <QHash> |
| 12 | #include <QSet> |
| 13 | #include <kserviceoffer.h>cxx . . $ `<file>/src/services/kserviceoffer.h`/ |
| 14 | class KConfigGroupcxx . . $ KConfigGroup#; |
| 15 | class KServiceFactorycxx . . $ KServiceFactory#; |
| 16 | |
| 17 | struct ServiceTypeOffersDatacxx . . $ ServiceTypeOffersData# { |
| 18 | QListcxx . . $ QList#<KServiceOffercxx . . $ KServiceOffer#> offerscxx . . $ ServiceTypeOffersData#offers.; // service + initial preference + allow as default |
| 19 | QSetcxx . . $ QSet#<KServicecxx . . $ KService#::Ptrcxx . . $ KService#Ptr#> offerSetcxx . . $ ServiceTypeOffersData#offerSet.; // for quick contains() check |
| 20 | QSetcxx . . $ QSet#<KServicecxx . . $ KService#::Ptrcxx . . $ KService#Ptr#> removedOfferscxx . . $ ServiceTypeOffersData#removedOffers.; // remember removed offers explicitly |
| 21 | }; |
| 22 | |
| 23 | class KOfferHashcxx . . $ KOfferHash# |
| 24 | { |
| 25 | public: |
| 26 | KOfferHashcxx . . $ KOfferHash#KOfferHash(49f6e7a06ebc5aa8).() |
| 27 | { |
| 28 | } |
| 29 | KOfferHashcxx . . $ KOfferHash#KOfferHash(7c23f6793ad6e2e).(const KOfferHashcxx . . $ KOfferHash# &) = delete; |
| 30 | KOfferHashcxx . . $ KOfferHash# &operatorcxx . . $ KOfferHash#`operator=`(10c978ae344c2672).=(const KOfferHashcxx . . $ KOfferHash# &) = delete; |
| 31 | QListcxx . . $ QList#<KServiceOffercxx . . $ KServiceOffer#> offersForcxx . . $ KOfferHash#offersFor(5e71bc0214a2b7e9).(const QStringcxx . . $ QString# &serviceType) const |
| 32 | { |
| 33 | auto it = m_serviceTypeDatacxx . . $ KOfferHash#m_serviceTypeData..constFindcxx . . $ QHash#constFind(8350f99e9328307f).(serviceType); |
| 34 | if (it !=cxx . . $ QHash#const_iterator#`operator!=`(ed375b04c2ec1e10). m_serviceTypeDatacxx . . $ KOfferHash#m_serviceTypeData..cendcxx . . $ QHash#cend(bacd0392ad39bf1c).()) { |
| 35 | return itcxx . . $ QList#QList(3d2301cfd89f773a)..valuecxx . . $ QHash#const_iterator#value(bdbd05d619d62250).().offerscxx . . $ ServiceTypeOffersData#offers.; |
| 36 | } |
| 37 | return QListcxx . . $ QList#<KServiceOffercxx . . $ KServiceOffer#>(); |
| 38 | } |
| 39 | void addServiceOffercxx . . $ KOfferHash#addServiceOffer(2898aa0e817ca398).(const QStringcxx . . $ QString# &serviceType, const KServiceOffercxx . . $ KServiceOffer# &offer); |
| 40 | void removeServiceOffercxx . . $ KOfferHash#removeServiceOffer(452febd1e20f965b).(const QStringcxx . . $ QString# &serviceType, const KServicecxx . . $ KService#::Ptrcxx . . $ KService#Ptr# &service); |
| 41 | bool hasRemovedOffercxx . . $ KOfferHash#hasRemovedOffer(c77fe6fed0a958f2).(const QStringcxx . . $ QString# &serviceType, const KServicecxx . . $ KService#::Ptrcxx . . $ KService#Ptr# &service) const; |
| 42 | |
| 43 | const QHashcxx . . $ QHash#<QStringcxx . . $ QString#, ServiceTypeOffersDatacxx . . $ ServiceTypeOffersData#> &serviceTypeDatacxx . . $ KOfferHash#serviceTypeData(94fa7fdae4f4931f).() const |
| 44 | { |
| 45 | return m_serviceTypeDatacxx . . $ KOfferHash#m_serviceTypeData.; |
| 46 | } |
| 47 | |
| 48 | private: |
| 49 | QHashcxx . . $ QHash#<QStringcxx . . $ QString#, ServiceTypeOffersDatacxx . . $ ServiceTypeOffersData#> m_serviceTypeDatacxx . . $ KOfferHash#m_serviceTypeData.; |
| 50 | }; |
| 51 | |
| 52 | /** |
| 53 | * Parse mimeapps.list files and: |
| 54 | * - modify MIME type associations in the relevant services (using KServiceFactory) |
| 55 | * - remember preference order specified by user |
| 56 | */ |
| 57 | class KMimeAssociationscxx . . $ KMimeAssociations# |
| 58 | { |
| 59 | public: |
| 60 | explicit KMimeAssociationscxx . . $ KMimeAssociations#KMimeAssociations(9b28e7bd17fb482a).(KOfferHashcxx . . $ KOfferHash# &offerHash, KServiceFactorycxx . . $ KServiceFactory# *serviceFactory); |
| 61 | |
| 62 | static QStringListcxx . . $ QStringList# mimeAppsFilescxx . . $ KMimeAssociations#mimeAppsFiles(669a05bc42dd57cc).(); |
| 63 | |
| 64 | // Read mimeapps.list files |
| 65 | void parseAllMimeAppsListcxx . . $ KMimeAssociations#parseAllMimeAppsList(49f6e7a06ebc5aa8).(); |
| 66 | |
| 67 | void parseMimeAppsListcxx . . $ KMimeAssociations#parseMimeAppsList(29ed8fcd127906b1).(const QStringcxx . . $ QString# &file, int basePreference); |
| 68 | |
| 69 | private: |
| 70 | static QStringListcxx . . $ QStringList# mimeAppsDirscxx . . $ KMimeAssociations#mimeAppsDirs(669a05bc42dd57cc).(); |
| 71 | |
| 72 | void parseAddedAssociationscxx . . $ KMimeAssociations#parseAddedAssociations(aee6b0d7fa94e14c).(const KConfigGroupcxx . . $ KConfigGroup# &group, const QStringcxx . . $ QString# &file, int basePreference); |
| 73 | void parseRemovedAssociationscxx . . $ KMimeAssociations#parseRemovedAssociations(48c5e19c69481ee4).(const KConfigGroupcxx . . $ KConfigGroup# &group, const QStringcxx . . $ QString# &file); |
| 74 | |
| 75 | KOfferHashcxx . . $ KOfferHash# &m_offerHashcxx . . $ KMimeAssociations#m_offerHash.; |
| 76 | KServiceFactorycxx . . $ KServiceFactory# *m_serviceFactorycxx . . $ KMimeAssociations#m_serviceFactory.; |
| 77 | }; |
| 78 | |
| 79 | #endif /* KMIMEASSOCIATIONS_H */ |