2016-09-15 13:07:13 +02:00
|
|
|
/*
|
|
|
|
* RetroShare Android QML App
|
2017-03-17 17:22:58 +01:00
|
|
|
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
2016-09-15 13:07:13 +02: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 15:01:44 +02:00
|
|
|
|
|
|
|
import QtQuick 2.2
|
2017-03-24 12:02:13 +01:00
|
|
|
import QtQuick.Controls 2.0
|
2016-09-15 13:07:13 +02:00
|
|
|
import org.retroshare.qml_components.LibresapiLocalClient 1.0
|
2017-04-11 13:11:57 +02:00
|
|
|
import "URI.js" as URI
|
2017-04-11 15:48:16 +02:00
|
|
|
import "." //Needed for TokensManager singleton
|
2016-09-15 13:07:13 +02:00
|
|
|
|
|
|
|
ApplicationWindow
|
|
|
|
{
|
|
|
|
id: mainWindow
|
|
|
|
visible: true
|
2017-03-17 17:22:58 +01:00
|
|
|
title: "RetroShare"
|
2016-10-26 20:37:28 +02:00
|
|
|
width: 400
|
|
|
|
height: 400
|
2016-09-15 13:07:13 +02:00
|
|
|
|
2017-04-07 18:26:08 +02:00
|
|
|
property string pgp_name
|
|
|
|
|
2017-04-11 13:11:57 +02:00
|
|
|
function handleIntentUri(uriStr)
|
|
|
|
{
|
|
|
|
console.log("handleIntentUri", JSON.stringify(URI.parse(uriStr), null, 1))
|
|
|
|
}
|
|
|
|
|
2017-03-24 12:02:13 +01:00
|
|
|
header: ToolBar
|
2016-09-15 13:07:13 +02:00
|
|
|
{
|
2017-03-24 12:02:13 +01:00
|
|
|
id: toolBar
|
|
|
|
|
2017-03-17 17:22:58 +01:00
|
|
|
Image
|
|
|
|
{
|
|
|
|
id: rsIcon
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
height: Math.max(30, parent.height - 4)
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
source: "icons/retroshare06.png"
|
|
|
|
}
|
|
|
|
Label
|
|
|
|
{
|
|
|
|
text: "RetroShare"
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: rsIcon.right
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
}
|
2017-03-24 12:02:13 +01:00
|
|
|
MouseArea
|
2016-09-15 13:07:13 +02:00
|
|
|
{
|
2017-03-24 12:02:13 +01:00
|
|
|
height: parent.height
|
|
|
|
width: parent.height
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 2
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
onClicked: menu.open()
|
|
|
|
|
|
|
|
Image
|
2016-09-15 13:07:13 +02:00
|
|
|
{
|
2017-03-24 12:02:13 +01:00
|
|
|
source: "qrc:/qml/icons/application-menu.png"
|
|
|
|
height: parent.height - 10
|
|
|
|
width: parent.height - 10
|
|
|
|
anchors.centerIn: parent
|
2016-09-15 13:07:13 +02:00
|
|
|
}
|
2017-03-24 12:02:13 +01:00
|
|
|
|
|
|
|
Menu
|
2016-09-15 13:07:13 +02:00
|
|
|
{
|
2017-03-24 12:02:13 +01:00
|
|
|
id: menu
|
|
|
|
y: parent.y + parent.height
|
|
|
|
|
|
|
|
MenuItem
|
|
|
|
{
|
|
|
|
text: qsTr("Trusted Nodes")
|
|
|
|
//iconSource: "qrc:/qml/icons/document-share.png"
|
2017-04-03 21:19:14 +02:00
|
|
|
onTriggered: stackView.push("qrc:/qml/TrustedNodesView.qml")
|
2017-03-24 12:02:13 +01:00
|
|
|
}
|
|
|
|
MenuItem
|
|
|
|
{
|
|
|
|
text: qsTr("Search Contacts")
|
|
|
|
onTriggered:
|
2017-04-03 21:19:14 +02:00
|
|
|
stackView.push("qrc:/qml/Contacts.qml",
|
|
|
|
{'searching': true} )
|
2017-03-24 12:02:13 +01:00
|
|
|
}
|
|
|
|
MenuItem
|
|
|
|
{
|
|
|
|
text: "Terminate Core"
|
|
|
|
onTriggered: rsApi.request("/control/shutdown")
|
|
|
|
}
|
2016-09-15 13:07:13 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 17:22:58 +01:00
|
|
|
}
|
2016-09-15 13:07:13 +02:00
|
|
|
|
2017-03-17 17:22:58 +01:00
|
|
|
StackView
|
|
|
|
{
|
|
|
|
id: stackView
|
|
|
|
anchors.fill: parent
|
|
|
|
Keys.onReleased:
|
|
|
|
if (event.key === Qt.Key_Back && stackView.depth > 1)
|
2016-09-15 13:07:13 +02:00
|
|
|
{
|
2017-03-17 17:22:58 +01:00
|
|
|
stackView.pop();
|
|
|
|
event.accepted = true;
|
2016-09-15 13:07:13 +02:00
|
|
|
}
|
|
|
|
|
2017-03-17 17:22:58 +01:00
|
|
|
state: "core_down"
|
2017-04-07 18:26:08 +02:00
|
|
|
initialItem: BusyOverlay { message: qsTr("Connecting to core...") }
|
|
|
|
|
2017-03-17 17:22:58 +01:00
|
|
|
states: [
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "core_down"
|
|
|
|
PropertyChanges { target: stackView; enabled: false }
|
|
|
|
},
|
|
|
|
State
|
2016-09-15 13:07:13 +02:00
|
|
|
{
|
2017-03-17 17:22:58 +01:00
|
|
|
name: "waiting_account_select"
|
|
|
|
PropertyChanges { target: stackView; enabled: true }
|
|
|
|
StateChangeScript
|
2016-12-08 15:56:23 +01:00
|
|
|
{
|
2017-03-17 17:22:58 +01:00
|
|
|
script:
|
|
|
|
{
|
|
|
|
console.log("StateChangeScript waiting_account_select")
|
|
|
|
stackView.clear()
|
2017-03-24 12:02:13 +01:00
|
|
|
stackView.push("qrc:/qml/Locations.qml")
|
2017-03-17 17:22:58 +01:00
|
|
|
}
|
2016-12-08 15:56:23 +01:00
|
|
|
}
|
2017-03-17 17:22:58 +01:00
|
|
|
},
|
|
|
|
State
|
2017-04-07 18:26:08 +02:00
|
|
|
{
|
|
|
|
name: "waiting_startup"
|
|
|
|
PropertyChanges { target: stackView; enabled: false }
|
|
|
|
StateChangeScript
|
|
|
|
{
|
|
|
|
script:
|
|
|
|
{
|
|
|
|
console.log("StateChangeScript waiting_startup")
|
|
|
|
stackView.clear()
|
|
|
|
stackView.push("qrc:/qml/BusyOverlay.qml",
|
|
|
|
{ message: "Core initializing..."})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State
|
2017-03-17 17:22:58 +01:00
|
|
|
{
|
|
|
|
name: "running_ok"
|
|
|
|
PropertyChanges { target: stackView; enabled: true }
|
|
|
|
StateChangeScript
|
|
|
|
{
|
|
|
|
script:
|
|
|
|
{
|
2017-04-03 21:19:14 +02:00
|
|
|
console.log("StateChangeScript running_ok")
|
|
|
|
coreStateCheckTimer.stop()
|
2017-03-17 17:22:58 +01:00
|
|
|
stackView.clear()
|
2017-03-24 12:02:13 +01:00
|
|
|
stackView.push("qrc:/qml/Contacts.qml")
|
2017-03-17 17:22:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State
|
|
|
|
{
|
|
|
|
name: "running_ok_no_full_control"
|
|
|
|
PropertyChanges { target: stackView; state: "running_ok" }
|
2016-09-27 14:05:14 +02:00
|
|
|
}
|
2017-03-17 17:22:58 +01:00
|
|
|
]
|
2017-04-03 21:19:14 +02: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 13:07:13 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-04 15:01:44 +02:00
|
|
|
}
|