Commit 95473668 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(SettingsAdvanced): send logs in progress

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