File indexing completed on 2025-01-05 04:49:19
0001 /* 0002 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <KAddressBookImportExport/ExportSelectionWidget> 0010 #include <KAddressBookImportExport/PluginInterface> 0011 #include <KContacts/Addressee> 0012 0013 class VCardImportExportPluginInterface : public KAddressBookImportExport::PluginInterface 0014 { 0015 Q_OBJECT 0016 public: 0017 explicit VCardImportExportPluginInterface(QObject *parent = nullptr); 0018 ~VCardImportExportPluginInterface() override; 0019 0020 void createAction(KActionCollection *ac) override; 0021 void exec() override; 0022 [[nodiscard]] bool canImportFileType(const QUrl &url) override; 0023 0024 private: 0025 enum ExportVCardType { 0026 VCard2_1 = 0, 0027 VCard3, 0028 VCard4, 0029 }; 0030 KContacts::Addressee::List parseVCard(const QByteArray &data) const; 0031 KContacts::Addressee::List filterContacts(const KContacts::Addressee::List &addrList, 0032 KAddressBookImportExport::ExportSelectionWidget::ExportFields exportFieldType) const; 0033 void addKey(KContacts::Addressee &addr, KContacts::Key::Type type) const; 0034 0035 void exportVCard(); 0036 void importVCard(); 0037 void slotImportVCard(); 0038 void slotExportVCard4(); 0039 void slotExportVCard3(); 0040 [[nodiscard]] QString contactFileName(const KContacts::Addressee &contact) const; 0041 void slotExportVCard2(); 0042 [[nodiscard]] bool doExport(const QUrl &url, const QByteArray &data) const; 0043 0044 ExportVCardType mExportVCardType; 0045 };