aboutsummaryrefslogtreecommitdiff
path: root/jiddb.h
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-06-12 23:47:17 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-06-29 14:09:46 +0200
commit05b2584fa4d773f5a88ed3ce98f5dd8304e11c34 (patch)
treef72e73c3259b8100e886f49f67ecc669b7667502 /jiddb.h
parent3b8fafc4122848219898245d52dabd669cacb4ba (diff)
First commit
Diffstat (limited to 'jiddb.h')
-rw-r--r--jiddb.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/jiddb.h b/jiddb.h
new file mode 100644
index 0000000..aba351a
--- /dev/null
+++ b/jiddb.h
@@ -0,0 +1,52 @@
+#ifndef JID_DB_H
+#define JID_DB_H
+
+#include "direction.h"
+#include <QDateTime>
+#include <QList>
+#include <QObject>
+#include <QString>
+#include <QStringList>
+#include <QSqlDatabase>
+
+class JidDb : public QObject
+{
+ Q_OBJECT
+
+public:
+ struct Message
+ {
+ Direction direction;
+ QDateTime dt;
+ QString contact, body;
+ };
+
+ struct Conversation
+ {
+ Conversation(const QString &to, const QString &last_msg,
+ const QDateTime &dt) :
+ to(to), last_msg(last_msg), dt(dt) {}
+ QString to, last_msg;
+ QDateTime dt;
+ };
+
+ JidDb(const QString &jid);
+ QStringList roster() const;
+ const QString jid;
+
+public Q_SLOTS:
+ QList<Conversation> getConversations() const;
+ QList<Message> getMessages(const QString &jid, int tail = -1) const;
+ void storeMessage(const Message &msg) const;
+ void addToRoster(const QString &jid);
+ void addToRoster(const QStringList &roster);
+
+Q_SIGNALS:
+ void addedToRoster(QString jid);
+
+private:
+ QSqlDatabase db;
+ void ensureContactDb(const QString &jid) const;
+};
+
+#endif