forked from blue/squawk
Refactoring, account destruction fix, some thoughts about where to store contact settings (omemo enable status for instance)
This commit is contained in:
parent
283e9ebc4d
commit
fffef9876a
15 changed files with 352 additions and 380 deletions
|
@ -29,6 +29,7 @@ Core::Archive::Archive(const QString& p_jid, QObject* parent):
|
|||
jid(p_jid),
|
||||
opened(false),
|
||||
fromTheBeginning(false),
|
||||
encryptionEnabled(false),
|
||||
environment(),
|
||||
main(),
|
||||
order(),
|
||||
|
@ -84,6 +85,12 @@ void Core::Archive::open(const QString& account)
|
|||
} catch (const NotFound& e) {
|
||||
fromTheBeginning = false;
|
||||
}
|
||||
|
||||
try {
|
||||
encryptionEnabled = getStatBoolValue("encryptionEnabled", txn);
|
||||
} catch (const NotFound& e) {
|
||||
encryptionEnabled = false;
|
||||
}
|
||||
|
||||
std::string sJid = jid.toStdString();
|
||||
AvatarInfo info;
|
||||
|
@ -603,7 +610,7 @@ std::list<Shared::Message> Core::Archive::getBefore(int count, const QString& id
|
|||
return res;
|
||||
}
|
||||
|
||||
bool Core::Archive::isFromTheBeginning()
|
||||
bool Core::Archive::isFromTheBeginning() const
|
||||
{
|
||||
if (!opened) {
|
||||
throw Closed("isFromTheBeginning", jid.toStdString());
|
||||
|
@ -630,6 +637,35 @@ void Core::Archive::setFromTheBeginning(bool is)
|
|||
}
|
||||
}
|
||||
|
||||
bool Core::Archive::isEncryptionEnabled() const
|
||||
{
|
||||
if (!opened) {
|
||||
throw Closed("isEncryptionEnabled", jid.toStdString());
|
||||
}
|
||||
return encryptionEnabled;
|
||||
}
|
||||
|
||||
bool Core::Archive::setEncryptionEnabled(bool is)
|
||||
{
|
||||
if (!opened) {
|
||||
throw Closed("setEncryptionEnabled", jid.toStdString());
|
||||
}
|
||||
if (encryptionEnabled != is) {
|
||||
encryptionEnabled = is;
|
||||
|
||||
MDB_txn *txn;
|
||||
mdb_txn_begin(environment, NULL, 0, &txn);
|
||||
bool success = setStatValue("encryptionEnabled", is, txn);
|
||||
if (success) {
|
||||
mdb_txn_commit(txn);
|
||||
return true;
|
||||
} else {
|
||||
mdb_txn_abort(txn);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Core::Archive::idByStanzaId(const QString& stanzaId) const
|
||||
{
|
||||
if (!opened) {
|
||||
|
|
|
@ -55,8 +55,10 @@ public:
|
|||
void clear();
|
||||
long unsigned int size() const;
|
||||
std::list<Shared::Message> getBefore(int count, const QString& id);
|
||||
bool isFromTheBeginning();
|
||||
bool isFromTheBeginning() const;
|
||||
void setFromTheBeginning(bool is);
|
||||
bool isEncryptionEnabled() const;
|
||||
bool setEncryptionEnabled(bool is); //returns true if changed, false otherwise
|
||||
bool setAvatar(const QByteArray& data, AvatarInfo& info, bool generated = false, const QString& resource = "");
|
||||
AvatarInfo getAvatarInfo(const QString& resource = "") const;
|
||||
bool readAvatarInfo(AvatarInfo& target, const QString& resource = "") const;
|
||||
|
@ -171,6 +173,7 @@ public:
|
|||
private:
|
||||
bool opened;
|
||||
bool fromTheBeginning;
|
||||
bool encryptionEnabled;
|
||||
MDB_env* environment;
|
||||
MDB_dbi main; //id to message
|
||||
MDB_dbi order; //time to id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue