Commit 04035b25 authored by David Edmundson's avatar David Edmundson Committed by Aleix Pol Gonzalez
Browse files

[shell] Split UserFeedback out of ShellCorona

ShellCorona is a messy class doing mulitple functions.

This patch splits out all telemetry code into a new class, meaning it's
easier to extend. Code remains the same.
parent a3f22cde
......@@ -43,9 +43,17 @@ set (plasma_shell_SRCS
${scripting_SRC}
)
if (TARGET KUserFeedbackCore)
set(plasma_shell_SRCS
${plasma_shell_SRCS}
userfeedback.cpp
)
endif()
set(krunner_xml ${plasma-workspace_SOURCE_DIR}/krunner/dbus/org.kde.krunner.App.xml)
qt5_add_dbus_interface(plasma_shell_SRCS ${krunner_xml} krunner_interface)
add_executable(plasmashell
${plasma_shell_SRCS}
)
......
......@@ -31,8 +31,9 @@
#include <KAboutData>
#include <KQuickAddons/QtQuickSettings>
#ifdef WITH_KUSERFEEDBACKCORE
#include <KUserFeedback/Provider>
#include "userfeedback.h"
#endif
#include <kdbusservice.h>
......@@ -165,8 +166,9 @@ int main(int argc, char *argv[])
corona->setShell(cliOptions.value(shellPluginOption));
#ifdef WITH_KUSERFEEDBACKCORE
auto userFeedback = new UserFeedback(corona, &app);
if (cliOptions.isSet(feedbackOption)) {
QTextStream(stdout) << corona->feedbackProvider()->describeDataSources();
QTextStream(stdout) << userFeedback->describeDataSources();
return 0;
}
#endif
......
......@@ -53,19 +53,6 @@
#include <KMessageBox>
#include <kdirwatch.h>
#ifdef WITH_KUSERFEEDBACKCORE
#include <KUserFeedback/Provider>
#include <KUserFeedback/ApplicationVersionSource>
#include <KUserFeedback/CompilerInfoSource>
#include <KUserFeedback/PlatformInfoSource>
#include <KUserFeedback/QtVersionSource>
#include <KUserFeedback/UsageTimeSource>
#include <KUserFeedback/OpenGLInfoSource>
#include <KUserFeedback/ScreenInfoSource>
#include "panelcountsource.h"
#endif
#include <KPackage/PackageLoader>
#include <KWayland/Client/connection_thread.h>
......@@ -110,9 +97,6 @@ ShellCorona::ShellCorona(QObject *parent)
m_waylandPlasmaShell(nullptr),
m_closingDown(false),
m_strutManager(new StrutManager(this))
#ifdef WITH_KUSERFEEDBACKCORE
, m_feedbackProvider(new KUserFeedback::Provider(this))
#endif
{
setupWaylandIntegration();
qmlRegisterUncreatableType<DesktopView>("org.kde.plasma.shell", 2, 0, "Desktop", QStringLiteral("It is not possible to create objects of type Desktop"));
......@@ -321,26 +305,7 @@ void ShellCorona::setShell(const QString &shell)
}
#ifdef WITH_KUSERFEEDBACKCORE
m_feedbackProvider->setProductIdentifier(QStringLiteral("org.kde.plasmashell"));
m_feedbackProvider->setFeedbackServer(QUrl(QStringLiteral("https://telemetry.kde.org/")));
m_feedbackProvider->setSubmissionInterval(7);
m_feedbackProvider->setApplicationStartsUntilEncouragement(5);
m_feedbackProvider->setEncouragementDelay(30);
m_feedbackProvider->addDataSource(new KUserFeedback::ApplicationVersionSource);
m_feedbackProvider->addDataSource(new KUserFeedback::CompilerInfoSource);
m_feedbackProvider->addDataSource(new KUserFeedback::PlatformInfoSource);
m_feedbackProvider->addDataSource(new KUserFeedback::QtVersionSource);
m_feedbackProvider->addDataSource(new KUserFeedback::UsageTimeSource);
m_feedbackProvider->addDataSource(new KUserFeedback::OpenGLInfoSource);
m_feedbackProvider->addDataSource(new KUserFeedback::ScreenInfoSource);
m_feedbackProvider->addDataSource(new PanelCountSource(this));
{
auto plasmaConfig = KSharedConfig::openConfig(QStringLiteral("PlasmaUserFeedback"));
m_feedbackProvider->setTelemetryMode(KUserFeedback::Provider::TelemetryMode(plasmaConfig->group("Global").readEntry("FeedbackLevel", int(KUserFeedback::Provider::NoTelemetry))));
}
#endif
//FIXME: this would change the runtime platform to a fixed one if available
// but a different way to load platform specific components is needed beforehand
......
......@@ -66,10 +66,6 @@ namespace KWayland
class PlasmaShell;
}
}
namespace KUserFeedback
{
class Provider;
};
class ShellCorona : public Plasma::Corona, QDBusContext
{
......@@ -123,8 +119,6 @@ public:
QString defaultContainmentPlugin() const;
KUserFeedback::Provider* feedbackProvider() const { return m_feedbackProvider; }
Q_SIGNALS:
void glInitializationFailed();
......@@ -269,7 +263,6 @@ private:
QString m_testModeLayout;
StrutManager *m_strutManager;
KUserFeedback::Provider *m_feedbackProvider = nullptr;
};
#endif // SHELLCORONA_H
......
/*
* Copyright 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
* Copyright 2020 David Edmundson <davidedmundson@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "userfeedback.h"
#include <KUserFeedback/Provider>
#include <KUserFeedback/ApplicationVersionSource>
#include <KUserFeedback/CompilerInfoSource>
#include <KUserFeedback/PlatformInfoSource>
#include <KUserFeedback/QtVersionSource>
#include <KUserFeedback/UsageTimeSource>
#include <KUserFeedback/OpenGLInfoSource>
#include <KUserFeedback/ScreenInfoSource>
#include <KLocalizedString>
#include "shellcorona.h"
class PanelCountSource : public KUserFeedback::AbstractDataSource
{
public:
/*! Create a new start count data source. */
PanelCountSource(ShellCorona* corona)
: AbstractDataSource(QStringLiteral("panelCount"), KUserFeedback::Provider::DetailedSystemInformation)
, corona(corona)
{}
QString name() const override { return i18n("Panel Count"); }
QString description() const override { return i18n("Counts the panels"); }
QVariant data() override { return QVariantMap{ { QStringLiteral("panelCount"), corona->panelCount() } } ; }
private:
ShellCorona* const corona;
};
UserFeedback::UserFeedback(ShellCorona *corona, QObject *parent)
: QObject(parent)
, m_provider(new KUserFeedback::Provider(this))
{
m_provider->setProductIdentifier(QStringLiteral("org.kde.plasmashell"));
m_provider->setFeedbackServer(QUrl(QStringLiteral("https://telemetry.kde.org/")));
m_provider->setSubmissionInterval(7);
m_provider->setApplicationStartsUntilEncouragement(5);
m_provider->setEncouragementDelay(30);
m_provider->addDataSource(new KUserFeedback::ApplicationVersionSource);
m_provider->addDataSource(new KUserFeedback::CompilerInfoSource);
m_provider->addDataSource(new KUserFeedback::PlatformInfoSource);
m_provider->addDataSource(new KUserFeedback::QtVersionSource);
m_provider->addDataSource(new KUserFeedback::UsageTimeSource);
m_provider->addDataSource(new KUserFeedback::OpenGLInfoSource);
m_provider->addDataSource(new KUserFeedback::ScreenInfoSource);
m_provider->addDataSource(new PanelCountSource(corona));
auto plasmaConfig = KSharedConfig::openConfig(QStringLiteral("PlasmaUserFeedback"));
m_provider->setTelemetryMode(KUserFeedback::Provider::TelemetryMode(plasmaConfig->group("Global").readEntry("FeedbackLevel", int(KUserFeedback::Provider::NoTelemetry))));
}
QString UserFeedback::describeDataSources() const
{
return m_provider->describeDataSources();
}
/*
* Copyright 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
* Copyright 2020 David Edmundson <davidedmundson@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
......@@ -17,29 +18,24 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PANELCOUNTSOURCE_H
#define PANELCOUNTSOURCE_H
#pragma once
#include "shellcorona.h"
#include <KLocalizedString>
#include <KUserFeedback/AbstractDataSource>
#include <QObject>
class PanelCountSource : public KUserFeedback::AbstractDataSource
{
public:
/*! Create a new start count data source. */
PanelCountSource(ShellCorona* corona)
: AbstractDataSource(QStringLiteral("panelCount"), KUserFeedback::Provider::DetailedSystemInformation)
, corona(corona)
{}
class ShellCorona;
QString name() const override { return i18n("Panel Count"); }
QString description() const override { return i18n("Counts the panels"); }
QVariant data() override { return QVariantMap{ { QStringLiteral("panelCount"), corona->panelCount() } } ; }
namespace KUserFeedback
{
class Provider;
}
class UserFeedback : public QObject
{
Q_OBJECT
public:
UserFeedback(ShellCorona *corona, QObject *parent);
~UserFeedback() override = default;
QString describeDataSources() const;
private:
ShellCorona* const corona;
KUserFeedback::Provider *m_provider;
};
#endif
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