File indexing completed on 2024-04-28 16:42:51

0001 // SPDX-FileCopyrightText: 2020 Jonah BrĂ¼chert <jbb@kaidan.im>
0002 // SPDX-FileCopyrightText: 2020 Bhushan Shah <bshah@kde.org>
0003 // SPDX-FileCopyrightText: 2021 Alexey Andreyev <aa13q@ya.ru>
0004 //
0005 // SPDX-License-Identifier: LicenseRef-KDE-Accepted-GPL
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 #include <QSqlDatabase>
0011 
0012 #include <kTelephonyMetaTypes/dialer-types.h>
0013 
0014 class CallHistoryDatabase : public QObject
0015 {
0016     Q_OBJECT
0017     Q_CLASSINFO("D-Bus Interface", "org.kde.telephony.CallHistoryDatabase")
0018 
0019 public:
0020     explicit CallHistoryDatabase(QObject *parent = nullptr);
0021 
0022     static void exec(QSqlQuery &query);
0023 
0024 Q_SIGNALS:
0025     void callsChanged();
0026 
0027 public Q_SLOTS:
0028     DialerTypes::CallDataVector fetchCalls();
0029     void addCall(const DialerTypes::CallData &callData);
0030     void clear();
0031     void remove(const QString &id);
0032     int lastId() const;
0033     QString lastCall(const QString &number, int direction) const;
0034 
0035 private:
0036     uint _guessPreHistoricRevision();
0037     void _migrationV1(uint current);
0038     void _migrationV2(uint current);
0039     void _migrate();
0040 
0041     QSqlDatabase _database;
0042 };