mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Qml app improved trusted nodes exchange
AddTrustedNode.qml support for plain certificate and node link import/export Move clipboard wrapper to it's own singleton ClipboardWrapper.qml with improved clipboard API
This commit is contained in:
parent
5c1ad36d2b
commit
7b070e482d
@ -1,43 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* RetroShare Android QML App
|
||||||
|
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 2.0
|
import QtQuick.Controls 2.0
|
||||||
import QtQuick.Layouts 1.3
|
|
||||||
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
||||||
|
import "." //Needed for ClipboardWrapper singleton
|
||||||
|
import "URI.js" as UriJs
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
function refreshData() { rsApi.request("/peers/self/certificate/", "") }
|
property ApplicationWindow mW
|
||||||
|
|
||||||
Component.onCompleted:
|
Column
|
||||||
{
|
|
||||||
rsApi.openConnection(apiSocketPath)
|
|
||||||
refreshData()
|
|
||||||
}
|
|
||||||
onFocusChanged: focus && refreshData()
|
|
||||||
|
|
||||||
LibresapiLocalClient
|
|
||||||
{
|
|
||||||
id: rsApi
|
|
||||||
onGoodResponseReceived:
|
|
||||||
{
|
|
||||||
var jsonData = JSON.parse(msg)
|
|
||||||
if(jsonData && jsonData.data && jsonData.data.cert_string)
|
|
||||||
myKeyField.text = jsonData.data.cert_string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout
|
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Text
|
||||||
|
{
|
||||||
|
text: qsTr("Import/export node from/to clipboard")
|
||||||
|
font.bold: true
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
}
|
||||||
|
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
id: bottomButton
|
text: qsTr("Export own certificate link")
|
||||||
text: "Add trusted node"
|
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
|
console.log("onClicked", text)
|
||||||
|
rsApi.request(
|
||||||
|
"/peers/self/certificate/", "",
|
||||||
|
function(par)
|
||||||
|
{
|
||||||
|
var radix = JSON.parse(par.response).data.cert_string
|
||||||
|
var name = mainWindow.user_name
|
||||||
|
var encodedName = UriJs.URI.encode(name)
|
||||||
|
ClipboardWrapper.postToClipBoard(
|
||||||
|
"retroshare://certificate?" +
|
||||||
|
"name=" + encodedName +
|
||||||
|
"&radix=" + UriJs.URI.encode(radix) +
|
||||||
|
"&location=" + encodedName
|
||||||
|
)
|
||||||
|
|
||||||
|
linkCopiedPopup.itemName = name
|
||||||
|
linkCopiedPopup.open()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
text: qsTr("Import trusted node")
|
||||||
|
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
|
var cptext = ClipboardWrapper.getFromClipBoard()
|
||||||
|
|
||||||
|
console.log("typeof(cptext)", typeof(cptext))
|
||||||
|
if(cptext.search("://") > 0)
|
||||||
|
mainWindow.handleIntentUri(cptext)
|
||||||
|
else
|
||||||
rsApi.request(
|
rsApi.request(
|
||||||
"/peers/examine_cert/",
|
"/peers/examine_cert/",
|
||||||
JSON.stringify({cert_string: otherKeyField.text}),
|
JSON.stringify({cert_string: cptext}),
|
||||||
function(par)
|
function(par)
|
||||||
{
|
{
|
||||||
console.log("/peers/examine_cert/ CB", par)
|
console.log("/peers/examine_cert/ CB", par)
|
||||||
@ -59,25 +99,19 @@ Item
|
|||||||
|
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
text: "Copy"
|
text: qsTr("Export own plain certificate")
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
myKeyField.selectAll()
|
rsApi.request(
|
||||||
myKeyField.copy()
|
"/peers/self/certificate/", "",
|
||||||
}
|
function(par)
|
||||||
}
|
|
||||||
|
|
||||||
Button
|
|
||||||
{
|
{
|
||||||
text: "Paste"
|
var jD = JSON.parse(par.response).data
|
||||||
onClicked:
|
ClipboardWrapper.postToClipBoard(jD.cert_string)
|
||||||
{
|
mainWindow.linkCopiedPopup.itemName=mainWindow.user_name
|
||||||
otherKeyField.selectAll()
|
mainWindow.linkCopiedPopup.open()
|
||||||
otherKeyField.paste()
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField { id: myKeyField }
|
|
||||||
TextField { id: otherKeyField }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
47
retroshare-qml-app/src/ClipboardWrapper.qml
Normal file
47
retroshare-qml-app/src/ClipboardWrapper.qml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* RetroShare Android QML App
|
||||||
|
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import QtQml 2.2
|
||||||
|
import QtQuick 2.7
|
||||||
|
import QtQuick.Controls 2.0
|
||||||
|
|
||||||
|
QtObject
|
||||||
|
{
|
||||||
|
/// Public API
|
||||||
|
function postToClipBoard(str)
|
||||||
|
{
|
||||||
|
console.log("postToClipBoard(str)", str)
|
||||||
|
privTF.text = str
|
||||||
|
privTF.selectAll()
|
||||||
|
privTF.cut()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Public API
|
||||||
|
function getFromClipBoard()
|
||||||
|
{
|
||||||
|
privTF.text = "getFromClipBoard()" // Need some text for selectAll()
|
||||||
|
privTF.selectAll()
|
||||||
|
privTF.paste()
|
||||||
|
return privTF.text.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Private
|
||||||
|
property TextInput privTF: TextInput { visible: false }
|
||||||
|
}
|
@ -75,13 +75,15 @@ Item
|
|||||||
{
|
{
|
||||||
contactsView.own_gxs_id = json.data[0].gxs_id
|
contactsView.own_gxs_id = json.data[0].gxs_id
|
||||||
contactsView.own_nick = json.data[0].name
|
contactsView.own_nick = json.data[0].name
|
||||||
|
if(mainWindow.user_name.length === 0)
|
||||||
|
mainWindow.user_name = json.data[0].name
|
||||||
}
|
}
|
||||||
else if (!settings.defaultIdentityCreated)
|
else if (!settings.defaultIdentityCreated)
|
||||||
{
|
{
|
||||||
console.log("refreshOwnCallback(par)", "creating new identity" )
|
console.log("refreshOwnCallback(par)", "creating new identity" )
|
||||||
settings.defaultIdentityCreated = true
|
settings.defaultIdentityCreated = true
|
||||||
|
|
||||||
var jsonData = { "name": mainWindow.pgp_name, "pgp_linked": false }
|
var jsonData = { "name": mainWindow.user_name, "pgp_linked": false }
|
||||||
rsApi.request(
|
rsApi.request(
|
||||||
"/identity/create_identity",
|
"/identity/create_identity",
|
||||||
JSON.stringify(jsonData),
|
JSON.stringify(jsonData),
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 2.0
|
import QtQuick.Controls 2.0
|
||||||
|
import "." //Needed for ClipboardWrapper singleton
|
||||||
import "URI.js" as UriJs
|
import "URI.js" as UriJs
|
||||||
|
|
||||||
Item
|
Item
|
||||||
@ -139,15 +140,14 @@ Item
|
|||||||
function(par)
|
function(par)
|
||||||
{
|
{
|
||||||
var jD = JSON.parse(par.response).data
|
var jD = JSON.parse(par.response).data
|
||||||
clipboardWrap.text = "retroshare://" +
|
ClipboardWrapper.postToClipBoard(
|
||||||
|
"retroshare://" +
|
||||||
"identity?gxsid=" +
|
"identity?gxsid=" +
|
||||||
model.gxs_id +
|
model.gxs_id +
|
||||||
"&name=" +
|
"&name=" +
|
||||||
UriJs.URI.encode(model.name) +
|
UriJs.URI.encode(model.name) +
|
||||||
"&groupdata=" +
|
"&groupdata=" +
|
||||||
UriJs.URI.encode(jD.radix)
|
UriJs.URI.encode(jD.radix))
|
||||||
clipboardWrap.selectAll()
|
|
||||||
clipboardWrap.copy()
|
|
||||||
linkCopiedPopup.itemName = model.name
|
linkCopiedPopup.itemName = model.name
|
||||||
linkCopiedPopup.visible = true
|
linkCopiedPopup.visible = true
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ Item
|
|||||||
rsApi.request(
|
rsApi.request(
|
||||||
"/control/create_location/",
|
"/control/create_location/",
|
||||||
JSON.stringify(jsonData))
|
JSON.stringify(jsonData))
|
||||||
mainWindow.pgp_name = login
|
mainWindow.user_name = login
|
||||||
locationView.state = "selectLocation"
|
locationView.state = "selectLocation"
|
||||||
bottomButton.enabled = false
|
bottomButton.enabled = false
|
||||||
bottomButton.text = "Creating profile..."
|
bottomButton.text = "Creating profile..."
|
||||||
@ -95,7 +95,7 @@ Item
|
|||||||
// There is only one location so we can jump selecting location
|
// There is only one location so we can jump selecting location
|
||||||
var location = jsonData[0]
|
var location = jsonData[0]
|
||||||
loginView.login = location.name
|
loginView.login = location.name
|
||||||
mainWindow.pgp_name = location.name
|
mainWindow.user_name = location.name
|
||||||
locationView.sslid = location.peer_id
|
locationView.sslid = location.peer_id
|
||||||
locationView.state = "login"
|
locationView.state = "login"
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ Item
|
|||||||
loginView.login = text
|
loginView.login = text
|
||||||
locationView.sslid = model.id
|
locationView.sslid = model.id
|
||||||
locationView.state = "login"
|
locationView.state = "login"
|
||||||
mainWindow.pgp_name = model.name
|
mainWindow.user_name = model.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visible: false
|
visible: false
|
||||||
|
@ -121,6 +121,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
rootContext.setContextProperty("QT_DEBUG", QVariant(true));
|
rootContext.setContextProperty("QT_DEBUG", QVariant(true));
|
||||||
|
rsApi.setDebug(false);
|
||||||
#else
|
#else
|
||||||
rootContext.setContextProperty("QT_DEBUG", QVariant(false));
|
rootContext.setContextProperty("QT_DEBUG", QVariant(false));
|
||||||
#endif // QT_DEBUG
|
#endif // QT_DEBUG
|
||||||
|
@ -20,7 +20,7 @@ import QtQuick 2.7
|
|||||||
import QtQuick.Controls 2.0
|
import QtQuick.Controls 2.0
|
||||||
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
||||||
import "URI.js" as UriJs
|
import "URI.js" as UriJs
|
||||||
import "." //Needed for TokensManager singleton
|
import "." //Needed for TokensManager and ClipboardWrapper singleton
|
||||||
|
|
||||||
ApplicationWindow
|
ApplicationWindow
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ ApplicationWindow
|
|||||||
width: 400
|
width: 400
|
||||||
height: 400
|
height: 400
|
||||||
|
|
||||||
property string pgp_name
|
property string user_name
|
||||||
|
|
||||||
property bool coreReady: stackView.state === "running_ok" ||
|
property bool coreReady: stackView.state === "running_ok" ||
|
||||||
stackView.state === "running_ok_no_full_control"
|
stackView.state === "running_ok_no_full_control"
|
||||||
@ -115,11 +115,8 @@ ApplicationWindow
|
|||||||
{
|
{
|
||||||
text: "Paste Link"
|
text: "Paste Link"
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
handleIntentUri(ClipboardWrapper.getFromClipBoard())
|
||||||
clipboardWrap.selectAll()
|
|
||||||
clipboardWrap.paste()
|
|
||||||
handleIntentUri(clipboardWrap.text)
|
|
||||||
}
|
|
||||||
enabled: mainWindow.coreReady
|
enabled: mainWindow.coreReady
|
||||||
}
|
}
|
||||||
MenuItem
|
MenuItem
|
||||||
@ -368,17 +365,16 @@ ApplicationWindow
|
|||||||
{
|
{
|
||||||
text: qsTr("%1 key imported").arg(
|
text: qsTr("%1 key imported").arg(
|
||||||
contactImportPopup.expectedName)
|
contactImportPopup.expectedName)
|
||||||
horizontalAlignment: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Text
|
Text
|
||||||
{
|
{
|
||||||
text: qsTr("Link malformed!")
|
text: qsTr("Link malformed!")
|
||||||
|
|
||||||
color: "red"
|
color: "red"
|
||||||
visible: contactImportPopup.visible &&
|
visible: contactImportPopup.visible &&
|
||||||
!contactImportPopup.idMatch()
|
!contactImportPopup.idMatch()
|
||||||
horizontalAlignment: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Text
|
Text
|
||||||
@ -387,10 +383,9 @@ ApplicationWindow
|
|||||||
qsTr("Expected id and real one differs:") +
|
qsTr("Expected id and real one differs:") +
|
||||||
"<br/><pre>" + contactImportPopup.expectedGxsId +
|
"<br/><pre>" + contactImportPopup.expectedGxsId +
|
||||||
"<br/>" + contactImportPopup.realGxsId + "</pre>"
|
"<br/>" + contactImportPopup.realGxsId + "</pre>"
|
||||||
|
|
||||||
visible: contactImportPopup.visible &&
|
visible: contactImportPopup.visible &&
|
||||||
!contactImportPopup.idMatch()
|
!contactImportPopup.idMatch()
|
||||||
horizontalAlignment: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,6 +422,4 @@ ApplicationWindow
|
|||||||
onTriggered: linkCopiedPopup.close()
|
onTriggered: linkCopiedPopup.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField { id: clipboardWrap; visible: false }
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,6 @@
|
|||||||
<file>qmldir</file>
|
<file>qmldir</file>
|
||||||
<file>TrustedNodeDetails.qml</file>
|
<file>TrustedNodeDetails.qml</file>
|
||||||
<file>icons/document-share.png</file>
|
<file>icons/document-share.png</file>
|
||||||
|
<file>ClipboardWrapper.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -1 +1,2 @@
|
|||||||
singleton TokensManager 1.0 TokensManager.qml
|
singleton TokensManager 1.0 TokensManager.qml
|
||||||
|
singleton ClipboardWrapper 1.0 ClipboardWrapper.qml
|
||||||
|
Loading…
Reference in New Issue
Block a user