Share page fixes
This commit is contained in:
parent
836075de10
commit
c6efc5b212
5 changed files with 28 additions and 16 deletions
|
@ -597,7 +597,7 @@ CQR_Encode::~CQR_Encode()
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CQR_Encode::EncodeData
|
||||
|
||||
bool CQR_Encode::EncodeData(int nLevel, int nVersion, bool bAutoExtent, int nMaskingNo, char* lpsSource, int ncSource)
|
||||
bool CQR_Encode::EncodeData(int nLevel, int nVersion, bool bAutoExtent, int nMaskingNo, const char* lpsSource, int ncSource)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -746,7 +746,7 @@ bool CQR_Encode::EncodeData(int nLevel, int nVersion, bool bAutoExtent, int nMas
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CQR_Encode::GetEncodeVersion
|
||||
|
||||
int CQR_Encode::GetEncodeVersion(int nVersion, char* lpsSource, int ncLength)
|
||||
int CQR_Encode::GetEncodeVersion(int nVersion, const char* lpsSource, int ncLength)
|
||||
{
|
||||
int nVerGroup = nVersion >= 27 ? QR_VRESION_L : (nVersion >= 10 ? QR_VRESION_M : QR_VRESION_S);
|
||||
int i, j;
|
||||
|
@ -788,7 +788,7 @@ int CQR_Encode::GetEncodeVersion(int nVersion, char* lpsSource, int ncLength)
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CQR_Encode::EncodeSourceData
|
||||
bool CQR_Encode::EncodeSourceData(char* lpsSource, int ncLength, int nVerGroup)
|
||||
bool CQR_Encode::EncodeSourceData(const char* lpsSource, int ncLength, int nVerGroup)
|
||||
{
|
||||
memset(m_nBlockLength, 0, sizeof(m_nBlockLength));
|
||||
|
||||
|
|
|
@ -92,11 +92,11 @@ private:
|
|||
unsigned char m_byRSWork[MAX_CODEBLOCK];
|
||||
|
||||
public:
|
||||
bool EncodeData(int nLevel, int nVersion, bool bAutoExtent, int nMaskingNo, char* lpsSource, int ncSource = 0);
|
||||
bool EncodeData(int nLevel, int nVersion, bool bAutoExtent, int nMaskingNo, const char* lpsSource, int ncSource = 0);
|
||||
|
||||
private:
|
||||
int GetEncodeVersion(int nVersion, char* lpsSource, int ncLength);
|
||||
bool EncodeSourceData(char* lpsSource, int ncLength, int nVerGroup);
|
||||
int GetEncodeVersion(int nVersion, const char* lpsSource, int ncLength);
|
||||
bool EncodeSourceData(const char* lpsSource, int ncLength, int nVerGroup);
|
||||
|
||||
int GetBitLength(unsigned char nMode, int ncData, int nVerGroup);
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ void ShareConnectionLogic::onUpdatePage()
|
|||
void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
||||
{
|
||||
set_textEditShareAmneziaCodeText("");
|
||||
set_shareAmneziaQrCodeText("");
|
||||
|
||||
QJsonObject serverConfig;
|
||||
// Full access
|
||||
if (shareFullAccess()) {
|
||||
|
@ -83,12 +85,15 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
}
|
||||
}
|
||||
|
||||
QByteArray ba = QJsonDocument(serverConfig).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
QString code = QString("vpn://%1").arg(QString(ba));
|
||||
QByteArray ba = QJsonDocument(serverConfig).toBinaryData();
|
||||
ba = qCompress(ba, 8);
|
||||
QString code = QString("vpn://%1").arg(QString(ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)));
|
||||
set_textEditShareAmneziaCodeText(code);
|
||||
|
||||
QImage qr = updateQRCodeImage(code);
|
||||
set_shareAmneziaQrCodeText(imageToBase64(qr));
|
||||
if (ba.size() < 1024) {
|
||||
QImage qr = updateQRCodeImage(ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals));
|
||||
set_shareAmneziaQrCodeText(imageToBase64(qr));
|
||||
}
|
||||
}
|
||||
|
||||
void ShareConnectionLogic::onPushButtonShareOpenVpnGenerateClicked()
|
||||
|
@ -138,7 +143,7 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
|
|||
ssString = "ss://" + ssString.toUtf8().toBase64();
|
||||
set_lineEditShareShadowSocksStringText(ssString);
|
||||
|
||||
QImage qr = updateQRCodeImage(ssString);
|
||||
QImage qr = updateQRCodeImage(ssString.toUtf8());
|
||||
set_shareShadowSocksQrCodeText(imageToBase64(qr));
|
||||
|
||||
set_labelShareShadowSocksServerText(ssConfig.value("server").toString());
|
||||
|
@ -175,14 +180,14 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
|
|||
set_textEditShareAmneziaCodeText(tr(""));
|
||||
}
|
||||
|
||||
QImage ShareConnectionLogic::updateQRCodeImage(const QString &text)
|
||||
QImage ShareConnectionLogic::updateQRCodeImage(const QByteArray &data)
|
||||
{
|
||||
int levelIndex = 1;
|
||||
int versionIndex = 0;
|
||||
bool bExtent = true;
|
||||
int maskIndex = -1;
|
||||
|
||||
m_qrEncode.EncodeData( levelIndex, versionIndex, bExtent, maskIndex, text.toUtf8().data() );
|
||||
m_qrEncode.EncodeData( levelIndex, versionIndex, bExtent, maskIndex, data.data() );
|
||||
|
||||
int qrImageSize = m_qrEncode.m_nSymbleSize;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
void updateSharingPage(int serverIndex, const ServerCredentials &credentials,
|
||||
DockerContainer container);
|
||||
QImage updateQRCodeImage(const QString &text);
|
||||
QImage updateQRCodeImage(const QByteArray &data);
|
||||
QString imageToBase64(const QImage &image);
|
||||
|
||||
private:
|
||||
|
|
|
@ -61,8 +61,8 @@ PageShareProtocolBase {
|
|||
This code includes your server credentials!\n
|
||||
Provide this code only to TRUSTED users.")
|
||||
: qsTr("Anyone who logs in with this code will be able to connect to this VPN server. \n
|
||||
This code does not include server credentials.")
|
||||
|
||||
This code does not include server credentials.\n
|
||||
New encryption keys pair will be generated.")
|
||||
}
|
||||
|
||||
ShareConnectionButtonType {
|
||||
|
@ -130,6 +130,13 @@ This code does not include server credentials.")
|
|||
Layout.preferredHeight: width
|
||||
smooth: false
|
||||
source: ShareConnectionLogic.shareAmneziaQrCodeText
|
||||
visible: ShareConnectionLogic.shareAmneziaQrCodeText.length > 0
|
||||
}
|
||||
|
||||
LabelType {
|
||||
height: 20
|
||||
text: qsTr("Config to long to be displayed as QR code")
|
||||
visible: ShareConnectionLogic.shareAmneziaQrCodeText.length == 0 && tfShareCode.textArea.length > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue