Refactoring, account destruction fix, some thoughts about where to store contact settings (omemo enable status for instance)

This commit is contained in:
Blue 2023-03-16 22:38:05 +03:00
parent 283e9ebc4d
commit fffef9876a
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
15 changed files with 352 additions and 380 deletions

View file

@ -24,54 +24,43 @@ Core::Contact::Contact(const QString& pJid, const QString& account, QObject* par
groups(),
subscriptionState(Shared::SubscriptionState::unknown),
pep(Shared::Support::unknown)
{
}
{}
Core::Contact::~Contact()
{
}
Core::Contact::~Contact() {}
QSet<QString> Core::Contact::getGroups() const
{
QSet<QString> Core::Contact::getGroups() const {
return groups;
}
unsigned int Core::Contact::groupsCount() const
{
unsigned int Core::Contact::groupsCount() const {
return groups.size();
}
void Core::Contact::setGroups(const QSet<QString>& set)
{
void Core::Contact::setGroups(const QSet<QString>& set) {
QSet<QString> toRemove = groups - set;
QSet<QString> toAdd = set - groups;
groups = set;
for (QSet<QString>::iterator itr = toRemove.begin(), end = toRemove.end(); itr != end; ++itr) {
emit groupRemoved(*itr);
}
for (const QString& group : toRemove)
emit groupRemoved(group);
for (QSet<QString>::iterator itr = toAdd.begin(), end = toAdd.end(); itr != end; ++itr) {
emit groupAdded(*itr);
}
for (const QString& group : toAdd)
emit groupAdded(group);
}
Shared::SubscriptionState Core::Contact::getSubscriptionState() const
{
Shared::SubscriptionState Core::Contact::getSubscriptionState() const {
return subscriptionState;
}
void Core::Contact::setSubscriptionState(Shared::SubscriptionState state)
{
void Core::Contact::setSubscriptionState(Shared::SubscriptionState state) {
if (subscriptionState != state) {
subscriptionState = state;
emit subscriptionStateChanged(subscriptionState);
}
}
void Core::Contact::handlePresence(const QXmppPresence& pres)
{
void Core::Contact::handlePresence(const QXmppPresence& pres) {
switch (pres.vCardUpdateType()) {
case QXmppPresence::VCardUpdateNone: //this presence has nothing to do with photo
break;
@ -101,13 +90,21 @@ void Core::Contact::handlePresence(const QXmppPresence& pres)
}
void Core::Contact::setPepSupport(Shared::Support support) {
if (pep != support) {
if (pep != support)
pep = support;
}
}
Shared::Support Core::Contact::getPepSupport() const {
return pep;}
return pep;
}
QMap<QString, QVariant> Core::Contact::getInfo() const {
QMap<QString, QVariant> data = RosterItem::getInfo();
data.insert("state", QVariant::fromValue(subscriptionState));
return data;
}