summaryrefslogtreecommitdiffstats
path: root/pbap.h
diff options
context:
space:
mode:
authorMatt Porter <mporter@konsulko.com>2018-06-19 14:56:26 -0400
committerMatt Porter <mporter@konsulko.com>2018-06-22 16:38:30 -0400
commite8b328e0516d8ead9af13c8379a6cd1dbbb8a9e9 (patch)
treedec002e6adcf197c3ac7913fb211b65b73772bc9 /pbap.h
parentfc65716b43af6be84d42599d813d3d40df07d376 (diff)
pbap: add contacts support and recent call model
Add support for parsing contacts and recent call data from the PBAP-provided vCards using libvcard. Expose a recent call list model and interfaces to refresh the data. Bug-AGL: SPEC-1436 Change-Id: Ia4a02443e22e4a27dc974ef414b765667b26ff83 Signed-off-by: Matt Porter <mporter@konsulko.com>
Diffstat (limited to 'pbap.h')
-rw-r--r--pbap.h116
1 files changed, 114 insertions, 2 deletions
diff --git a/pbap.h b/pbap.h
index f5e675b..2a5fb61 100644
--- a/pbap.h
+++ b/pbap.h
@@ -20,28 +20,140 @@
#include <QDebug>
#include <QObject>
#include <QJsonArray>
+#include <QtQml/QQmlContext>
#include "messageengine.h"
+class PhoneNumber : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString number READ number NOTIFY numberChanged)
+ Q_PROPERTY(int type READ type NOTIFY typeChanged)
+
+ public:
+ explicit PhoneNumber(QString number, QString type);
+ virtual ~PhoneNumber();
+
+ QString number() {return m_number;};
+ int type() {return m_type;};
+
+ enum PhoneNumberType {
+ UNKNOWN,
+ VOICE,
+ CELL,
+ HOME,
+ WORK,
+ FAX,
+ };
+ Q_ENUM(PhoneNumberType)
+
+ signals:
+ void numberChanged();
+ void typeChanged();
+
+ private:
+ QString m_number;
+ int m_type;
+ int stringToEnum(QString);
+};
+
+class Contact : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name NOTIFY nameChanged)
+ Q_PROPERTY(QList<QObject *>numbers READ numbers NOTIFY numbersChanged)
+
+ public:
+ explicit Contact(QString name, QList<QObject *>numbers);
+ virtual ~Contact();
+
+ QString name() {return m_name;};
+ QList<QObject *>numbers() {return m_numbers;};
+
+ signals:
+ void nameChanged();
+ void numbersChanged();
+
+ private:
+ QString m_name;
+ QList<QObject *>m_numbers;
+};
+
+class RecentCall : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name NOTIFY nameChanged)
+ Q_PROPERTY(QString number READ number NOTIFY numberChanged)
+ Q_PROPERTY(QString datetime READ datetime NOTIFY datetimeChanged)
+ Q_PROPERTY(int type READ type NOTIFY typeChanged)
+
+ public:
+ explicit RecentCall(QString name, QString number, QString datetime, QString type);
+ virtual ~RecentCall();
+
+ QString name() {return m_name;};
+ QString number() {return m_number;};
+ QString datetime() {return m_datetime;};
+ int type() {return m_type;};
+
+ enum RecentCallType {
+ UNKNOWN,
+ MISSED,
+ RECEIVED,
+ DIALED,
+ };
+ Q_ENUM(RecentCallType)
+
+ signals:
+ void nameChanged();
+ void numberChanged();
+ void datetimeChanged();
+ void typeChanged();
+
+ private:
+ QString m_name;
+ QString m_number;
+ QString m_datetime;
+ int m_type;
+ int stringToEnum(QString);
+};
+
class Pbap : public QObject
{
Q_OBJECT
public:
- explicit Pbap(QUrl &url, QObject * parent = Q_NULLPTR);
+ explicit Pbap(QUrl &url, QQmlContext *context, QObject * parent = Q_NULLPTR);
virtual ~Pbap();
+ Q_INVOKABLE void refreshContacts(int max_entries);
+ Q_INVOKABLE void refreshCalls(int max_entries);
Q_INVOKABLE void search(QString number);
signals:
- void searchResults(QString name);
+ void searchResults(QString name);
+ void statusChanged(bool connected);
private:
MessageEngine *m_mloop;
+ QQmlContext *m_context;
+ QList<QObject *>m_contacts;
+ QList<QObject *>m_calls;
+ void updateContacts(QString);
+ void updateCalls(QString);
void sendSearchResults(QJsonArray);
// slots
+ void onConnected();
+ void onDisconnected();
void onMessageReceived(MessageType, Message*);
+
+ const QStringList events {
+ "status",
+ };
};
#endif // PBAP_H