Merge branch 'feature/new-gui' of github.com:amnezia-vpn/amnezia-client into feature/new-gui
This commit is contained in:
commit
3034019d5a
10 changed files with 87 additions and 88 deletions
|
@ -69,14 +69,14 @@ void SshConfigurator::openSshTerminal(const ServerCredentials &credentials)
|
|||
p->setProcessEnvironment(prepareEnv());
|
||||
p->setProgram(qApp->applicationDirPath() + "\\cygwin\\putty.exe");
|
||||
|
||||
if (credentials.password.contains("PRIVATE KEY")) {
|
||||
if (credentials.secretData.contains("PRIVATE KEY")) {
|
||||
// todo: connect by key
|
||||
// p->setNativeArguments(QString("%1@%2")
|
||||
// .arg(credentials.userName).arg(credentials.hostName).arg(credentials.password));
|
||||
// .arg(credentials.userName).arg(credentials.hostName).arg(credentials.secretData));
|
||||
}
|
||||
else {
|
||||
p->setNativeArguments(QString("%1@%2 -pw %3")
|
||||
.arg(credentials.userName).arg(credentials.hostName).arg(credentials.password));
|
||||
.arg(credentials.userName).arg(credentials.hostName).arg(credentials.secretData));
|
||||
}
|
||||
#else
|
||||
p->setProgram("/bin/bash");
|
||||
|
|
|
@ -35,14 +35,14 @@ Ikev2Protocol::~Ikev2Protocol()
|
|||
|
||||
void Ikev2Protocol::stop()
|
||||
{
|
||||
setConnectionState(VpnProtocol::Disconnecting);
|
||||
setConnectionState(Vpn::ConnectionState::Disconnecting);
|
||||
{
|
||||
if (! disconnect_vpn() ){
|
||||
qDebug()<<"We don't disconnect";
|
||||
setConnectionState(VpnProtocol::Error);
|
||||
setConnectionState(Vpn::ConnectionState::Error);
|
||||
}
|
||||
else {
|
||||
setConnectionState(VpnProtocol::Disconnected);
|
||||
setConnectionState(Vpn::ConnectionState::Disconnected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,40 +55,40 @@ void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE
|
|||
{
|
||||
case RASCS_OpenPort:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
setConnectionState(Preparing);
|
||||
setConnectionState(Vpn::ConnectionState::Preparing);
|
||||
break;
|
||||
case RASCS_PortOpened:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
setConnectionState(Preparing);
|
||||
setConnectionState(Vpn::ConnectionState::Preparing);
|
||||
break;
|
||||
case RASCS_ConnectDevice:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
setConnectionState(Preparing);
|
||||
setConnectionState(Vpn::ConnectionState::Preparing);
|
||||
break;
|
||||
case RASCS_DeviceConnected:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
setConnectionState(Preparing);
|
||||
setConnectionState(Vpn::ConnectionState::Preparing);
|
||||
break;
|
||||
case RASCS_AllDevicesConnected:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
setConnectionState(Preparing);
|
||||
setConnectionState(Vpn::ConnectionState::Preparing);
|
||||
break;
|
||||
case RASCS_Authenticate:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
setConnectionState(Preparing);
|
||||
setConnectionState(Vpn::ConnectionState::Preparing);
|
||||
break;
|
||||
case RASCS_AuthNotify:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
if (dwError != 0) {
|
||||
//qDebug() << "have error" << dwError;
|
||||
setConnectionState(Disconnected);
|
||||
setConnectionState(Vpn::ConnectionState::Disconnected);
|
||||
} else {
|
||||
//qDebug() << "RASCS_AuthNotify but no error" << dwError;
|
||||
}
|
||||
break;
|
||||
case RASCS_AuthRetry:
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
setConnectionState(Preparing);
|
||||
setConnectionState(Vpn::ConnectionState::Preparing);
|
||||
break;
|
||||
case RASCS_AuthCallback:
|
||||
qDebug()<<__FUNCTION__ << __LINE__;
|
||||
|
@ -151,16 +151,16 @@ void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE
|
|||
qDebug()<<__FUNCTION__ << __LINE__;
|
||||
break;
|
||||
case RASCS_PasswordExpired:
|
||||
setConnectionState(Error);
|
||||
setConnectionState(Vpn::ConnectionState::Error);
|
||||
qDebug()<<__FUNCTION__ << __LINE__;
|
||||
break;
|
||||
|
||||
case RASCS_Connected: // = RASCS_DONE:
|
||||
setConnectionState(Connected);
|
||||
setConnectionState(Vpn::ConnectionState::Connected);
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
break;
|
||||
case RASCS_Disconnected:
|
||||
setConnectionState(Disconnected);
|
||||
setConnectionState(Vpn::ConnectionState::Disconnected);
|
||||
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||
break;
|
||||
default:
|
||||
|
@ -177,7 +177,7 @@ void Ikev2Protocol::readIkev2Configuration(const QJsonObject &configuration)
|
|||
ErrorCode Ikev2Protocol::start()
|
||||
{
|
||||
QByteArray cert = QByteArray::fromBase64(m_config[config_key::cert].toString().toUtf8());
|
||||
setConnectionState(Connecting);
|
||||
setConnectionState(Vpn::ConnectionState::Connecting);
|
||||
|
||||
QTemporaryFile certFile;
|
||||
certFile.setAutoRemove(false);
|
||||
|
|
|
@ -21,23 +21,25 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i
|
|||
DockerContainer container = ContainerProps::allContainers().at(index.row());
|
||||
|
||||
switch (role) {
|
||||
case NameRole:
|
||||
// return ContainerProps::containerHumanNames().value(container);
|
||||
case DescRole:
|
||||
// return ContainerProps::containerDescriptions().value(container);
|
||||
case ConfigRole:
|
||||
m_settings->setContainerConfig(m_currentlyProcessedServerIndex,
|
||||
container,
|
||||
value.toJsonObject());
|
||||
case ServiceTypeRole:
|
||||
// return ContainerProps::containerService(container);
|
||||
case DockerContainerRole:
|
||||
// return container;
|
||||
case IsInstalledRole:
|
||||
// return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
|
||||
case IsDefaultRole:
|
||||
m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container);
|
||||
emit defaultContainerChanged();
|
||||
case NameRole:
|
||||
// return ContainerProps::containerHumanNames().value(container);
|
||||
case DescRole:
|
||||
// return ContainerProps::containerDescriptions().value(container);
|
||||
case ConfigRole:
|
||||
m_settings->setContainerConfig(m_currentlyProcessedServerIndex,
|
||||
container,
|
||||
value.toJsonObject());
|
||||
case ServiceTypeRole:
|
||||
// return ContainerProps::containerService(container);
|
||||
case DockerContainerRole:
|
||||
// return container;
|
||||
case IsInstalledRole:
|
||||
// return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
|
||||
case IsDefaultRole: {
|
||||
m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container);
|
||||
m_defaultContainerIndex = container;
|
||||
emit defaultContainerChanged();
|
||||
}
|
||||
}
|
||||
|
||||
emit dataChanged(index, index);
|
||||
|
@ -58,8 +60,10 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
|||
return ContainerProps::containerHumanNames().value(container);
|
||||
case DescRole:
|
||||
return ContainerProps::containerDescriptions().value(container);
|
||||
case ConfigRole:
|
||||
return m_settings->containerConfig(m_currentlyProcessedServerIndex, container);
|
||||
case ConfigRole: {
|
||||
if (container == DockerContainer::None) return QJsonObject();
|
||||
return m_containers.value(container);
|
||||
}
|
||||
case ServiceTypeRole:
|
||||
return ContainerProps::containerService(container);
|
||||
case DockerContainerRole:
|
||||
|
@ -71,11 +75,11 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
|||
case EasySetupDescriptionRole:
|
||||
return ContainerProps::easySetupDescription(container);
|
||||
case IsInstalledRole:
|
||||
return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
|
||||
return m_containers.contains(container);
|
||||
case IsCurrentlyInstalledRole:
|
||||
return container == static_cast<DockerContainer>(m_currentlyInstalledContainerIndex);
|
||||
case IsDefaultRole:
|
||||
return container == m_settings->defaultContainer(m_currentlyProcessedServerIndex);
|
||||
return container == m_defaultContainerIndex;
|
||||
case IsSupportedRole:
|
||||
return ContainerProps::isSupportedByCurrentPlatform(container);
|
||||
}
|
||||
|
@ -87,6 +91,8 @@ void ContainersModel::setCurrentlyProcessedServerIndex(int index)
|
|||
{
|
||||
beginResetModel();
|
||||
m_currentlyProcessedServerIndex = index;
|
||||
m_containers = m_settings->containers(m_currentlyProcessedServerIndex);
|
||||
m_defaultContainerIndex = m_settings->defaultContainer(m_currentlyProcessedServerIndex);
|
||||
endResetModel();
|
||||
emit defaultContainerChanged();
|
||||
}
|
||||
|
@ -98,12 +104,12 @@ void ContainersModel::setCurrentlyInstalledContainerIndex(int index)
|
|||
|
||||
DockerContainer ContainersModel::getDefaultContainer()
|
||||
{
|
||||
return m_settings->defaultContainer(m_currentlyProcessedServerIndex);
|
||||
return m_defaultContainerIndex;
|
||||
}
|
||||
|
||||
QString ContainersModel::getDefaultContainerName()
|
||||
{
|
||||
return ContainerProps::containerHumanNames().value(getDefaultContainer());
|
||||
return ContainerProps::containerHumanNames().value(m_defaultContainerIndex);
|
||||
}
|
||||
|
||||
int ContainersModel::getCurrentlyInstalledContainerIndex()
|
||||
|
|
|
@ -55,8 +55,13 @@ protected:
|
|||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
QMap<DockerContainer, QJsonObject> m_containers;
|
||||
|
||||
|
||||
int m_currentlyProcessedServerIndex;
|
||||
int m_currentlyInstalledContainerIndex;
|
||||
DockerContainer m_defaultContainerIndex;
|
||||
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,24 +2,28 @@
|
|||
|
||||
ServersModel::ServersModel(std::shared_ptr<Settings> settings, QObject *parent) : m_settings(settings), QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
m_servers = m_settings->serversArray();
|
||||
m_defaultServerIndex = m_settings->defaultServerIndex();
|
||||
}
|
||||
|
||||
int ServersModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return static_cast<int>(m_settings->serversCount());
|
||||
return static_cast<int>(m_servers.size());
|
||||
}
|
||||
|
||||
bool ServersModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= static_cast<int>(m_settings->serversCount())) {
|
||||
|| index.row() >= static_cast<int>(m_servers.size())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (role) {
|
||||
case IsDefaultRole: m_settings->setDefaultServer(index.row());
|
||||
case IsDefaultRole: {
|
||||
m_settings->setDefaultServer(index.row());
|
||||
m_defaultServerIndex = m_settings->defaultServerIndex();
|
||||
}
|
||||
default: return true;
|
||||
}
|
||||
|
||||
|
@ -29,12 +33,11 @@ bool ServersModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||
|
||||
QVariant ServersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0 || index.row() >= static_cast<int>(m_settings->serversCount())) {
|
||||
if (!index.isValid() || index.row() < 0 || index.row() >= static_cast<int>(m_servers.size())) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
const QJsonArray &servers = m_settings->serversArray();
|
||||
const QJsonObject server = servers.at(index.row()).toObject();
|
||||
const QJsonObject server = m_servers.at(index.row()).toObject();
|
||||
|
||||
switch (role) {
|
||||
case NameRole: {
|
||||
|
@ -49,7 +52,7 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
|||
case CredentialsRole:
|
||||
return QVariant::fromValue(m_settings->serverCredentials(index.row()));
|
||||
case IsDefaultRole:
|
||||
return index.row() == m_settings->defaultServerIndex();
|
||||
return index.row() == m_defaultServerIndex;
|
||||
case IsCurrentlyProcessedRole:
|
||||
return index.row() == m_currenlyProcessedServerIndex;
|
||||
}
|
||||
|
@ -59,12 +62,12 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
|||
|
||||
const int ServersModel::getDefaultServerIndex()
|
||||
{
|
||||
return m_settings->defaultServerIndex();
|
||||
return m_defaultServerIndex;
|
||||
}
|
||||
|
||||
const int ServersModel::getServersCount()
|
||||
{
|
||||
return m_settings->serversCount();
|
||||
return m_servers.count();
|
||||
}
|
||||
|
||||
void ServersModel::setCurrentlyProcessedServerIndex(int index)
|
||||
|
@ -74,7 +77,7 @@ void ServersModel::setCurrentlyProcessedServerIndex(int index)
|
|||
|
||||
bool ServersModel::isDefaultServerCurrentlyProcessed()
|
||||
{
|
||||
return m_settings->defaultServerIndex() == m_currenlyProcessedServerIndex;
|
||||
return m_defaultServerIndex == m_currenlyProcessedServerIndex;
|
||||
}
|
||||
|
||||
ServerCredentials ServersModel::getCurrentlyProcessedServerCredentials()
|
||||
|
@ -86,6 +89,7 @@ void ServersModel::addServer(const QJsonObject &server)
|
|||
{
|
||||
beginResetModel();
|
||||
m_settings->addServer(server);
|
||||
m_servers = m_settings->serversArray();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
|
@ -93,6 +97,7 @@ void ServersModel::removeServer()
|
|||
{
|
||||
beginResetModel();
|
||||
m_settings->removeServer(m_currenlyProcessedServerIndex);
|
||||
m_servers = m_settings->serversArray();
|
||||
|
||||
if (m_settings->defaultServerIndex() == m_currenlyProcessedServerIndex) {
|
||||
m_settings->setDefaultServer(0);
|
||||
|
|
|
@ -46,8 +46,11 @@ protected:
|
|||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
QJsonArray m_servers;
|
||||
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
||||
int m_defaultServerIndex;
|
||||
int m_currenlyProcessedServerIndex;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,8 +38,6 @@ ListView {
|
|||
|
||||
ButtonGroup.group: containersRadioButtonGroup
|
||||
|
||||
checked: isDefault
|
||||
|
||||
indicator: Rectangle {
|
||||
anchors.fill: parent
|
||||
color: containerRadioButton.hovered ? Qt.rgba(1, 1, 1, 0.08) : "transparent"
|
||||
|
|
|
@ -34,22 +34,6 @@ Item {
|
|||
Layout.fillWidth: true
|
||||
|
||||
color: "transparent"
|
||||
|
||||
ShaderEffectSource {
|
||||
id: effectSource
|
||||
|
||||
sourceItem: background
|
||||
anchors.fill: background
|
||||
sourceRect: Qt.rect(x,y, width, height)
|
||||
}
|
||||
|
||||
FastBlur {
|
||||
id: blur
|
||||
anchors.fill: effectSource
|
||||
|
||||
source: effectSource
|
||||
radius: 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,21 +137,6 @@ PageType {
|
|||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
spacing: 8
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
sourceModel: ContainersModel
|
||||
filters: [
|
||||
ValueFilter {
|
||||
roleName: "serviceType"
|
||||
value: ProtocolEnum.Vpn
|
||||
},
|
||||
ValueFilter {
|
||||
roleName: "isSupported"
|
||||
value: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
DropDownType {
|
||||
id: containersDropDown
|
||||
|
||||
|
@ -176,7 +161,20 @@ PageType {
|
|||
listView: HomeContainersListView {
|
||||
rootWidth: root.width
|
||||
|
||||
model: proxyContainersModel
|
||||
model: SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
sourceModel: ContainersModel
|
||||
filters: [
|
||||
ValueFilter {
|
||||
roleName: "serviceType"
|
||||
value: ProtocolEnum.Vpn
|
||||
},
|
||||
ValueFilter {
|
||||
roleName: "isSupported"
|
||||
value: true
|
||||
}
|
||||
]
|
||||
}
|
||||
currentIndex: ContainersModel.getDefaultContainer()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,9 +45,9 @@ PageType {
|
|||
|
||||
Component.onCompleted: {
|
||||
var pagePath = PageController.getPagePath(PageEnum.PageHome)
|
||||
tabBarStackView.push(pagePath, { "objectName" : pagePath })
|
||||
ServersModel.setCurrentlyProcessedServerIndex(ServersModel.getDefaultServerIndex())
|
||||
ContainersModel.setCurrentlyProcessedServerIndex(ServersModel.getDefaultServerIndex())
|
||||
tabBarStackView.push(pagePath, { "objectName" : pagePath })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ PageType {
|
|||
isSelected: tabBar.currentIndex === 0
|
||||
image: "qrc:/images/controls/home.svg"
|
||||
onClicked: {
|
||||
tabBarStackView.goToTabBarPage(PageEnum.PageHome)
|
||||
ContainersModel.setCurrentlyProcessedServerIndex(ServersModel.getDefaultServerIndex())
|
||||
tabBarStackView.goToTabBarPage(PageEnum.PageHome)
|
||||
}
|
||||
}
|
||||
TabImageButtonType {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue