2016-09-15 07:07:13 -04:00
|
|
|
/*
|
|
|
|
* RetroShare Android QML App
|
2017-03-17 12:22:58 -04:00
|
|
|
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
2016-09-15 07:07:13 -04:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2016-09-04 09:01:44 -04:00
|
|
|
|
2017-06-13 08:24:07 -04:00
|
|
|
import QtQuick 2.1
|
2017-03-24 07:02:13 -04:00
|
|
|
import QtQuick.Controls 2.0
|
2017-08-03 12:20:14 -04:00
|
|
|
import QtGraphicalEffects 1.0
|
2016-09-15 07:07:13 -04:00
|
|
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
2017-04-13 10:47:27 -04:00
|
|
|
import "URI.js" as UriJs
|
2017-04-20 15:39:59 -04:00
|
|
|
import "." //Needed for TokensManager and ClipboardWrapper singleton
|
2017-06-22 08:46:30 -04:00
|
|
|
import "components/."
|
|
|
|
|
2016-09-15 07:07:13 -04:00
|
|
|
|
|
|
|
ApplicationWindow
|
|
|
|
{
|
|
|
|
id: mainWindow
|
|
|
|
visible: true
|
2017-03-17 12:22:58 -04:00
|
|
|
title: "RetroShare"
|
2016-10-26 14:37:28 -04:00
|
|
|
width: 400
|
|
|
|
height: 400
|
2016-09-15 07:07:13 -04:00
|
|
|
|
2017-04-20 15:39:59 -04:00
|
|
|
property string user_name
|
2017-04-07 12:26:08 -04:00
|
|
|
|
2017-04-13 10:47:27 -04:00
|
|
|
property bool coreReady: stackView.state === "running_ok" ||
|
|
|
|
stackView.state === "running_ok_no_full_control"
|
|
|
|
|
2017-04-14 20:17:27 -04:00
|
|
|
Component.onCompleted:
|
|
|
|
{
|
|
|
|
addUriHandler("/certificate", certificateLinkHandler)
|
2017-04-20 10:05:15 -04:00
|
|
|
addUriHandler("/identity", contactLinkHandler)
|
2017-07-31 10:52:03 -04:00
|
|
|
addUriHandler("/contacts", openContactsViewLinkHandler)
|
2017-04-14 20:17:27 -04:00
|
|
|
|
|
|
|
var argc = mainArgs.length
|
|
|
|
for(var i=0; i<argc; ++i)
|
|
|
|
{
|
|
|
|
var dump = UriJs.URI.parse(mainArgs[i])
|
|
|
|
if(dump.protocol && (dump.query || dump.path))
|
|
|
|
handleIntentUri(mainArgs[i])
|
|
|
|
}
|
|
|
|
}
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
property var uriHandlersRegister: ({})
|
2017-04-14 20:17:27 -04:00
|
|
|
property var pendingUriRegister: []
|
2017-04-13 10:47:27 -04:00
|
|
|
function addUriHandler(path, fun) { uriHandlersRegister[path] = fun }
|
|
|
|
function delUriHandler(path, fun) { delete uriHandlersRegister[path] }
|
2017-04-11 07:11:57 -04:00
|
|
|
|
2017-07-04 11:20:42 -04:00
|
|
|
|
2017-03-24 07:02:13 -04:00
|
|
|
header: ToolBar
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-24 07:02:13 -04:00
|
|
|
id: toolBar
|
2017-08-03 11:29:18 -04:00
|
|
|
height: 50
|
2017-06-08 10:21:33 -04:00
|
|
|
property alias titleText: toolBarText.text
|
2017-06-12 10:14:47 -04:00
|
|
|
property alias loaderSource: imageLoader.sourceComponent
|
2017-07-04 11:20:42 -04:00
|
|
|
property alias gxsSource: imageLoader.gxsSource
|
2017-06-08 10:21:33 -04:00
|
|
|
property string defaultLabel: "RetroShare"
|
|
|
|
|
2017-06-23 11:26:10 -04:00
|
|
|
property var iconsSize: (coreReady)? height - 10 : 0
|
|
|
|
|
2017-06-23 09:17:41 -04:00
|
|
|
property var searchBtnCb
|
2017-03-24 07:02:13 -04:00
|
|
|
|
2017-06-23 10:33:16 -04:00
|
|
|
function openMainPage ()
|
2017-03-17 12:22:58 -04:00
|
|
|
{
|
2017-06-23 10:33:16 -04:00
|
|
|
if (stackView.currentItem.objectName != "contactsView" )
|
|
|
|
{
|
|
|
|
stackView.push("qrc:/Contacts.qml")
|
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
2017-06-23 10:33:16 -04:00
|
|
|
|
2017-06-13 08:24:07 -04:00
|
|
|
states:
|
|
|
|
[
|
2017-06-13 08:51:53 -04:00
|
|
|
State
|
|
|
|
{
|
2017-06-08 10:21:33 -04:00
|
|
|
name: "DEFAULT"
|
|
|
|
PropertyChanges { target: toolBar; titleText: defaultLabel}
|
2017-06-12 10:14:47 -04:00
|
|
|
PropertyChanges { target: toolBar; loaderSource: rsIcon}
|
2017-06-08 10:21:33 -04:00
|
|
|
},
|
2017-06-13 08:51:53 -04:00
|
|
|
State
|
|
|
|
{
|
2017-06-08 10:21:33 -04:00
|
|
|
name: "CHATVIEW"
|
2017-06-23 10:36:36 -04:00
|
|
|
PropertyChanges { target: toolBarText; mouseA.visible: false }
|
2017-07-04 11:20:42 -04:00
|
|
|
PropertyChanges { target: toolBar; loaderSource: userHash }
|
2017-06-23 11:26:10 -04:00
|
|
|
// PropertyChanges { target: toolBar; backBtnVisible: true }
|
2017-06-23 09:01:48 -04:00
|
|
|
},
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "CONTACTSVIEW"
|
|
|
|
PropertyChanges { target: toolBar; titleText: defaultLabel}
|
|
|
|
PropertyChanges { target: toolBar; loaderSource: rsIcon}
|
|
|
|
PropertyChanges { target: searchIcon; searchIconVisibility: true}
|
2017-06-08 10:21:33 -04:00
|
|
|
}
|
|
|
|
]
|
2017-03-24 07:02:13 -04:00
|
|
|
|
2017-06-13 08:24:07 -04:00
|
|
|
Item
|
2017-03-17 12:22:58 -04:00
|
|
|
{
|
2017-06-13 08:24:07 -04:00
|
|
|
id: tolbarLeftPadding
|
|
|
|
width: 4
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
2017-06-13 08:24:07 -04:00
|
|
|
|
2017-03-24 07:02:13 -04:00
|
|
|
MouseArea
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-07-09 05:49:52 -04:00
|
|
|
id: menu
|
2017-03-24 07:02:13 -04:00
|
|
|
height: parent.height
|
|
|
|
width: parent.height
|
2017-07-04 11:20:42 -04:00
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
anchors.left: tolbarLeftPadding.right
|
2017-03-24 07:02:13 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
onClicked: sideBar.open()
|
2017-03-24 07:02:13 -04:00
|
|
|
|
|
|
|
Image
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-07-09 05:49:52 -04:00
|
|
|
source: "qrc:/icons/application-menu.svg"
|
2017-03-24 07:02:13 -04:00
|
|
|
height: parent.height - 10
|
2017-07-09 05:49:52 -04:00
|
|
|
width: height
|
|
|
|
sourceSize.height: height
|
|
|
|
sourceSize.width: height
|
2017-03-24 07:02:13 -04:00
|
|
|
anchors.centerIn: parent
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
2017-03-24 07:02:13 -04:00
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
SideBar {
|
|
|
|
id: sideBar
|
2017-07-04 11:20:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
|
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
Label
|
|
|
|
{
|
2017-06-23 10:36:36 -04:00
|
|
|
property alias mouseA: mouseA
|
2017-06-08 10:21:33 -04:00
|
|
|
id: toolBarText
|
2017-03-17 12:22:58 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2017-07-09 05:49:52 -04:00
|
|
|
anchors.left: menu.right
|
2017-03-17 12:22:58 -04:00
|
|
|
anchors.leftMargin: 20
|
2017-06-22 11:50:42 -04:00
|
|
|
|
2017-06-23 10:33:16 -04:00
|
|
|
MouseArea {
|
2017-06-23 10:36:36 -04:00
|
|
|
id: mouseA
|
|
|
|
visible: true
|
2017-06-23 10:33:16 -04:00
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: { toolBar.openMainPage() }
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2017-06-22 11:50:42 -04:00
|
|
|
|
2017-07-22 08:44:12 -04:00
|
|
|
ButtonIcon
|
2017-06-22 11:50:42 -04:00
|
|
|
{
|
2017-06-23 09:01:48 -04:00
|
|
|
property bool searchIconVisibility: false
|
2017-06-23 09:17:41 -04:00
|
|
|
property var onClickCB: function (){}
|
2017-06-23 09:01:48 -04:00
|
|
|
|
2017-06-22 11:50:42 -04:00
|
|
|
id: searchIcon
|
2017-06-23 11:26:10 -04:00
|
|
|
height: toolBar.iconsSize
|
|
|
|
width: toolBar.iconsSize
|
2017-06-22 11:50:42 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
imgUrl: "qrc:/icons/search.svg"
|
2017-07-09 05:49:52 -04:00
|
|
|
anchors.right: imageLoader.left
|
|
|
|
anchors.rightMargin: 5
|
2017-06-23 09:01:48 -04:00
|
|
|
visible: searchIconVisibility && coreReady
|
2017-06-22 11:50:42 -04:00
|
|
|
onClicked:
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-06-23 09:17:41 -04:00
|
|
|
toolBar.searchBtnCb()
|
2017-06-22 11:50:42 -04:00
|
|
|
}
|
|
|
|
}
|
2017-03-24 07:02:13 -04:00
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
Loader
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-07-09 05:49:52 -04:00
|
|
|
id: imageLoader
|
|
|
|
height: toolBar.height - 4
|
2017-04-20 15:39:59 -04:00
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
asynchronous: true
|
|
|
|
|
2017-03-24 07:02:13 -04:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 2
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
property string gxsSource;
|
2017-03-24 07:02:13 -04:00
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Component
|
|
|
|
{
|
|
|
|
id: rsIcon
|
2017-07-22 08:44:12 -04:00
|
|
|
ButtonIcon
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-07-09 05:49:52 -04:00
|
|
|
height: imageLoader.height
|
|
|
|
width: imageLoader.height
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2017-08-17 19:37:39 -04:00
|
|
|
imgUrl: "/icons/retroshare.png"
|
2017-07-09 06:27:49 -04:00
|
|
|
onClicked:
|
2017-03-24 07:02:13 -04:00
|
|
|
{
|
2017-07-09 06:27:49 -04:00
|
|
|
if (coreReady) toolBar.openMainPage()
|
2017-03-24 07:02:13 -04:00
|
|
|
}
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
|
|
|
}
|
2017-03-24 07:02:13 -04:00
|
|
|
|
2017-07-09 05:49:52 -04:00
|
|
|
Component
|
|
|
|
{
|
|
|
|
id: userHash
|
|
|
|
|
|
|
|
AvatarOrColorHash
|
|
|
|
{
|
|
|
|
id: colorHash
|
|
|
|
|
|
|
|
gxs_id: imageLoader.gxsSource
|
|
|
|
height: toolBar.height - 4
|
|
|
|
anchors.leftMargin: 2
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
2017-07-09 05:49:52 -04:00
|
|
|
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
2017-07-09 05:49:52 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
2017-07-09 05:49:52 -04:00
|
|
|
|
2017-08-03 12:20:14 -04:00
|
|
|
DropShadow
|
|
|
|
{
|
|
|
|
anchors.fill: toolBar
|
|
|
|
horizontalOffset: 0
|
|
|
|
verticalOffset: 1
|
|
|
|
radius: 12
|
|
|
|
samples: 25
|
|
|
|
color: "#80000000"
|
|
|
|
source: toolBar
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
2016-09-15 07:07:13 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
StackView
|
|
|
|
{
|
|
|
|
id: stackView
|
|
|
|
anchors.fill: parent
|
2017-08-03 12:20:14 -04:00
|
|
|
anchors.top: toolBar.bottom
|
|
|
|
anchors.topMargin: 5
|
2017-04-14 20:17:27 -04:00
|
|
|
focus: true
|
2017-06-13 08:51:53 -04:00
|
|
|
onCurrentItemChanged:
|
2017-07-04 09:35:45 -04:00
|
|
|
{
|
|
|
|
if (currentItem)
|
|
|
|
{
|
2017-07-04 11:20:42 -04:00
|
|
|
setStatus (currentItem)
|
2017-07-04 09:35:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
Keys.onReleased:
|
2017-07-04 09:35:45 -04:00
|
|
|
{
|
|
|
|
if ((event.key === Qt.Key_Back || Qt.Key_Backspace) && stackView.depth > 1)
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
stackView.pop();
|
|
|
|
event.accepted = true;
|
2017-07-04 09:35:45 -04:00
|
|
|
setStatus (stackView.currentItem)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setStatus (currentItem)
|
2017-06-13 08:51:53 -04:00
|
|
|
{
|
|
|
|
if (currentItem)
|
|
|
|
{
|
2017-06-23 09:01:48 -04:00
|
|
|
if (currentItem.objectName != "chatView" &&
|
|
|
|
currentItem.objectName != "contactsView" &&
|
|
|
|
toolBar.state != "DEFAULT")
|
2017-06-13 08:51:53 -04:00
|
|
|
{
|
2017-06-08 10:21:33 -04:00
|
|
|
toolBar.state = "DEFAULT"
|
|
|
|
}
|
2017-07-04 09:51:03 -04:00
|
|
|
else if (typeof currentItem.changeState === 'function')
|
|
|
|
{
|
|
|
|
currentItem.changeState ()
|
|
|
|
}
|
|
|
|
|
2017-06-08 10:21:33 -04:00
|
|
|
currentItem.focus = true
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
2017-06-08 10:21:33 -04:00
|
|
|
}
|
|
|
|
|
2016-09-15 07:07:13 -04:00
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
state: "core_down"
|
2017-04-07 12:26:08 -04:00
|
|
|
initialItem: BusyOverlay { message: qsTr("Connecting to core...") }
|
|
|
|
|
2017-03-17 12:22:58 -04:00
|
|
|
states: [
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "core_down"
|
|
|
|
PropertyChanges { target: stackView; enabled: false }
|
|
|
|
},
|
|
|
|
State
|
2016-09-15 07:07:13 -04:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
name: "waiting_account_select"
|
|
|
|
PropertyChanges { target: stackView; enabled: true }
|
|
|
|
StateChangeScript
|
2016-12-08 09:56:23 -05:00
|
|
|
{
|
2017-03-17 12:22:58 -04:00
|
|
|
script:
|
|
|
|
{
|
|
|
|
console.log("StateChangeScript waiting_account_select")
|
|
|
|
stackView.clear()
|
2017-04-13 10:47:27 -04:00
|
|
|
stackView.push("qrc:/Locations.qml")
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
2016-12-08 09:56:23 -05:00
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
},
|
|
|
|
State
|
2017-04-07 12:26:08 -04:00
|
|
|
{
|
|
|
|
name: "waiting_startup"
|
|
|
|
PropertyChanges { target: stackView; enabled: false }
|
|
|
|
StateChangeScript
|
|
|
|
{
|
|
|
|
script:
|
|
|
|
{
|
|
|
|
console.log("StateChangeScript waiting_startup")
|
|
|
|
stackView.clear()
|
2017-04-13 10:47:27 -04:00
|
|
|
stackView.push("qrc:/BusyOverlay.qml",
|
2017-04-07 12:26:08 -04:00
|
|
|
{ message: "Core initializing..."})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State
|
2017-03-17 12:22:58 -04:00
|
|
|
{
|
|
|
|
name: "running_ok"
|
|
|
|
PropertyChanges { target: stackView; enabled: true }
|
|
|
|
StateChangeScript
|
|
|
|
{
|
|
|
|
script:
|
|
|
|
{
|
2017-04-03 15:19:14 -04:00
|
|
|
console.log("StateChangeScript running_ok")
|
|
|
|
coreStateCheckTimer.stop()
|
2017-03-17 12:22:58 -04:00
|
|
|
stackView.clear()
|
2017-04-13 10:47:27 -04:00
|
|
|
stackView.push("qrc:/Contacts.qml")
|
2017-04-14 20:17:27 -04:00
|
|
|
while(mainWindow.pendingUriRegister.length > 0)
|
|
|
|
mainWindow.handleIntentUri(
|
|
|
|
mainWindow.pendingUriRegister.shift())
|
2017-03-17 12:22:58 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "running_ok_no_full_control"
|
|
|
|
PropertyChanges { target: stackView; state: "running_ok" }
|
2016-09-27 08:05:14 -04:00
|
|
|
}
|
2017-03-17 12:22:58 -04:00
|
|
|
]
|
2017-04-03 15:19:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Timer
|
|
|
|
{
|
|
|
|
id: coreStateCheckTimer
|
|
|
|
interval: 1000
|
|
|
|
repeat: true
|
|
|
|
triggeredOnStart: true
|
|
|
|
onTriggered:
|
|
|
|
{
|
|
|
|
var ret = rsApi.request("/control/runstate/", "", runStateCallback)
|
|
|
|
if ( ret < 1 )
|
|
|
|
{
|
|
|
|
console.log("checkCoreStatus() core is down")
|
|
|
|
stackView.state = "core_down"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component.onCompleted: start()
|
|
|
|
|
|
|
|
function runStateCallback(par)
|
|
|
|
{
|
|
|
|
var jsonReponse = JSON.parse(par.response)
|
|
|
|
var runState = jsonReponse.data.runstate
|
|
|
|
if(typeof(runState) === 'string') stackView.state = runState
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stackView.state = "core_down"
|
|
|
|
console.log("runStateCallback(...) core is down")
|
|
|
|
}
|
2016-09-15 07:07:13 -04:00
|
|
|
}
|
|
|
|
}
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
function handleIntentUri(uriStr)
|
|
|
|
{
|
2017-07-11 13:13:55 -04:00
|
|
|
console.log("handleIntentUri(uriStr)", uriStr)
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
if(!Array.isArray(uriStr.match(/:\/\/[a-zA-Z.-]*\//g)))
|
|
|
|
{
|
|
|
|
/* RetroShare GUI produces links without hostname and only two
|
|
|
|
* slashes after scheme causing the first piece of the path part
|
|
|
|
* being interpreted as host, this is awckard and should be fixed in
|
|
|
|
* the GUI, in the meantime we add a slash for easier parsing, in
|
|
|
|
* case there is no hostname and just two slashes, we might consider
|
|
|
|
* to use +hostname+ part for some trick in the future, for example
|
|
|
|
* it could help other application to recognize retroshare link by
|
|
|
|
* putting a domain name there that has no meaning for retroshare
|
|
|
|
*/
|
|
|
|
uriStr = uriStr.replace("://", ":///")
|
|
|
|
}
|
|
|
|
|
|
|
|
var uri = new UriJs.URI(uriStr)
|
|
|
|
var hPath = uri.path() // no nesting ATM segmentCoded()
|
2017-07-11 13:13:55 -04:00
|
|
|
console.log("hPath", hPath)
|
|
|
|
|
|
|
|
var authority = uri.authority()
|
|
|
|
console.log("authority", authority)
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
if(typeof uriHandlersRegister[hPath] == "function")
|
|
|
|
{
|
|
|
|
console.log("handleIntentUri(uriStr)", "found handler for path",
|
|
|
|
hPath, uriHandlersRegister[hPath])
|
|
|
|
uriHandlersRegister[hPath](uriStr)
|
|
|
|
}
|
2017-07-11 13:13:55 -04:00
|
|
|
|
|
|
|
else if (typeof uriHandlersRegister[authority] == "function" )
|
|
|
|
{
|
|
|
|
console.log("handleIntentUri(uriStr)", "found handler for path",
|
|
|
|
authority, uriHandlersRegister[authority])
|
|
|
|
uriHandlersRegister[authority](uriStr)
|
|
|
|
}
|
2017-04-13 10:47:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function certificateLinkHandler(uriStr)
|
|
|
|
{
|
|
|
|
console.log("certificateLinkHandler(uriStr)", coreReady)
|
|
|
|
|
2017-04-14 20:17:27 -04:00
|
|
|
if(!coreReady)
|
|
|
|
{
|
|
|
|
// Save cert uri for later processing as we need core to examine it
|
|
|
|
pendingUriRegister.push(uriStr)
|
|
|
|
return
|
|
|
|
}
|
2017-04-13 10:47:27 -04:00
|
|
|
|
|
|
|
var uri = new UriJs.URI(uriStr)
|
|
|
|
var uQuery = uri.search(true)
|
|
|
|
if(uQuery.radix)
|
|
|
|
{
|
|
|
|
var certStr = UriJs.URI.decode(uQuery.radix)
|
|
|
|
|
|
|
|
// Workaround https://github.com/RetroShare/RetroShare/issues/772
|
|
|
|
certStr = certStr.replace(/ /g, "+")
|
|
|
|
|
|
|
|
rsApi.request(
|
|
|
|
"/peers/examine_cert/",
|
|
|
|
JSON.stringify({cert_string: certStr}),
|
|
|
|
function(par)
|
|
|
|
{
|
|
|
|
console.log("/peers/examine_cert/ CB", par)
|
|
|
|
var jData = JSON.parse(par.response).data
|
|
|
|
stackView.push(
|
|
|
|
"qrc:/TrustedNodeDetails.qml",
|
|
|
|
{
|
|
|
|
nodeCert: certStr,
|
|
|
|
pgpName: jData.name,
|
|
|
|
pgpId: jData.pgp_id,
|
|
|
|
locations:
|
|
|
|
[{
|
|
|
|
location: jData.location,
|
|
|
|
peer_id: jData.peer_id
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-04-20 10:05:15 -04:00
|
|
|
|
|
|
|
function contactLinkHandler(uriStr)
|
|
|
|
{
|
|
|
|
console.log("contactLinkHandler(uriStr)", coreReady)
|
|
|
|
|
|
|
|
if(!coreReady)
|
|
|
|
{
|
|
|
|
// Save cert uri for later processing as we need core to examine it
|
|
|
|
pendingUriRegister.push(uriStr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var uri = new UriJs.URI(uriStr)
|
|
|
|
var uQuery = uri.search(true)
|
|
|
|
if(uQuery.groupdata)
|
|
|
|
{
|
|
|
|
contactImportPopup.expectedName = uQuery.name
|
|
|
|
contactImportPopup.expectedGxsId = uQuery.gxsid
|
|
|
|
|
|
|
|
rsApi.request(
|
|
|
|
"/identity/import_key",
|
|
|
|
JSON.stringify({radix: uQuery.groupdata}),
|
|
|
|
function(par)
|
|
|
|
{
|
|
|
|
var jD = JSON.parse(par.response).data
|
|
|
|
contactImportPopup.realGxsId = jD.gxs_id
|
|
|
|
contactImportPopup.open()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-07-31 10:52:03 -04:00
|
|
|
|
|
|
|
function openContactsViewLinkHandler (uriStr)
|
|
|
|
{
|
2017-07-31 11:42:45 -04:00
|
|
|
console.log("openContactsViewLinkHandler(uriStr)" , uriStr)
|
2017-07-31 10:52:03 -04:00
|
|
|
if(coreReady)
|
|
|
|
{
|
2017-07-31 11:42:45 -04:00
|
|
|
var uri = new UriJs.URI(uriStr)
|
|
|
|
var query = UriJs.URI.parseQuery(uri.search());
|
|
|
|
if (query.gxsId && query.name)
|
|
|
|
{
|
|
|
|
|
|
|
|
ChatCache.chatHelper.startDistantChat(ChatCache.contactsCache.own.gxs_id,
|
|
|
|
query.gxsId,
|
|
|
|
query.name,
|
|
|
|
function (chatId)
|
|
|
|
{
|
|
|
|
stackView.push("qrc:/ChatView.qml", {'chatId': chatId})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stackView.push("qrc:/Contacts.qml" )
|
|
|
|
}
|
2017-07-31 10:52:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-20 10:05:15 -04:00
|
|
|
Popup
|
|
|
|
{
|
|
|
|
id: contactImportPopup
|
|
|
|
property string expectedName
|
|
|
|
property string expectedGxsId
|
|
|
|
property string realGxsId
|
|
|
|
|
|
|
|
function idMatch() { return expectedGxsId === realGxsId }
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
onVisibleChanged: if(visible && idMatch()) contactImportTimer.start()
|
|
|
|
|
|
|
|
x: parent.x + parent.width/2 - width/2
|
|
|
|
y: parent.y + parent.height/2 - height/2
|
|
|
|
|
|
|
|
Column
|
|
|
|
{
|
|
|
|
spacing: 3
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
Text
|
|
|
|
{
|
|
|
|
text: qsTr("%1 key imported").arg(
|
|
|
|
contactImportPopup.expectedName)
|
2017-04-20 15:39:59 -04:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2017-04-20 10:05:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Text
|
|
|
|
{
|
|
|
|
text: qsTr("Link malformed!")
|
|
|
|
color: "red"
|
|
|
|
visible: contactImportPopup.visible &&
|
|
|
|
!contactImportPopup.idMatch()
|
2017-04-20 15:39:59 -04:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2017-04-20 10:05:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Text
|
|
|
|
{
|
|
|
|
text:
|
|
|
|
qsTr("Expected id and real one differs:") +
|
|
|
|
"<br/><pre>" + contactImportPopup.expectedGxsId +
|
|
|
|
"<br/>" + contactImportPopup.realGxsId + "</pre>"
|
|
|
|
visible: contactImportPopup.visible &&
|
|
|
|
!contactImportPopup.idMatch()
|
2017-04-20 15:39:59 -04:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2017-04-20 10:05:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer
|
|
|
|
{
|
|
|
|
id: contactImportTimer
|
|
|
|
interval: 1500
|
|
|
|
onTriggered: contactImportPopup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Popup
|
|
|
|
{
|
|
|
|
id: linkCopiedPopup
|
|
|
|
property string itemName
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
onVisibleChanged: if(visible) contactLinkTimer.start()
|
|
|
|
|
|
|
|
x: parent.x + parent.width/2 - width/2
|
|
|
|
y: parent.y + parent.height/2 - height/2
|
|
|
|
|
|
|
|
Text
|
|
|
|
{
|
|
|
|
text:
|
|
|
|
qsTr("%1 link copied to clipboard").arg(
|
|
|
|
linkCopiedPopup.itemName)
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer
|
|
|
|
{
|
|
|
|
id: contactLinkTimer
|
|
|
|
interval: 1500
|
|
|
|
onTriggered: linkCopiedPopup.close()
|
|
|
|
}
|
|
|
|
}
|
2017-08-02 12:09:40 -04:00
|
|
|
|
|
|
|
FontLoader { id: emojiFont; source: "/fonts/OpenSansEmoji.ttf" }
|
|
|
|
|
|
|
|
QtObject
|
|
|
|
{
|
|
|
|
id: theme
|
|
|
|
|
|
|
|
property var emojiFontName: emojiFont.name
|
|
|
|
|
|
|
|
property var supportedEmojiFonts: ["Android Emoji"]
|
|
|
|
property var rootFontName: emojiFont.name
|
|
|
|
|
|
|
|
// If native emoji font exists use it, else use RS emoji font
|
|
|
|
function selectFont ()
|
|
|
|
{
|
|
|
|
var fontFamilies = Qt.fontFamilies()
|
|
|
|
fontFamilies.some(function (f)
|
|
|
|
{
|
|
|
|
if (supportedEmojiFonts.indexOf(f) !== -1)
|
|
|
|
{
|
|
|
|
emojiFontName = f
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted:
|
|
|
|
{
|
|
|
|
selectFont()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-01 08:31:07 -05:00
|
|
|
property var netStatus: ({})
|
|
|
|
function refreshNetStatus(optCallback)
|
|
|
|
{
|
2018-02-01 15:26:36 -05:00
|
|
|
console.log("refreshNetStatus(optCallback)")
|
2018-02-01 08:31:07 -05:00
|
|
|
rsApi.request("/peers/get_network_options", "", function(par)
|
|
|
|
{
|
|
|
|
var json = JSON.parse(par.response)
|
|
|
|
mainWindow.netStatus = json.data
|
|
|
|
if(typeof(optCallback) === "function") optCallback();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateDhtMode(stopping)
|
|
|
|
{
|
|
|
|
console.log("updateDhtMode(stopping)", stopping)
|
|
|
|
|
|
|
|
switch(AppSettings.dhtMode)
|
|
|
|
{
|
|
|
|
case "On": mainWindow.netStatus.discovery_mode = 0; break;
|
|
|
|
case "Off": mainWindow.netStatus.discovery_mode = 1; break;
|
|
|
|
case "Interactive": mainWindow.netStatus.discovery_mode = stopping ? 1:0; break
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("updateDhtMode(stopping)", stopping, netStatus.discovery_mode)
|
|
|
|
|
|
|
|
rsApi.request("/peers/set_network_options", JSON.stringify(netStatus))
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onDestruction: if(coreReady) updateDhtMode(true)
|
|
|
|
|
|
|
|
|
|
|
|
Connections
|
|
|
|
{
|
|
|
|
target: AppSettings
|
|
|
|
onDhtModeChanged:
|
|
|
|
{
|
|
|
|
Qt.application.state
|
|
|
|
console.log("onDhtModeChanged", AppSettings.dhtMode)
|
|
|
|
if(coreReady) updateDhtMode(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections
|
|
|
|
{
|
|
|
|
target: stackView
|
|
|
|
onStateChanged: if(coreReady) refreshNetStatus(function() {updateDhtMode(false)})
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections
|
|
|
|
{
|
|
|
|
target: Qt.application
|
|
|
|
onStateChanged:
|
|
|
|
{
|
|
|
|
console.log("Qt.application.state changed to", Qt.ApplicationSuspended)
|
|
|
|
if(coreReady && (Qt.application.state === Qt.ApplicationSuspended))
|
|
|
|
updateDhtMode(true)
|
|
|
|
}
|
|
|
|
}
|
2016-09-04 09:01:44 -04:00
|
|
|
}
|