mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(SettingsAdvanced): send logs in progress
This commit is contained in:
parent
830b95e859
commit
9547366891
12 changed files with 162 additions and 16 deletions
|
|
@ -985,6 +985,18 @@ your friend's SIP address or username.</translation>
|
|||
<source>logsUploadUrlLabel</source>
|
||||
<translation>Logs upload server url</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>logsUploadFailed</source>
|
||||
<translation>Failed to upload logs.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>logsEnabledLabel</source>
|
||||
<translation>Logs enabled</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>cleanLogs</source>
|
||||
<translation>CLEAN LOGS</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsAudio</name>
|
||||
|
|
|
|||
|
|
@ -983,6 +983,18 @@ Cliquez ici : <a href="%1">%1</a>
|
|||
<source>logsUploadUrlLabel</source>
|
||||
<translation>Url du serveur de logs</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>logsUploadFailed</source>
|
||||
<translation>L'envoi des logs a échoué.></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>logsEnabledLabel</source>
|
||||
<translation>Logs activés.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>cleanLogs</source>
|
||||
<translation>SUPPRIMER LOGS</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsAudio</name>
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U
|
|||
|
||||
// Initialize logger.
|
||||
shared_ptr<linphone::Config> config = ::getConfigIfExists(*mParser);
|
||||
Logger::init(SettingsModel::getLogsFolder(config));
|
||||
Logger::init(SettingsModel::getLogsFolder(config), SettingsModel::getLogsEnabled(config));
|
||||
if (mParser->isSet("verbose"))
|
||||
Logger::getInstance()->setVerbose(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,11 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Logger::init (const QString &folder) {
|
||||
void Logger::enable (bool status) {
|
||||
linphone_core_enable_log_collection(status ? LinphoneLogCollectionEnabled : LinphoneLogCollectionDisabled);
|
||||
}
|
||||
|
||||
void Logger::init (const QString &folder, bool enabled) {
|
||||
Q_ASSERT(!folder.isEmpty());
|
||||
|
||||
if (mInstance)
|
||||
|
|
@ -173,5 +177,5 @@ void Logger::init (const QString &folder) {
|
|||
linphone_core_set_log_collection_path(::Utils::appStringToCoreString(folder).c_str());
|
||||
|
||||
linphone_core_set_log_collection_max_file_size(MAX_LOGS_COLLECTION_SIZE);
|
||||
linphone_core_enable_log_collection(LinphoneLogCollectionEnabled);
|
||||
mInstance->enable(enabled);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ public:
|
|||
mVerbose = verbose;
|
||||
}
|
||||
|
||||
static void init (const QString &folder);
|
||||
void enable (bool status);
|
||||
|
||||
static void init (const QString &folder, bool enabled);
|
||||
|
||||
static Logger *getInstance () {
|
||||
return mInstance;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,14 @@ void CoreHandlers::onCallStateChanged (
|
|||
App::getInstance()->getNotifier()->notifyReceivedCall(call);
|
||||
}
|
||||
|
||||
void CoreHandlers::onCallStatsUpdated (
|
||||
const shared_ptr<linphone::Core> &,
|
||||
const shared_ptr<linphone::Call> &call,
|
||||
const shared_ptr<const linphone::CallStats> &stats
|
||||
) {
|
||||
call->getData<CallModel>("call-model").updateStats(stats);
|
||||
}
|
||||
|
||||
void CoreHandlers::onGlobalStateChanged (
|
||||
const shared_ptr<linphone::Core> &,
|
||||
linphone::GlobalState gstate,
|
||||
|
|
@ -114,12 +122,20 @@ void CoreHandlers::onGlobalStateChanged (
|
|||
}
|
||||
}
|
||||
|
||||
void CoreHandlers::onCallStatsUpdated (
|
||||
void CoreHandlers::onLogCollectionUploadStateChanged (
|
||||
const shared_ptr<linphone::Core> &,
|
||||
const shared_ptr<linphone::Call> &call,
|
||||
const shared_ptr<const linphone::CallStats> &stats
|
||||
linphone::CoreLogCollectionUploadState state,
|
||||
const string &
|
||||
) {
|
||||
call->getData<CallModel>("call-model").updateStats(stats);
|
||||
emit logsUploadStateChanged(state);
|
||||
}
|
||||
|
||||
void CoreHandlers::onLogCollectionUploadProgressIndication (
|
||||
const shared_ptr<linphone::Core> &,
|
||||
size_t,
|
||||
size_t
|
||||
) {
|
||||
// TODO;
|
||||
}
|
||||
|
||||
void CoreHandlers::onMessageReceived (
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ signals:
|
|||
void callTransferFailed (const std::shared_ptr<linphone::Call> &call);
|
||||
void callTransferSucceeded (const std::shared_ptr<linphone::Call> &call);
|
||||
void coreStarted ();
|
||||
void logsUploadStateChanged (linphone::CoreLogCollectionUploadState state);
|
||||
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
|
||||
void registrationStateChanged (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, linphone::RegistrationState state);
|
||||
|
|
@ -71,16 +72,28 @@ private:
|
|||
const std::string &message
|
||||
) override;
|
||||
|
||||
void onCallStatsUpdated (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
const std::shared_ptr<const linphone::CallStats> &stats
|
||||
) override;
|
||||
|
||||
void onGlobalStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
linphone::GlobalState gstate,
|
||||
const std::string &message
|
||||
) override;
|
||||
|
||||
void onCallStatsUpdated (
|
||||
void onLogCollectionUploadStateChanged (
|
||||
const std::shared_ptr<linphone::Core> &core,
|
||||
const std::shared_ptr<linphone::Call> &call,
|
||||
const std::shared_ptr<const linphone::CallStats> &stats
|
||||
linphone::CoreLogCollectionUploadState state,
|
||||
const std::string &info
|
||||
) override;
|
||||
|
||||
void onLogCollectionUploadProgressIndication (
|
||||
const std::shared_ptr<linphone::Core> &lc,
|
||||
size_t offset,
|
||||
size_t total
|
||||
) override;
|
||||
|
||||
void onMessageReceived (
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ using namespace std;
|
|||
|
||||
CoreManager *CoreManager::mInstance = nullptr;
|
||||
|
||||
CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(parent), mHandlers(make_shared<CoreHandlers>(this)) {
|
||||
CoreManager::CoreManager (QObject *parent, const QString &configPath) :
|
||||
QObject(parent), mHandlers(make_shared<CoreHandlers>(this)) {
|
||||
mPromiseBuild = QtConcurrent::run(this, &CoreManager::createLinphoneCore, configPath);
|
||||
|
||||
QObject::connect(&mPromiseWatcher, &QFutureWatcher<void>::finished, this, [] {
|
||||
|
|
@ -50,7 +51,9 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(
|
|||
emit mInstance->coreCreated();
|
||||
});
|
||||
|
||||
QObject::connect(mHandlers.get(), &CoreHandlers::coreStarted, this, [] {
|
||||
CoreHandlers *coreHandlers = mHandlers.get();
|
||||
|
||||
QObject::connect(coreHandlers, &CoreHandlers::coreStarted, this, [] {
|
||||
mInstance->mCallsListModel = new CallsListModel(mInstance);
|
||||
mInstance->mContactsListModel = new ContactsListModel(mInstance);
|
||||
mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
|
||||
|
|
@ -60,6 +63,11 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(
|
|||
emit mInstance->coreStarted();
|
||||
});
|
||||
|
||||
QObject::connect(
|
||||
coreHandlers, &CoreHandlers::logsUploadStateChanged,
|
||||
this, &CoreManager::handleLogsUploadStateChanged
|
||||
);
|
||||
|
||||
mPromiseWatcher.setFuture(mPromiseBuild);
|
||||
}
|
||||
|
||||
|
|
@ -190,6 +198,21 @@ void CoreManager::iterate () {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CoreManager::handleLogsUploadStateChanged (linphone::CoreLogCollectionUploadState state) {
|
||||
switch (state) {
|
||||
case linphone::CoreLogCollectionUploadStateInProgress:
|
||||
break;
|
||||
case linphone::CoreLogCollectionUploadStateDelivered:
|
||||
emit logsUploaded(true);
|
||||
break;
|
||||
case linphone::CoreLogCollectionUploadStateNotDelivered:
|
||||
emit logsUploaded(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CoreManager::getDownloadUrl () {
|
||||
return QStringLiteral(DOWNLOAD_URL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ signals:
|
|||
void coreCreated ();
|
||||
void coreStarted ();
|
||||
|
||||
void logsUploaded (bool success);
|
||||
|
||||
private:
|
||||
CoreManager (QObject *parent, const QString &configPath);
|
||||
|
||||
|
|
@ -138,6 +140,8 @@ private:
|
|||
|
||||
void iterate ();
|
||||
|
||||
void handleLogsUploadStateChanged (linphone::CoreLogCollectionUploadState state);
|
||||
|
||||
static QString getDownloadUrl ();
|
||||
|
||||
std::shared_ptr<linphone::Core> mCore;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <QDir>
|
||||
|
||||
#include "../../app/logger/Logger.hpp"
|
||||
#include "../../app/paths/Paths.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
|
|
@ -746,8 +747,24 @@ void SettingsModel::setLogsUploadUrl (const QString &url) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getLogsEnabled () const {
|
||||
return getLogsEnabled(mConfig);
|
||||
}
|
||||
|
||||
void SettingsModel::setLogsEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "logs_enabled", status);
|
||||
Logger::getInstance()->enable(status);
|
||||
emit logsEnabledChanged(status);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QString SettingsModel::getLogsFolder (const shared_ptr<linphone::Config> &config) {
|
||||
return ::Utils::coreStringToAppString(
|
||||
config->getString(UI_SECTION, "logs_folder", Paths::getLogsDirPath())
|
||||
);
|
||||
}
|
||||
|
||||
bool SettingsModel::getLogsEnabled (const std::shared_ptr<linphone::Config> &config) {
|
||||
return config->getInt(UI_SECTION, "logs_enabled", false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ class SettingsModel : public QObject {
|
|||
|
||||
Q_PROPERTY(QString logsFolder READ getLogsFolder WRITE setLogsFolder NOTIFY logsFolderChanged);
|
||||
Q_PROPERTY(QString logsUploadUrl READ getLogsUploadUrl WRITE setLogsUploadUrl NOTIFY logsUploadUrlChanged);
|
||||
Q_PROPERTY(bool logsEnabled READ getLogsEnabled WRITE setLogsEnabled NOTIFY logsEnabledChanged);
|
||||
|
||||
public:
|
||||
enum MediaEncryption {
|
||||
|
|
@ -291,9 +292,13 @@ public:
|
|||
QString getLogsUploadUrl () const;
|
||||
void setLogsUploadUrl (const QString &url);
|
||||
|
||||
bool getLogsEnabled () const;
|
||||
void setLogsEnabled (bool status);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static QString getLogsFolder (const std::shared_ptr<linphone::Config> &config);
|
||||
static bool getLogsEnabled (const std::shared_ptr<linphone::Config> &config);
|
||||
|
||||
static const std::string UI_SECTION;
|
||||
|
||||
|
|
@ -376,6 +381,7 @@ signals:
|
|||
|
||||
void logsFolderChanged (const QString &folder);
|
||||
void logsUploadUrlChanged (const QString &url);
|
||||
void logsEnabledChanged (bool status);
|
||||
|
||||
private:
|
||||
std::shared_ptr<linphone::Config> mConfig;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ TabContainer {
|
|||
label: qsTr('logsUploadUrlLabel')
|
||||
|
||||
TextField {
|
||||
readOnly: true
|
||||
text: SettingsModel.logsUploadUrl
|
||||
|
||||
onEditingFinished: SettingsModel.logsUploadUrl = text
|
||||
|
|
@ -45,14 +46,50 @@ TabContainer {
|
|||
}
|
||||
}
|
||||
|
||||
FormLine {
|
||||
FormGroup {
|
||||
label: qsTr('logsEnabledLabel')
|
||||
|
||||
Switch {
|
||||
checked: SettingsModel.logsEnabled
|
||||
|
||||
onClicked: SettingsModel.logsEnabled = !checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormEmptyLine {}
|
||||
}
|
||||
|
||||
TextButtonB {
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
text: qsTr('sendLogs')
|
||||
spacing: 5
|
||||
|
||||
onClicked: CoreManager.sendLogs()
|
||||
TextButtonB {
|
||||
text: qsTr('cleanLogs')
|
||||
|
||||
onClicked: CoreManager.cleanLogs()
|
||||
}
|
||||
|
||||
TextButtonB {
|
||||
enabled: !sendLogsBlock.loading
|
||||
text: qsTr('sendLogs')
|
||||
|
||||
onClicked: sendLogsBlock.execute()
|
||||
}
|
||||
}
|
||||
|
||||
RequestBlock {
|
||||
id: sendLogsBlock
|
||||
|
||||
action: CoreManager.sendLogs
|
||||
width: parent.width
|
||||
|
||||
Connections {
|
||||
target: CoreManager
|
||||
|
||||
onLogsUploaded: sendLogsBlock.stop(success ? '' : qsTr('logsUploadFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue