File indexing completed on 2024-06-09 04:58:54
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "conferencecallsettingswidget.h" 0008 #include "connection.h" 0009 #include "rocketchataccount.h" 0010 #include "ruqolawidgets_debug.h" 0011 #include "video-conference/videoconferenceprovidersjob.h" 0012 #include <KLocalizedString> 0013 #include <QComboBox> 0014 #include <QFormLayout> 0015 #include <QJsonArray> 0016 0017 ConferenceCallSettingsWidget::ConferenceCallSettingsWidget(RocketChatAccount *account, QWidget *parent) 0018 : SettingsWidgetBase{account, parent} 0019 , mDefaultProvider(new QComboBox(this)) 0020 { 0021 mDefaultProvider->setObjectName(QStringLiteral("mDefaultProvider")); 0022 addComboBox(i18n("Default Provider"), {}, mDefaultProvider, QStringLiteral("VideoConf_Default_Provider")); 0023 } 0024 0025 ConferenceCallSettingsWidget::~ConferenceCallSettingsWidget() = default; 0026 0027 void ConferenceCallSettingsWidget::initialize(const QMap<QString, QVariant> &mapSettings) 0028 { 0029 auto job = new RocketChatRestApi::VideoConferenceProvidersJob(this); 0030 mAccount->restApi()->initializeRestApiJob(job); 0031 connect(job, &RocketChatRestApi::VideoConferenceProvidersJob::videoConferenceProvidersDone, this, [this, mapSettings](const QJsonObject &obj) { 0032 // {"data":[{"key":"jitsi","label":"Jitsi"}],"success":true} 0033 QMap<QString, QString> maps; 0034 const QJsonArray array = obj[QLatin1String("data")].toArray(); 0035 for (const QJsonValue ¤t : array) { 0036 const QJsonObject roleObject = current.toObject(); 0037 maps.insert(roleObject[QLatin1String("key")].toString(), roleObject[QLatin1String("label")].toString()); 0038 } 0039 // qDebug() << " list " << obj << " maps " << maps; 0040 fillComboBox(mDefaultProvider, maps); 0041 initializeWidget(mDefaultProvider, mapSettings, QString()); 0042 }); 0043 if (!job->start()) { 0044 qCWarning(RUQOLAWIDGETS_LOG) << "Impossible to start VideoConferenceProvidersJob job"; 0045 } 0046 } 0047 0048 #include "moc_conferencecallsettingswidget.cpp"