Commit d90a252c authored by Wescoeur's avatar Wescoeur

feat(SettingsAdvanced): supports all logs features

parent 95473668
......@@ -997,6 +997,10 @@ your friend&apos;s SIP address or username.</translation>
<source>cleanLogs</source>
<translation>CLEAN LOGS</translation>
</message>
<message>
<source>cleanLogsDescription</source>
<translation>Are you sure you want to remove all logs?</translation>
</message>
</context>
<context>
<name>SettingsAudio</name>
......
......@@ -985,7 +985,7 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
</message>
<message>
<source>logsUploadFailed</source>
<translation>L&apos;envoi des logs a échoué.&gt;</translation>
<translation>L&apos;envoi des logs a échoué.</translation>
</message>
<message>
<source>logsEnabledLabel</source>
......@@ -995,6 +995,10 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>cleanLogs</source>
<translation>SUPPRIMER LOGS</translation>
</message>
<message>
<source>cleanLogsDescription</source>
<translation>Voulez-vous vraiment supprimer tous les logs ?</translation>
</message>
</context>
<context>
<name>SettingsAudio</name>
......
......@@ -296,6 +296,8 @@
<file>ui/modules/Common/Window/VirtualWindow.qml</file>
<file>ui/modules/Common/Window/Window.js</file>
<file>ui/modules/Common/Window/Window.qml</file>
<file>ui/modules/Konami/Konami.qml</file>
<file>ui/modules/Konami/qmldir</file>
<file>ui/modules/Linphone/Account/AccountStatus.qml</file>
<file>ui/modules/Linphone/Blocks/CardBlock.qml</file>
<file>ui/modules/Linphone/Blocks/RequestBlock.qml</file>
......@@ -403,6 +405,7 @@
<file>ui/views/App/Main/MainWindow.js</file>
<file>ui/views/App/Main/MainWindowMenuBar.qml</file>
<file>ui/views/App/Main/MainWindow.qml</file>
<file>ui/views/App/Settings/SettingsAdvanced.js</file>
<file>ui/views/App/Settings/SettingsAdvanced.qml</file>
<file>ui/views/App/Settings/SettingsAudio.qml</file>
<file>ui/views/App/Settings/SettingsCallsChat.qml</file>
......@@ -441,6 +444,7 @@
<file>ui/views/App/Styles/Main/InviteFriendsStyle.qml</file>
<file>ui/views/App/Styles/Main/MainWindowStyle.qml</file>
<file>ui/views/App/Styles/qmldir</file>
<file>ui/views/App/Styles/Settings/SettingsAdvancedStyle.qml</file>
<file>ui/views/App/Styles/Settings/SettingsAudioStyle.qml</file>
<file>ui/views/App/Styles/Settings/SettingsSipAccountsEditStyle.qml</file>
<file>ui/views/App/Styles/Settings/SettingsVideoPreviewStyle.qml</file>
......
......@@ -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), SettingsModel::getLogsEnabled(config));
Logger::init(config);
if (mParser->isSet("verbose"))
Logger::getInstance()->setVerbose(true);
......
......@@ -25,6 +25,7 @@
#include <QDateTime>
#include <QThread>
#include "../../components/settings/SettingsModel.hpp"
#include "../../utils/Utils.hpp"
#include "../paths/Paths.hpp"
......@@ -159,11 +160,13 @@ 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());
void Logger::init (const std::shared_ptr<linphone::Config> &config) {
if (mInstance)
return;
const QString folder = SettingsModel::getLogsFolder(config);
Q_ASSERT(!folder.isEmpty());
mInstance = new Logger();
qInstallMessageHandler(Logger::log);
......@@ -177,5 +180,5 @@ void Logger::init (const QString &folder, bool enabled) {
linphone_core_set_log_collection_path(::Utils::appStringToCoreString(folder).c_str());
linphone_core_set_log_collection_max_file_size(MAX_LOGS_COLLECTION_SIZE);
mInstance->enable(enabled);
mInstance->enable(SettingsModel::getLogsEnabled(config));
}
......@@ -23,6 +23,7 @@
#ifndef LOGGER_H_
#define LOGGER_H_
#include <linphone++/linphone.hh>
#include <QMutex>
// =============================================================================
......@@ -41,7 +42,7 @@ public:
void enable (bool status);
static void init (const QString &folder, bool enabled);
static void init (const std::shared_ptr<linphone::Config> &config);
static Logger *getInstance () {
return mInstance;
......
......@@ -69,11 +69,10 @@ void CoreHandlers::handleCoreCreated () {
void CoreHandlers::notifyCoreStarted () {
if (mCoreCreated && mCoreStarted)
scheduleFunctionInApp(
[this]() {
qInfo() << QStringLiteral("Core started.");
emit coreStarted();
});
scheduleFunctionInApp([this] {
qInfo() << QStringLiteral("Core started.");
emit coreStarted();
});
}
// -----------------------------------------------------------------------------
......@@ -125,9 +124,9 @@ void CoreHandlers::onGlobalStateChanged (
void CoreHandlers::onLogCollectionUploadStateChanged (
const shared_ptr<linphone::Core> &,
linphone::CoreLogCollectionUploadState state,
const string &
const string &info
) {
emit logsUploadStateChanged(state);
emit logsUploadStateChanged(state, info);
}
void CoreHandlers::onLogCollectionUploadProgressIndication (
......
......@@ -46,7 +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 logsUploadStateChanged (linphone::CoreLogCollectionUploadState state, const std::string &info);
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);
......
......@@ -107,6 +107,8 @@ void CoreManager::forceRefreshRegisters () {
mCore->refreshRegisters();
}
// -----------------------------------------------------------------------------
void CoreManager::sendLogs () const {
Q_CHECK_PTR(mCore);
......@@ -115,6 +117,12 @@ void CoreManager::sendLogs () const {
mCore->uploadLogCollection();
}
void CoreManager::cleanLogs () const {
Q_CHECK_PTR(mCore);
mCore->resetLogCollection();
}
// -----------------------------------------------------------------------------
#define SET_DATABASE_PATH(DATABASE, PATH) \
......@@ -198,15 +206,14 @@ void CoreManager::iterate () {
// -----------------------------------------------------------------------------
void CoreManager::handleLogsUploadStateChanged (linphone::CoreLogCollectionUploadState state) {
void CoreManager::handleLogsUploadStateChanged (linphone::CoreLogCollectionUploadState state, const string &info) {
switch (state) {
case linphone::CoreLogCollectionUploadStateInProgress:
break;
case linphone::CoreLogCollectionUploadStateDelivered:
emit logsUploaded(true);
break;
case linphone::CoreLogCollectionUploadStateNotDelivered:
emit logsUploaded(false);
emit logsUploaded(::Utils::coreStringToAppString(info));
break;
}
}
......
......@@ -120,12 +120,13 @@ public:
Q_INVOKABLE void forceRefreshRegisters ();
Q_INVOKABLE void sendLogs () const;
Q_INVOKABLE void cleanLogs () const;
signals:
void coreCreated ();
void coreStarted ();
void logsUploaded (bool success);
void logsUploaded (const QString &url);
private:
CoreManager (QObject *parent, const QString &configPath);
......@@ -140,7 +141,7 @@ private:
void iterate ();
void handleLogsUploadStateChanged (linphone::CoreLogCollectionUploadState state);
void handleLogsUploadStateChanged (linphone::CoreLogCollectionUploadState state, const std::string &info);
static QString getDownloadUrl ();
......
......@@ -20,7 +20,6 @@
* Author: Ronan Abhamon
*/
#include <linphone++/linphone.hh>
#include <QMetaProperty>
#include "../../../utils/Utils.hpp"
......@@ -29,10 +28,6 @@
#define COLORS_SECTION "ui_colors"
#ifndef LINPHONE_FRIDAY
#define LINPHONE_FRIDAY 1
#endif // ifndef LINPHONE_FRIDAY
#if LINPHONE_FRIDAY
#include <QDate>
#endif // if LINPHONE_FRIDAY
......@@ -43,24 +38,29 @@ using namespace std;
#if LINPHONE_FRIDAY
static void setLinphoneFridayColors (Colors &colors) {
colors.setProperty("i", QColor("#F48D8D"));
colors.setProperty("s", QColor("#F58585"));
colors.setProperty("t", QColor("#FFC5C5"));
inline bool isLinphoneFriday () {
return QDate::currentDate().dayOfWeek() == 5;
}
#endif // if LINPHONE_FRIDAY
Colors::Colors (QObject *parent) : QObject(parent) {
#if LINPHONE_FRIDAY
if (QDate::currentDate().dayOfWeek() == 5)
::setLinphoneFridayColors(*this);
if (isLinphoneFriday()) {
setProperty("i", QColor("#F48D8D"));
setProperty("s", QColor("#F58585"));
setProperty("t", QColor("#FFC5C5"));
}
#endif // if LINPHONE_FRIDAY
}
void Colors::useConfig (const std::shared_ptr<linphone::Config> &config) {
overrideColors(config);
#if LINPHONE_FRIDAY
if (!isLinphoneFriday())
overrideColors(config);
#else
overrideColors(config);
#endif // if LINPHONE_FRIDAY
}
// -----------------------------------------------------------------------------
......
......@@ -23,6 +23,7 @@
#ifndef COLORS_H_
#define COLORS_H_
#include <linphone++/linphone.hh>
#include <QColor>
#include <QObject>
......@@ -48,7 +49,7 @@
// -----------------------------------------------------------------------------
namespace linphone {
class Config;
class Config;
}
class Colors : public QObject {
......
/*
* Konami.qml
* Copyright 2017 Ronan Abhamon (https://github.com/Wescoeur)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import QtQuick 2.7
// =============================================================================
Item {
id: konami
property var code: [
Qt.Key_Up,
Qt.Key_Up,
Qt.Key_Down,
Qt.Key_Down,
Qt.Key_Left,
Qt.Key_Right,
Qt.Key_Left,
Qt.Key_Right,
Qt.Key_B,
Qt.Key_A
]
property int delay: 2000
signal triggered
// ---------------------------------------------------------------------------
Keys.forwardTo: core
Timer {
id: timer
interval: konami.delay
onTriggered: core.index = 0
}
Item {
id: core
property int index: 0
anchors.fill: parent
Keys.onPressed: {
timer.stop()
var code = konami.code
if (event.key === code[index]) {
// 1. Code OK.
if (++index === code.length) {
index = 0
konami.triggered()
return
}
// 2. Actual key OK.
if (delay > 0) {
timer.start()
}
return
}
// 3. Wrong key.
index = 0
}
}
}
module Konami
// =============================================================================
Konami 1.0 Konami.qml
......@@ -2,6 +2,7 @@ import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common 1.0
import Konami 1.0
import Linphone 1.0
import App.Styles 1.0
......@@ -40,6 +41,16 @@ DialogPlus {
Icon {
icon: 'linphone_logo'
iconSize: parent.height
Konami {
anchors.fill: parent
onTriggered: console.log('TODO')
MouseArea {
anchors.fill: parent
onClicked: parent.focus = true
}
}
}
Column {
......
// =============================================================================
// `SettingsAdvanced.qml` Logic.
// =============================================================================
.import Linphone 1.0 as Linphone
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
// =============================================================================
function cleanLogs () {
window.attachVirtualWindow(Utils.buildDialogUri('ConfirmDialog'), {
descriptionText: qsTr('cleanLogsDescription'),
}, function (status) {
if (status) {
Linphone.CoreManager.cleanLogs()
}
})
}
function handleLogsUploaded (url) {
if (url.length) {
sendLogsBlock.stop('')
Qt.openUrlExternally(
'mailto:?subject=' + encodeURIComponent('Desktop Linphone Log') +
'&body=' + encodeURIComponent(url)
)
} else {
sendLogsBlock.stop(qsTr('logsUploadFailed'))
}
}
......@@ -5,6 +5,8 @@ import Linphone 1.0
import App.Styles 1.0
import 'SettingsAdvanced.js' as Logic
// =============================================================================
TabContainer {
......@@ -63,12 +65,12 @@ TabContainer {
Row {
anchors.right: parent.right
spacing: 5
spacing: SettingsAdvancedStyle.buttons.spacing
TextButtonB {
text: qsTr('cleanLogs')
onClicked: CoreManager.cleanLogs()
onClicked: Logic.cleanLogs()
}
TextButtonB {
......@@ -88,7 +90,7 @@ TabContainer {
Connections {
target: CoreManager
onLogsUploaded: sendLogsBlock.stop(success ? '' : qsTr('logsUploadFailed'))
onLogsUploaded: Logic.handleLogsUploaded(url)
}
}
......
pragma Singleton
import QtQml 2.2
// =============================================================================
QtObject {
property QtObject buttons: QtObject {
property int spacing: 10
}
}
......@@ -31,6 +31,7 @@ singleton AboutStyle 1.0 Main/Dialogs/AboutS
singleton AuthenticationRequestStyle 1.0 Main/Dialogs/AuthenticationRequestStyle.qml
singleton ManageAccountsStyle 1.0 Main/Dialogs/ManageAccountsStyle.qml
singleton SettingsAdvancedStyle 1.0 Settings/SettingsAdvancedStyle.qml
singleton SettingsAudioStyle 1.0 Settings/SettingsAudioStyle.qml
singleton SettingsSipAccountsEditStyle 1.0 Settings/SettingsSipAccountsEditStyle.qml
singleton SettingsVideoPreviewStyle 1.0 Settings/SettingsVideoPreviewStyle.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