forked from blue/squawk
first moves to safe pasword storing, preparing the structure
This commit is contained in:
parent
ddfb3419cc
commit
3477226367
21 changed files with 288 additions and 153 deletions
|
@ -28,7 +28,8 @@ Models::Account::Account(const QMap<QString, QVariant>& data, Models::Item* pare
|
|||
error(data.value("error").toString()),
|
||||
avatarPath(data.value("avatarPath").toString()),
|
||||
state(Shared::ConnectionState::disconnected),
|
||||
availability(Shared::Availability::offline)
|
||||
availability(Shared::Availability::offline),
|
||||
passwordType(Shared::AccountPassword::plain)
|
||||
{
|
||||
QMap<QString, QVariant>::const_iterator sItr = data.find("state");
|
||||
if (sItr != data.end()) {
|
||||
|
@ -155,6 +156,8 @@ QVariant Models::Account::data(int column) const
|
|||
return resource;
|
||||
case 8:
|
||||
return avatarPath;
|
||||
case 9:
|
||||
return Shared::Global::getName(passwordType);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -162,7 +165,7 @@ QVariant Models::Account::data(int column) const
|
|||
|
||||
int Models::Account::columnCount() const
|
||||
{
|
||||
return 9;
|
||||
return 10;
|
||||
}
|
||||
|
||||
void Models::Account::update(const QString& field, const QVariant& value)
|
||||
|
@ -185,6 +188,8 @@ void Models::Account::update(const QString& field, const QVariant& value)
|
|||
setError(value.toString());
|
||||
} else if (field == "avatarPath") {
|
||||
setAvatarPath(value.toString());
|
||||
} else if (field == "passwordType") {
|
||||
setPasswordType(value.toUInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,3 +245,22 @@ QString Models::Account::getFullJid() const
|
|||
{
|
||||
return getBareJid() + "/" + resource;
|
||||
}
|
||||
|
||||
Shared::AccountPassword Models::Account::getPasswordType() const
|
||||
{
|
||||
return passwordType;
|
||||
}
|
||||
|
||||
void Models::Account::setPasswordType(Shared::AccountPassword pt)
|
||||
{
|
||||
if (passwordType != pt) {
|
||||
passwordType = pt;
|
||||
changed(9);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Account::setPasswordType(unsigned int pt)
|
||||
{
|
||||
setPasswordType(Shared::Global::fromInt<Shared::AccountPassword>(pt));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef MODELS_ACCOUNT_H
|
||||
#define MODELS_ACCOUNT_H
|
||||
|
||||
#include "item.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/utils.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
#include "item.h"
|
||||
#include <QVariant>
|
||||
#include <QIcon>
|
||||
|
||||
|
@ -60,6 +60,10 @@ namespace Models {
|
|||
void setAvailability(unsigned int p_avail);
|
||||
Shared::Availability getAvailability() const;
|
||||
|
||||
void setPasswordType(Shared::AccountPassword pt);
|
||||
void setPasswordType(unsigned int pt);
|
||||
Shared::AccountPassword getPasswordType() const;
|
||||
|
||||
QIcon getStatusIcon(bool big = false) const;
|
||||
|
||||
QVariant data(int column) const override;
|
||||
|
@ -79,6 +83,7 @@ namespace Models {
|
|||
QString avatarPath;
|
||||
Shared::ConnectionState state;
|
||||
Shared::Availability availability;
|
||||
Shared::AccountPassword passwordType;
|
||||
|
||||
protected slots:
|
||||
void toOfflineState() override;
|
||||
|
|
|
@ -58,11 +58,11 @@ QVariant Models::Participant::data(int column) const
|
|||
{
|
||||
switch (column) {
|
||||
case 4:
|
||||
return static_cast<uint8_t>(affiliation);
|
||||
return QVariant::fromValue(affiliation);
|
||||
case 5:
|
||||
return static_cast<uint8_t>(role);
|
||||
return QVariant::fromValue(role);
|
||||
case 6:
|
||||
return static_cast<quint8>(getAvatarState());
|
||||
return QVariant::fromValue(getAvatarState());
|
||||
case 7:
|
||||
return getAvatarPath();
|
||||
default:
|
||||
|
@ -100,12 +100,7 @@ void Models::Participant::setAffiliation(Shared::Affiliation p_aff)
|
|||
|
||||
void Models::Participant::setAffiliation(unsigned int aff)
|
||||
{
|
||||
if (aff <= static_cast<uint8_t>(Shared::affiliationHighest)) {
|
||||
Shared::Affiliation affil = static_cast<Shared::Affiliation>(aff);
|
||||
setAffiliation(affil);
|
||||
} else {
|
||||
qDebug() << "An attempt to set wrong affiliation" << aff << "to the room participant" << name;
|
||||
}
|
||||
setAffiliation(Shared::Global::fromInt<Shared::Affiliation>(aff));
|
||||
}
|
||||
|
||||
Shared::Role Models::Participant::getRole() const
|
||||
|
@ -123,12 +118,7 @@ void Models::Participant::setRole(Shared::Role p_role)
|
|||
|
||||
void Models::Participant::setRole(unsigned int p_role)
|
||||
{
|
||||
if (p_role <= static_cast<uint8_t>(Shared::roleHighest)) {
|
||||
Shared::Role r = static_cast<Shared::Role>(p_role);
|
||||
setRole(r);
|
||||
} else {
|
||||
qDebug() << "An attempt to set wrong role" << p_role << "to the room participant" << name;
|
||||
}
|
||||
setRole(Shared::Global::fromInt<Shared::Role>(p_role));
|
||||
}
|
||||
|
||||
QString Models::Participant::getAvatarPath() const
|
||||
|
@ -158,11 +148,4 @@ void Models::Participant::setAvatarState(Shared::Avatar p_state)
|
|||
}
|
||||
|
||||
void Models::Participant::setAvatarState(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= static_cast<quint8>(Shared::Avatar::valid)) {
|
||||
Shared::Avatar state = static_cast<Shared::Avatar>(p_state);
|
||||
setAvatarState(state);
|
||||
} else {
|
||||
qDebug() << "An attempt to set invalid avatar state" << p_state << "to the room participant" << name << ", skipping";
|
||||
}
|
||||
}
|
||||
{setAvatarState(Shared::Global::fromInt<Shared::Avatar>(p_state));}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define MODELS_PARTICIPANT_H
|
||||
|
||||
#include "abstractparticipant.h"
|
||||
#include "shared/global.h"
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue