summaryrefslogtreecommitdiff
path: root/credentials.h
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-02-03 15:59:29 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2026-02-03 16:26:52 +0100
commitfdb64c59865e4db76addfb8222f6421443e25240 (patch)
tree0de2bad9f758c69b7fb9ba2670653c8515a3a70d /credentials.h
parent207176de48d5e44c8d3e6318b526db5d772dd008 (diff)
downloadyachat6-fdb64c59865e4db76addfb8222f6421443e25240.tar.gz
Import files from xxcc
Diffstat (limited to 'credentials.h')
-rw-r--r--credentials.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/credentials.h b/credentials.h
new file mode 100644
index 0000000..100729b
--- /dev/null
+++ b/credentials.h
@@ -0,0 +1,45 @@
+#ifndef CREDENTIALS_H
+#define CREDENTIALS_H
+
+#include "client.h"
+#include <QXmppTask.h>
+#include <QXmppPromise.h>
+#include <QObject>
+#include <QList>
+#include <QPair>
+#include <QStringList>
+#include <variant>
+
+class Credentials : public QObject
+{
+ Q_OBJECT
+public:
+ struct Success {};
+ struct Error
+ {
+ QString description;
+ };
+
+ using Pair = QPair<QString, QString>;
+ using PairList = QList<Pair>;
+ using StoreResult = std::variant<Success, Error>;
+ using LoadResult = std::variant<QString, Error>;
+ using PairListResult = std::variant<PairList, Error>;
+
+ QXmppTask<PairListResult> load();
+ QXmppTask<StoreResult> store(Client *c);
+
+private:
+ using Users = std::variant<QStringList, Error>;
+
+ QXmppTask<StoreResult> store(const QString &key, const QString &value);
+ QXmppTask<StoreResult> store(const QString &user);
+ QXmppTask<LoadResult> load(const QString &key);
+ QXmppTask<LoadResult> storedUsersList();
+ QXmppTask<Users> storedUsers();
+ QXmppTask<PairListResult> load(PairList &pairs,
+ QStringList::const_iterator &it,
+ QStringList::const_iterator end);
+};
+
+#endif