Commit c714ad8d authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Main): display popup when auth failed

parent c1645184
......@@ -89,6 +89,7 @@ set(SOURCES
src/app/providers/ThumbnailProvider.cpp
src/app/translator/DefaultTranslator.cpp
src/components/assistant/AssistantModel.cpp
src/components/authentication/Authentication.cpp
src/components/call/CallModel.cpp
src/components/calls/CallsListModel.cpp
src/components/camera/Camera.cpp
......@@ -126,9 +127,10 @@ set(HEADERS
src/app/providers/ThumbnailProvider.hpp
src/app/translator/DefaultTranslator.hpp
src/components/assistant/AssistantModel.hpp
src/components/camera/Camera.hpp
src/components/authentication/Authentication.hpp
src/components/call/CallModel.hpp
src/components/calls/CallsListModel.hpp
src/components/camera/Camera.hpp
src/components/camera/MSFunctions.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
......
......@@ -144,6 +144,33 @@
<translation>Please verify that you have validated your account or try again.</translation>
</message>
</context>
<context>
<name>AuthenticationRequest</name>
<message>
<source>cancel</source>
<translation>CANCEL</translation>
</message>
<message>
<source>confirm</source>
<translation>LOGIN</translation>
</message>
<message>
<source>identityLabel</source>
<translation>Identity</translation>
</message>
<message>
<source>passwordLabel</source>
<translation>Password</translation>
</message>
<message>
<source>authentificationRequestDescription</source>
<translation>Unable to authenticate. Please verify your password.</translation>
</message>
<message>
<source>userIdLabel</source>
<translation>User ID (optional)</translation>
</message>
</context>
<context>
<name>Calls</name>
<message>
......
......@@ -144,6 +144,33 @@
<translation>Merci de vérifier que vous avez validé votre compte ou réessayez plus tard.</translation>
</message>
</context>
<context>
<name>AuthenticationRequest</name>
<message>
<source>cancel</source>
<translation>ANNULER</translation>
</message>
<message>
<source>confirm</source>
<translation>SE CONNECTER</translation>
</message>
<message>
<source>identityLabel</source>
<translation>Identité</translation>
</message>
<message>
<source>passwordLabel</source>
<translation>Mot de passe</translation>
</message>
<message>
<source>authentificationRequestDescription</source>
<translation>Impossible de vous authentifier. Merci de vérifier votre mot de passe.</translation>
</message>
<message>
<source>userIdLabel</source>
<translation>ID utilisateur (optionnel)</translation>
</message>
</context>
<context>
<name>Calls</name>
<message>
......
......@@ -345,6 +345,8 @@
<file>ui/views/App/Main/Assistant/UseLinphoneSipAccountWithPhoneNumber.qml</file>
<file>ui/views/App/Main/Assistant/UseLinphoneSipAccountWithUsername.qml</file>
<file>ui/views/App/Main/Assistant/UseOtherSipAccount.qml</file>
<file>ui/views/App/Main/AuthenticationRequest.js</file>
<file>ui/views/App/Main/AuthenticationRequest.qml</file>
<file>ui/views/App/Main/ContactEdit.js</file>
<file>ui/views/App/Main/ContactEdit.qml</file>
<file>ui/views/App/Main/Contacts.qml</file>
......@@ -375,6 +377,7 @@
<file>ui/views/App/Styles/Main/Assistant/CreateLinphoneSipAccountStyle.qml</file>
<file>ui/views/App/Styles/Main/AssistantStyle.qml</file>
<file>ui/views/App/Styles/Main/Assistant/UseLinphoneSipAccountStyle.qml</file>
<file>ui/views/App/Styles/Main/AuthenticationRequestStyle.qml</file>
<file>ui/views/App/Styles/Main/ContactEditStyle.qml</file>
<file>ui/views/App/Styles/Main/ContactsStyle.qml</file>
<file>ui/views/App/Styles/Main/ConversationStyle.qml</file>
......
......@@ -276,10 +276,11 @@ void App::registerTypes () {
qInfo() << "Registering types...";
qmlRegisterType<AssistantModel>("Linphone", 1, 0, "AssistantModel");
qmlRegisterType<Authentication>("Linphone", 1, 0, "Authentication");
qmlRegisterType<Camera>("Linphone", 1, 0, "Camera");
qmlRegisterType<ContactsListProxyModel>("Linphone", 1, 0, "ContactsListProxyModel");
qmlRegisterType<ChatModel>("Linphone", 1, 0, "ChatModel");
qmlRegisterType<ChatProxyModel>("Linphone", 1, 0, "ChatProxyModel");
qmlRegisterType<ContactsListProxyModel>("Linphone", 1, 0, "ContactsListProxyModel");
qmlRegisterType<SmartSearchBarModel>("Linphone", 1, 0, "SmartSearchBarModel");
qRegisterMetaType<ChatModel::EntryType>("ChatModel::EntryType");
......@@ -394,7 +395,7 @@ void App::openAppAfterInit () {
getMainWindow()->showNormal();
#else
getMainWindow()->showNormal();
#endif // ifndef __APPLE__
#endif // ifndef __APPLE__
}
// -----------------------------------------------------------------------------
......
......@@ -21,6 +21,7 @@
*/
#include "assistant/AssistantModel.hpp"
#include "authentication/Authentication.hpp"
#include "calls/CallsListModel.hpp"
#include "camera/Camera.hpp"
#include "chat/ChatProxyModel.hpp"
......
/*
* Authentication.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 13, 2017
* Author: Ronan Abhamon
*/
#include "../../utils.hpp"
#include "../core/CoreManager.hpp"
#include "Authentication.hpp"
using namespace std;
// =============================================================================
Authentication::Authentication (QObject *parent) : QObject(parent) {
QObject::connect(
&(*CoreManager::getInstance()->getHandlers()), &CoreHandlers::authenticationRequested,
this, &Authentication::handleAuthenticationRequested
);
}
void Authentication::handleAuthenticationRequested (const shared_ptr<linphone::AuthInfo> &authInfo) {
emit authenticationRequested(
QVariant::fromValue(authInfo),
QStringLiteral("%1@%2").arg(
::Utils::linphoneStringToQString(authInfo->getUsername())
).arg(
::Utils::linphoneStringToQString(authInfo->getDomain())
),
::Utils::linphoneStringToQString(authInfo->getUserid())
);
}
/*
* Authentication.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 13, 2017
* Author: Ronan Abhamon
*/
#ifndef AUTHENTICATION_H_
#define AUTHENTICATION_H_
#include <linphone++/linphone.hh>
#include <QObject>
// =============================================================================
class Authentication : public QObject {
Q_OBJECT;
public:
Authentication (QObject *parent = Q_NULLPTR);
~Authentication () = default;
signals:
void authenticationRequested (const QVariant &authInfo, const QString &sipAddress, const QString &userId);
private:
void handleAuthenticationRequested (const std::shared_ptr<linphone::AuthInfo> &authInfo);
};
Q_DECLARE_METATYPE(std::shared_ptr<linphone::AuthInfo> );
#endif // AUTHENTICATION_H_
......@@ -34,10 +34,10 @@ using namespace std;
void CoreHandlers::onAuthenticationRequested (
const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::AuthInfo> &,
const shared_ptr<linphone::AuthInfo> &auth_info,
linphone::AuthMethod
) {
qDebug() << "Auth request";
emit authenticationRequested(auth_info);
}
void CoreHandlers::onCallStateChanged (
......
......@@ -34,6 +34,7 @@ class CoreHandlers :
Q_OBJECT;
signals:
void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &auth_info);
void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
void presenceReceived (const QString &sip_address, const std::shared_ptr<const linphone::PresenceModel> &presence_model);
......
......@@ -171,6 +171,17 @@ shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
return CoreManager::getInstance()->getCore()->createProxyConfig();
}
void AccountSettingsModel::addAuthInfo (
const shared_ptr<linphone::AuthInfo> &auth_info,
const QString &password,
const QString &user_id
) {
auth_info->setPasswd(::Utils::qStringToLinphoneString(password));
auth_info->setUserid(::Utils::qStringToLinphoneString(user_id));
CoreManager::getInstance()->getCore()->addAuthInfo(auth_info);
}
void AccountSettingsModel::eraseAllPasswords () {
CoreManager::getInstance()->getCore()->clearAllAuthInfo();
}
......
......@@ -66,6 +66,12 @@ public:
Q_INVOKABLE std::shared_ptr<linphone::ProxyConfig> createProxyConfig ();
Q_INVOKABLE void addAuthInfo (
const std::shared_ptr<linphone::AuthInfo> &auth_info,
const QString &password,
const QString &user_id
);
Q_INVOKABLE void eraseAllPasswords ();
signals:
......
......@@ -23,7 +23,7 @@ QtObject {
}
property QtObject description: QtObject {
property color color: Colors.l
property color color: Colors.j
property int fontSize: 11
property int verticalMargin: 25
}
......
// =============================================================================
// `AuthenticationRequest.qml` Logic.
// =============================================================================
.import Linphone 1.0 as Linphone
// =============================================================================
function confirmPassword () {
Linphone.AccountSettingsModel.addAuthInfo(dialog.authInfo, password.text, userId.text)
}
import QtQuick 2.7
import Common 1.0
import App.Styles 1.0
import 'AuthenticationRequest.js' as Logic
// =============================================================================
DialogPlus {
id: dialog
property alias sipAddress: identity.text
property alias userId: userId.text
property var authInfo
buttons: [
TextButtonA {
text: qsTr('cancel')
onClicked: exit(0)
},
TextButtonB {
enabled: password.length > 0
text: qsTr('confirm')
onClicked: {
Logic.confirmPassword()
exit(1)
}
}
]
centeredButtons: true
descriptionText: qsTr('authentificationRequestDescription')
height: AuthenticationRequestStyle.height
width: AuthenticationRequestStyle.width
// ---------------------------------------------------------------------------
Form {
orientation: Qt.Vertical
anchors {
left: parent.left
leftMargin: AuthenticationRequestStyle.leftMargin
right: parent.right
rightMargin: AuthenticationRequestStyle.rightMargin
}
FormLine {
FormGroup {
label: qsTr('identityLabel')
TextField {
id: identity
readOnly: true
}
}
}
FormLine {
FormGroup {
label: qsTr('userIdLabel')
TextField {
id: userId
}
}
}
FormLine {
FormGroup {
label: qsTr('passwordLabel')
TextField {
id: password
}
}
}
}
}
......@@ -85,3 +85,13 @@ function updateSelectedEntry (view, props) {
timeline.resetSelectedEntry()
}
}
// -----------------------------------------------------------------------------
function handleAuthenticationRequested (authInfo, sipAddress, userId) {
window.attachVirtualWindow(Qt.resolvedUrl('AuthenticationRequest.qml'), {
authInfo: authInfo,
sipAddress: sipAddress,
userId: userId
})
}
......@@ -84,6 +84,12 @@ ApplicationWindow {
spacing: 0
// -----------------------------------------------------------------------
Authentication {
onAuthenticationRequested: Logic.handleAuthenticationRequested(authInfo, sipAddress, userId)
}
// -----------------------------------------------------------------------
// Toolbar properties.
// -----------------------------------------------------------------------
......
pragma Singleton
import QtQuick 2.7
// =============================================================================
QtObject {
property int height: 366
property int leftMargin: 35
property int rightMargin: 35
property int width: 480
}
pragma Singleton
import QtQuick 2.7
import Common 1.0
// =============================================================================
QtObject {
......
......@@ -14,6 +14,7 @@ singleton CreateLinphoneSipAccountStyle 1.0 Main/Assistant/CreateLinp
singleton UseLinphoneSipAccountStyle 1.0 Main/Assistant/UseLinphoneSipAccountStyle.qml
singleton AssistantStyle 1.0 Main/AssistantStyle.qml
singleton AuthenticationRequestStyle 1.0 Main/AuthenticationRequestStyle.qml
singleton ContactEditStyle 1.0 Main/ContactEditStyle.qml
singleton ContactsStyle 1.0 Main/ContactsStyle.qml
singleton ConversationStyle 1.0 Main/ConversationStyle.qml
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment