Commit a5ec0c8e authored by Aline Gondim Santos's avatar Aline Gondim Santos

plugins: add ChatHandler API

Change-Id: I415fc953b9111ca7e3d899c1531a42bd43716ab2
parent 4a06565e
......@@ -66,7 +66,7 @@ set(COMMON_SOURCES
${SRC_DIR}/settingsadapter.cpp
${SRC_DIR}/deviceitemlistmodel.cpp
${SRC_DIR}/pluginitemlistmodel.cpp
${SRC_DIR}/mediahandleritemlistmodel.cpp
${SRC_DIR}/pluginhandleritemlistmodel.cpp
${SRC_DIR}/preferenceitemlistmodel.cpp
${SRC_DIR}/mediacodeclistmodel.cpp
${SRC_DIR}/accountstomigratelistmodel.cpp
......@@ -115,7 +115,7 @@ set(COMMON_HEADERS
${SRC_DIR}/settingsadapter.h
${SRC_DIR}/deviceitemlistmodel.h
${SRC_DIR}/pluginitemlistmodel.h
${SRC_DIR}/mediahandleritemlistmodel.h
${SRC_DIR}/pluginhandleritemlistmodel.h
${SRC_DIR}/preferenceitemlistmodel.h
${SRC_DIR}/mediacodeclistmodel.h
${SRC_DIR}/accountstomigratelistmodel.h
......
......@@ -170,7 +170,7 @@ HEADERS += \
src/settingsadapter.h \
src/deviceitemlistmodel.h \
src/pluginitemlistmodel.h \
src/mediahandleritemlistmodel.h \
src/pluginhandleritemlistmodel.h \
src/preferenceitemlistmodel.h \
src/mediacodeclistmodel.h \
src/accountstomigratelistmodel.h \
......@@ -211,7 +211,7 @@ SOURCES += \
src/settingsadapter.cpp \
src/deviceitemlistmodel.cpp \
src/pluginitemlistmodel.cpp \
src/mediahandleritemlistmodel.cpp \
src/pluginhandleritemlistmodel.cpp \
src/preferenceitemlistmodel.cpp \
src/mediacodeclistmodel.cpp \
src/accountstomigratelistmodel.cpp \
......
......@@ -45,7 +45,7 @@
<file>src/commoncomponents/SettingParaCombobox.qml</file>
<file>src/settingsview/components/DeviceItemDelegate.qml</file>
<file>src/settingsview/components/PluginItemDelegate.qml</file>
<file>src/mainview/components/MediaHandlerItemDelegate.qml</file>
<file>src/mainview/components/PluginHandlerItemDelegate.qml</file>
<file>src/commoncomponents/PreferenceItemDelegate.qml</file>
<file>src/settingsview/components/ContactItemDelegate.qml</file>
<file>src/settingsview/components/MediaCodecDelegate.qml</file>
......@@ -112,9 +112,9 @@
<file>src/mainview/js/callfullscreenwindowcontainercreation.js</file>
<file>src/mainview/components/VideoCallFullScreenWindowContainer.qml</file>
<file>src/mainview/components/ContactPicker.qml</file>
<file>src/mainview/components/MediaHandlerPicker.qml</file>
<file>src/mainview/components/PluginHandlerPicker.qml</file>
<file>src/mainview/js/contactpickercreation.js</file>
<file>src/mainview/js/mediahandlerpickercreation.js</file>
<file>src/mainview/js/pluginhandlerpickercreation.js</file>
<file>src/mainview/components/ContactPickerItemDelegate.qml</file>
<file>src/commoncomponents/AccountMigrationDialog.qml</file>
<file>src/commoncomponents/MaterialButton.qml</file>
......
......@@ -170,6 +170,8 @@ Item {
property int preferredDialogWidth: 400
property int preferredDialogHeight: 300
property int minimumPreviewWidth: 120
property int pluginHandlersPopupViewHeight: 200
property int pluginHandlersPopupViewDelegateHeight: 50
// main application spec
property int mainViewMinWidth: 460
......
......@@ -28,7 +28,7 @@ import net.jami.Adapters 1.0
import net.jami.Constants 1.0
import "../js/contactpickercreation.js" as ContactPickerCreation
import "../js/mediahandlerpickercreation.js" as MediaHandlerPickerCreation
import "../js/pluginhandlerpickercreation.js" as PluginHandlerPickerCreation
import "../../commoncomponents"
......@@ -73,8 +73,8 @@ Rectangle {
ContactPickerCreation.closeContactPicker()
}
function closePotentialMediaHandlerPicker() {
MediaHandlerPickerCreation.closeMediaHandlerPicker()
function closePotentialPluginHandlerPicker() {
PluginHandlerPickerCreation.closePluginHandlerPicker()
}
// returns true if participant is not fully maximized
......@@ -561,9 +561,9 @@ Rectangle {
}
onPluginItemClicked: {
// Create media handler picker - PLUGINS
MediaHandlerPickerCreation.createMediaHandlerPickerObjects(callOverlayRect)
MediaHandlerPickerCreation.openMediaHandlerPicker()
// Create plugin handler picker - PLUGINS
PluginHandlerPickerCreation.createPluginHandlerPickerObjects(callOverlayRect, true)
PluginHandlerPickerCreation.openPluginHandlerPicker()
}
}
}
......@@ -131,7 +131,7 @@ Item {
})
}
if (UtilsAdapter.checkShowPluginsButton()) {
if (UtilsAdapter.checkShowPluginsButton(true)) {
ContextMenuGenerator.addMenuItem(JamiStrings.viewPlugin,
"qrc:/images/icons/extension_24dp.svg",
function (){
......
/*
* Copyright (C) 2020 by Savoir-faire Linux
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
*
* 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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtQuick.Controls.Universal 2.14
import net.jami.Models 1.0
import net.jami.Adapters 1.0
import net.jami.Constants 1.0
import "../../commoncomponents"
Popup {
id: root
function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) {
var callId = UtilsAdapter.getCallId(callStackViewWindow.responsibleAccountId,
callStackViewWindow.responsibleConvUid)
PluginModel.toggleCallMediaHandler(mediaHandlerId, callId, !isLoaded)
mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel(callId)
}
width: 350
height: contentItem.height
modal: true
contentItem: StackLayout {
id: stack
currentIndex: 0
height: childrenRect.height
Rectangle {
id: mediahandlerPickerPopupRect
width: root.width
height: childrenRect.height + 50
color: JamiTheme.backgroundColor
radius: 10
PushButton {
id: closeButton
anchors.top: mediahandlerPickerPopupRect.top
anchors.topMargin: 5
anchors.right: mediahandlerPickerPopupRect.right
anchors.rightMargin: 5
source: "qrc:/images/icons/round-close-24px.svg"
imageColor: JamiTheme.textColor
onClicked: {
root.close()
}
}
ColumnLayout {
id: mediahandlerPickerPopupRectColumnLayout
anchors.top: mediahandlerPickerPopupRect.top
anchors.topMargin: 15
height: 230
Text {
id: mediahandlerPickerTitle
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: mediahandlerPickerPopupRect.width
Layout.preferredHeight: 30
font.pointSize: JamiTheme.textFontSize
font.bold: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: JamiTheme.textColor
text: qsTr("Choose plugin")
}
ListView {
id: mediahandlerPickerListView
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: mediahandlerPickerPopupRect.width
Layout.preferredHeight: 200
model: {
var callId = UtilsAdapter.getCallId(callStackViewWindow.responsibleAccountId,
callStackViewWindow.responsibleConvUid)
return PluginAdapter.getMediaHandlerSelectableModel(callId)
}
clip: true
delegate: MediaHandlerItemDelegate {
id: mediaHandlerItemDelegate
visible: PluginModel.getPluginsEnabled()
width: mediahandlerPickerListView.width
height: 50
mediaHandlerName : MediaHandlerName
mediaHandlerId: MediaHandlerId
mediaHandlerIcon: MediaHandlerIcon
isLoaded: IsLoaded
pluginId: PluginId
onBtnLoadMediaHandlerToggled: {
toggleMediaHandlerSlot(mediaHandlerId, isLoaded)
}
onOpenPreferences: {
mediahandlerPreferencePickerListView.pluginId = pluginId
mediahandlerPreferencePickerListView.mediaHandlerName = mediaHandlerName
mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediaHandlerName)
stack.currentIndex = 1
}
}
ScrollIndicator.vertical: ScrollIndicator {}
}
}
}
Rectangle {
id: mediahandlerPreferencePopupRect2
width: root.width
height: childrenRect.height + 50
color: JamiTheme.backgroundColor
radius: 10
PushButton {
id: backButton
anchors.top: mediahandlerPreferencePopupRect2.top
anchors.topMargin: 5
anchors.left: mediahandlerPreferencePopupRect2.left
anchors.leftMargin: 5
imageColor: JamiTheme.textColor
source: "qrc:/images/icons/ic_arrow_back_24px.svg"
toolTipText: qsTr("Go back to plugins list")
hoverEnabled: true
onClicked: {
stack.currentIndex = 0
}
}
PushButton {
id: closeButton2
anchors.top: mediahandlerPreferencePopupRect2.top
anchors.topMargin: 5
anchors.right: mediahandlerPreferencePopupRect2.right
anchors.rightMargin: 5
source: "qrc:/images/icons/round-close-24px.svg"
imageColor: JamiTheme.textColor
onClicked: {
stack.currentIndex = 0
root.close()
}
}
ColumnLayout {
anchors.top: mediahandlerPreferencePopupRect2.top
anchors.topMargin: 15
height: 230
Text {
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: mediahandlerPreferencePopupRect2.width
Layout.preferredHeight: 30
font.pointSize: JamiTheme.textFontSize
font.bold: true
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: JamiTheme.textColor
text: qsTr("Preferences")
}
ListView {
id: mediahandlerPreferencePickerListView
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: mediahandlerPickerPopupRect.width
Layout.preferredHeight: 200
property string pluginId: ""
property string mediaHandlerName: ""
model: PluginAdapter.getPluginPreferencesModel(pluginId, mediaHandlerName)
clip: true
delegate: PreferenceItemDelegate {
id: mediaHandlerPreferenceDelegate
width: mediahandlerPreferencePickerListView.width
height: childrenRect.height
preferenceName: PreferenceName
preferenceSummary: PreferenceSummary
preferenceType: PreferenceType
preferenceCurrentValue: PreferenceCurrentValue
pluginId: PluginId
currentPath: CurrentPath
preferenceKey : PreferenceKey
fileFilters: FileFilters
isImage: IsImage
pluginListPreferenceModel: PluginListPreferenceModel{
id: pluginListPreferenceModel
preferenceKey : PreferenceKey
pluginId: PluginId
}
onClicked: mediahandlerPreferencePickerListView.currentIndex = index
onBtnPreferenceClicked: {
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
}
}
ScrollIndicator.vertical: ScrollIndicator {}
}
}
}
}
onAboutToHide: stack.currentIndex = 0
onAboutToShow: {
// Reset the model on each show.
var callId = UtilsAdapter.getCallId(callStackViewWindow.responsibleAccountId,
callStackViewWindow.responsibleConvUid)
mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel(callId)
}
background: Rectangle {
color: "transparent"
}
}
......@@ -26,6 +26,7 @@ import net.jami.Adapters 1.0
import net.jami.Constants 1.0
import "../../commoncomponents"
import "../js/pluginhandlerpickercreation.js" as PluginHandlerPickerCreation
Rectangle {
id: messageWebViewRect
......@@ -136,6 +137,14 @@ Rectangle {
onNeedToHideConversationInCall: {
messageWebViewRect.needToHideConversationInCall()
}
onPluginSelector : {
// Create plugin handler picker - PLUGINS
PluginHandlerPickerCreation.createPluginHandlerPickerObjects(messageWebViewRect, false)
PluginHandlerPickerCreation.calculateCurrentGeo(
messageWebViewRect.width / 2, messageWebViewRect.height / 2)
PluginHandlerPickerCreation.openPluginHandlerPicker()
}
}
QtObject {
......
......@@ -21,6 +21,7 @@ import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import net.jami.Models 1.0
import net.jami.Constants 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents"
......@@ -34,6 +35,7 @@ Rectangle {
signal backClicked
signal needToHideConversationInCall
signal pluginSelector
function resetBackToWelcomeViewButtonSource(reset) {
backToWelcomeViewButtonSource = reset ? "qrc:/images/icons/ic_arrow_back_24px.svg" : "qrc:/images/icons/round-close-24px.svg"
......@@ -42,6 +44,7 @@ Rectangle {
function toggleMessagingHeaderButtonsVisible(visible) {
startAAudioCallButton.visible = visible
startAVideoCallButton.visible = visible
selectPluginButton.visible = visible
}
color: JamiTheme.secondaryBackgroundColor
......@@ -155,7 +158,8 @@ Rectangle {
PushButton {
id: startAVideoCallButton
anchors.right: sendContactRequestButton.visible ?
anchors.right: selectPluginButton.visible ? selectPluginButton.left :
sendContactRequestButton.visible ?
sendContactRequestButton.left :
buttonGroup.right
anchors.rightMargin: 16
......@@ -173,6 +177,32 @@ Rectangle {
}
}
PushButton {
id: selectPluginButton
visible: UtilsAdapter.checkShowPluginsButton(false)
Connections {
target: PluginAdapter
function onPluginHandlersUpdateStatus() {
selectPluginButton.visible = UtilsAdapter.checkShowPluginsButton(false)
}
}
anchors.right: sendContactRequestButton.visible ?
sendContactRequestButton.left :
buttonGroup.right
anchors.rightMargin: 16
anchors.verticalCenter: buttonGroup.verticalCenter
source: "qrc:/images/icons/extension_24dp.svg"
normalColor: JamiTheme.secondaryBackgroundColor
imageColor: JamiTheme.chatviewButtonColor
onClicked: pluginSelector()
}
PushButton {
id: sendContactRequestButton
......
......@@ -30,13 +30,13 @@ import "../../commoncomponents"
ItemDelegate {
id: root
property string mediaHandlerName : ""
property string mediaHandlerId: ""
property string mediaHandlerIcon: ""
property string handlerName : ""
property string handlerId: ""
property string handlerIcon: ""
property bool isLoaded: false
property string pluginId: ""
signal btnLoadMediaHandlerToggled
signal btnLoadHandlerToggled
signal openPreferences
RowLayout{
......@@ -52,7 +52,7 @@ ItemDelegate {
color: "transparent"
Image {
anchors.centerIn: parent
source: "file:" + mediaHandlerIcon
source: "file:" + handlerIcon
width: 30
height: 30
mipmap: true
......@@ -69,7 +69,7 @@ ItemDelegate {
font.pointSize: JamiTheme.settingsFontSize
font.kerning: true
text: mediaHandlerName === "" ? mediaHandlerId : mediaHandlerName
text: handlerName === "" ? handlerId : handlerName
}
Switch {
......@@ -89,7 +89,7 @@ ItemDelegate {
checked: isLoaded
onClicked: {
btnLoadMediaHandlerToggled()
btnLoadHandlerToggled()
}
background: Rectangle {
......@@ -116,7 +116,7 @@ ItemDelegate {
}
PushButton {
id: btnPreferencesMediaHandler
id: btnPreferencesPluginHandler
Layout.alignment: Qt.AlingVCenter | Qt.AlignRight
Layout.rightMargin: 8
......
/*
* Copyright (C) 2021 by Savoir-faire Linux
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
*
* 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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtQuick.Controls.Universal 2.14
import net.jami.Models 1.0
import net.jami.Adapters 1.0
import net.jami.Constants 1.0
import "../../commoncomponents"
Popup {
id: root
property bool isCall
property string pluginId: ""
property string handlerName: ""
signal updateProperties
width: JamiTheme.preferredDialogWidth
height: JamiTheme.pluginHandlersPopupViewHeight + JamiTheme.pluginHandlersPopupViewDelegateHeight
modal: true
contentItem: StackView {
id: stack
initialItem: pluginhandlerPreferenceStack
anchors.fill: parent
}
Component {
id: pluginhandlerPreferenceStack
Rectangle {
color: JamiTheme.backgroundColor
radius: 10
anchors.fill: parent
Connections {
target: root
function onAboutToShow(visible) {
if (isCall) {
// Reset the model on each show.
var callId = UtilsAdapter.getCallId(callStackViewWindow.responsibleAccountId,
callStackViewWindow.responsibleConvUid)
pluginhandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel(callId)
} else {
// Reset the model on each show.
var accountId = AccountAdapter.currentAccountId
var peerId = UtilsAdapter.getPeerUri(accountId, UtilsAdapter.getCurrConvId())
pluginhandlerPickerListView.model = PluginAdapter.getChatHandlerSelectableModel(accountId, peerId)
}
}
}
function toggleHandlerSlot(handlerId, isLoaded) {
if (isCall) {
var callId = UtilsAdapter.getCallId(callStackViewWindow.responsibleAccountId,
callStackViewWindow.responsibleConvUid)
PluginModel.toggleCallMediaHandler(handlerId, callId, !isLoaded)
pluginhandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel(callId)
} else {
var accountId = AccountAdapter.currentAccountId
var peerId = UtilsAdapter.getPeerUri(accountId, UtilsAdapter.getCurrConvId())
PluginModel.toggleChatHandler(handlerId, accountId, peerId, !isLoaded)
pluginhandlerPickerListView.model = PluginAdapter.getChatHandlerSelectableModel(accountId, peerId)
}
}
ColumnLayout {
anchors.fill: parent
anchors.bottomMargin: 5
RowLayout {