...
 
Commits (2)
......@@ -7,10 +7,12 @@
<file alias="qml/AboutDialog.qml">src/qml/AboutDialog.qml</file>
<file alias="qml/GlobalDrawer.qml">src/qml/GlobalDrawer.qml</file>
<file alias="qml/EmptyChatPage.qml">src/qml/EmptyChatPage.qml</file>
<file alias="qml/QrScannerPage.qml">src/qml/QrScannerPage.qml</file>
<file alias="qml/elements/SubRequestAcceptSheet.qml">src/qml/elements/SubRequestAcceptSheet.qml</file>
<file alias="qml/elements/RosterAddContactSheet.qml">src/qml/elements/RosterAddContactSheet.qml</file>
<file alias="qml/elements/RosterRemoveContactSheet.qml">src/qml/elements/RosterRemoveContactSheet.qml</file>
<file alias="qml/elements/RosterListItem.qml">src/qml/elements/RosterListItem.qml</file>
<file alias="qml/elements/MessageCounter.qml">src/qml/elements/MessageCounter.qml</file>
<file alias="qml/elements/ChatMessage.qml">src/qml/elements/ChatMessage.qml</file>
......
......@@ -193,18 +193,38 @@ quint8 Kaidan::getDisconnReason() const
return static_cast<quint8>(disconnReason);
}
void Kaidan::addOpenUri(const QByteArray &uri)
void Kaidan::addOpenUri(const QString &uri)
{
qDebug() << "[main]" << uri;
if (!uri.startsWith("xmpp:") || !uri.contains("@"))
if (startsAsXmppUri(uri) && uri.contains(";")) {
return;
}
if (connectionState == ConnectionState::StateConnected) {
emit xmppUriReceived(QString::fromUtf8(uri));
emit xmppUriReceived(uri);
} else {
//: The link is an XMPP-URI (i.e. 'xmpp:kaidan@muc.kaidan.im?join' for joining a chat)
emit passiveNotificationRequested(tr("The link will be opened after you have connected."));
openUriCache = QString::fromUtf8(uri);
openUriCache = uri;
}
}
ClientWorker::Credentials Kaidan::parseCredentialsUri(const QString &uri)
{
qDebug() << "[main]" << uri;
if (!(startsAsXmppUri(uri) && uri.contains(";"))) {
throw std::invalid_argument("String is not an argument.");
}
ClientWorker::Credentials creds;
creds.jid = uri.split(":")[1].split("?")[0];
creds.password = uri.split("password=")[1];
return creds;
}
bool Kaidan::startsAsXmppUri(const QString &uri) {
return uri.startsWith("xmpp:") && uri.contains("@") && uri.contains("?");
}
......@@ -205,7 +205,18 @@ public:
/**
* Adds XMPP URI to open as soon as possible
*/
void addOpenUri(const QByteArray &uri);
void addOpenUri(const QString &uri);
/**
* Parses bare JID and password from a string (e.g. from scanning
* a QR code) for URIs like xmpp:user@example.org?login;password=abc
*/
ClientWorker::Credentials parseCredentialsUri(const QString &uri);
/**
* Checks whether the given URI starts as an XMPP URI (e.g. user@example.org?join)
*/
bool startsAsXmppUri(const QString &uri);
/**
* Returns whether an HTTP File Upload service has been found
......
......@@ -235,7 +235,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
// open the XMPP-URI/link (if given)
if (!parser.positionalArguments().isEmpty())
kaidan.addOpenUri(parser.positionalArguments()[0].toUtf8());
kaidan.addOpenUri(parser.positionalArguments()[0]);
//
// QML-GUI
......
......@@ -38,6 +38,14 @@ import im.kaidan.kaidan 1.0
Kirigami.Page {
title: qsTr("Log in")
actions.contextualActions: [
Kirigami.Action {
text: qsTr("Log in using a QR-Code")
icon.name: "view-barcode"
onTriggered: pageStack.layers.push(qrScannerPage)
}
]
ColumnLayout {
anchors.fill: parent
......
import QtQuick 2.0
import org.kde.kirigami 2.2 as Kirigami
import QtMultimedia 5.9
Kirigami.Page {
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
title: qsTr("Scan QR code")
VideoOutput {
id: viewfinder
anchors.fill: parent
source: camera
}
Camera {
id: camera
captureMode: Camera.CaptureVideo
}
}
......@@ -71,6 +71,7 @@ Kirigami.ApplicationWindow {
Component {id: rosterPage; RosterPage {}}
Component {id: emptyChatPage; EmptyChatPage {}}
Component {id: settingsPage; SettingsPage {}}
Component {id: qrScannerPage; QrScannerPage {}}
function passiveNotification(text) {
showPassiveNotification(text, "long")
......