diff --git a/libs/telemetry/kis_telemetry_tickets.cpp b/libs/telemetry/kis_telemetry_tickets.cpp index ac6a8b37b2..fd11010123 100644 --- a/libs/telemetry/kis_telemetry_tickets.cpp +++ b/libs/telemetry/kis_telemetry_tickets.cpp @@ -1,127 +1,127 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_telemetry_tickets.h" #include #include #include KisTimeTicket::KisTimeTicket(QString id) - : KisTicket(id) + : KisTelemetryTicket(id) { m_start = QDateTime::currentDateTime(); m_end = m_start; } void KisTimeTicket::setStartTime(QDateTime& time) { m_start = time; } void KisTimeTicket::setEndTime(QDateTime& time) { m_end = time; } QDateTime KisTimeTicket::startTime() const { return m_start; } QDateTime KisTimeTicket::endTime() const { return m_end; } int KisTimeTicket::useTimeMSeconds() const { int timeUse = static_cast(m_end.toMSecsSinceEpoch() - m_start.toMSecsSinceEpoch()); return timeUse; } void KisTimeTicket::addMSecs(int seconds) { if (seconds < 0) { seconds = std::numeric_limits::max(); } m_end.addMSecs(seconds); } -KisTicket::KisTicket(QString id) +KisTelemetryTicket::KisTelemetryTicket(QString id) : m_id(id) { } -QString KisTicket::ticketId() const +QString KisTelemetryTicket::ticketId() const { return m_id; } -void KisTicket::setTickedId(QString id) +void KisTelemetryTicket::setTickedId(QString id) { m_id = id; } KisImagePropertiesTicket::KisImagePropertiesTicket(KisImagePropertiesTicket::ImageInfo imageInfo, QString id) : m_imageInfo(imageInfo) , m_fileInfo(id) { } QSize KisImagePropertiesTicket::size() const { return m_imageInfo.size; } int KisImagePropertiesTicket::getNumLayers() const { return m_imageInfo.numLayers; } QString KisImagePropertiesTicket::getFileFormat() const { return m_fileInfo.completeSuffix(); } QString KisImagePropertiesTicket::getColorSpace() const { return m_imageInfo.colorSpace; } qint64 KisImagePropertiesTicket::getImageSize() const { return m_fileInfo.size(); } QString KisImagePropertiesTicket::getColorProfile() const { return m_imageInfo.colorProfile; } KisActionInfoTicket::KisActionInfoTicket(KisActionInfoTicket::ActionInfo actionInfo, QString id) - : KisTicket(id) + : KisTelemetryTicket(id) , m_actionInfo(actionInfo) { } KisActionInfoTicket::ActionInfo KisActionInfoTicket::actionInfo() const { return m_actionInfo; } diff --git a/libs/telemetry/kis_telemetry_tickets.h b/libs/telemetry/kis_telemetry_tickets.h index 43215d39e8..6a15e20d7a 100644 --- a/libs/telemetry/kis_telemetry_tickets.h +++ b/libs/telemetry/kis_telemetry_tickets.h @@ -1,93 +1,93 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_TELEMETRY_TICKETS_H #define KIS_TELEMETRY_TICKETS_H #include #include #include #include "kritatelemetry_export.h" -class KRITATELEMETRY_EXPORT KisTicket { +class KRITATELEMETRY_EXPORT KisTelemetryTicket { public: - KisTicket() {} - KisTicket(QString id); + KisTelemetryTicket() {} + KisTelemetryTicket(QString id); QString ticketId() const; void setTickedId(QString id); - virtual ~KisTicket() {} + virtual ~KisTelemetryTicket() {} protected: QString m_id; }; -class KRITATELEMETRY_EXPORT KisTimeTicket : public KisTicket { +class KRITATELEMETRY_EXPORT KisTimeTicket : public KisTelemetryTicket { public: KisTimeTicket(QString id); void setStartTime(QDateTime& time); void setEndTime(QDateTime& time); QDateTime startTime() const; QDateTime endTime() const; int useTimeMSeconds() const; void addMSecs(int seconds); private: QDateTime m_start; QDateTime m_end; }; -class KRITATELEMETRY_EXPORT KisImagePropertiesTicket : public KisTicket { +class KRITATELEMETRY_EXPORT KisImagePropertiesTicket : public KisTelemetryTicket { public: struct ImageInfo { QSize size; QString filename; QString colorProfile; QString colorSpace; int numLayers; }; public: KisImagePropertiesTicket(KisImagePropertiesTicket::ImageInfo imageInfo, QString id); QSize size() const; int getNumLayers() const; QString getFileFormat() const; QString getColorSpace() const; qint64 getImageSize() const; QString getColorProfile() const; private: KisImagePropertiesTicket::ImageInfo m_imageInfo; QFileInfo m_fileInfo; }; -class KRITATELEMETRY_EXPORT KisActionInfoTicket : public KisTicket { +class KRITATELEMETRY_EXPORT KisActionInfoTicket : public KisTelemetryTicket { public: struct ActionInfo{ QString name; QString source; }; public: KisActionInfoTicket(KisActionInfoTicket::ActionInfo actionInfo, QString id); KisActionInfoTicket::ActionInfo actionInfo() const; private: KisActionInfoTicket::ActionInfo m_actionInfo; }; #endif diff --git a/plugins/telemetry/CMakeLists.txt b/plugins/telemetry/CMakeLists.txt index f67b5f4658..972691cd02 100644 --- a/plugins/telemetry/CMakeLists.txt +++ b/plugins/telemetry/CMakeLists.txt @@ -1,19 +1,19 @@ set(kritaplugintelemetry_SOURCES - kis_telemetry_provider.cpp - kis_telemetry.cpp - kis_cpuinfosource.cpp - kis_toolsinfosource.cpp - kis_assertinfosource.cpp - kis_imagepropertiessource.cpp - kis_actionsinfosource.cpp + telemetry_provider.cpp + telemetry.cpp + cpu_info_source.cpp + tools_info_source.cpp + assert_info_source.cpp + image_properties_source.cpp + actions_info_source.cpp ) add_subdirectory( tests ) add_library(kritaplugintelemetry MODULE ${kritaplugintelemetry_SOURCES}) generate_export_header(kritaplugintelemetry EXPORT_MACRO_NAME TELEMETRY_PLUGIN_EXPORT) target_link_libraries(kritaplugintelemetry kritalibtelemetry KUserFeedbackCore kritaui) install(TARGETS kritaplugintelemetry DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) diff --git a/plugins/telemetry/kis_actionsinfosource.cpp b/plugins/telemetry/actions_info_source.cpp similarity index 82% rename from plugins/telemetry/kis_actionsinfosource.cpp rename to plugins/telemetry/actions_info_source.cpp index 97228a6ac4..dfcf469f88 100644 --- a/plugins/telemetry/kis_actionsinfosource.cpp +++ b/plugins/telemetry/actions_info_source.cpp @@ -1,72 +1,72 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include "kis_actionsinfosource.h" -using namespace KisUserFeedback; +#include "actions_info_source.h" +using namespace UserFeedback; using namespace KUserFeedback; -KisUserFeedback::ActionsInfoSource::ActionsInfoSource() +UserFeedback::TelemetryActionsInfoSource::TelemetryActionsInfoSource() : AbstractDataSource(QStringLiteral("actions"), Provider::DetailedSystemInformation) { } -QString KisUserFeedback::ActionsInfoSource::description() const +QString UserFeedback::TelemetryActionsInfoSource::description() const { return QObject::tr("The number of used actions and their sources"); } -QVariant KisUserFeedback::ActionsInfoSource::data() +QVariant UserFeedback::TelemetryActionsInfoSource::data() { if (!m_actionsInfo.isEmpty()) { m_actionsInfo.clear(); } foreach (actionInfo action, m_actionsInfoMap) { - KisTicket* ticket = action.ticket.data(); + KisTelemetryTicket* ticket = action.ticket.data(); KisActionInfoTicket* actionTicket = nullptr; actionTicket = dynamic_cast(ticket); if (actionTicket) { QVariantMap m; m.insert(QStringLiteral("actionName"), ticket->ticketId()); m.insert(QStringLiteral("sources"), actionTicket->actionInfo().source); m.insert(QStringLiteral("countUse"), action.countUse); m_actionsInfo.push_back(m); } } return m_actionsInfo; } -void ActionsInfoSource::insert(QSharedPointer ticket) +void TelemetryActionsInfoSource::insert(QSharedPointer ticket) { if (m_actionsInfoMap.count(ticket->ticketId())) { int countUse = m_actionsInfoMap.value(ticket->ticketId()).countUse; m_actionsInfoMap.insert(ticket->ticketId(), { ticket, ++countUse }); } else { m_actionsInfoMap.insert(ticket->ticketId(), { ticket, 1 }); } } -void ActionsInfoSource::clear() +void TelemetryActionsInfoSource::clear() { m_actionsInfoMap.clear(); m_actionsInfo.clear(); } diff --git a/plugins/telemetry/kis_actionsinfosource.h b/plugins/telemetry/actions_info_source.h similarity index 86% rename from plugins/telemetry/kis_actionsinfosource.h rename to plugins/telemetry/actions_info_source.h index a416a67f71..28e723b9eb 100644 --- a/plugins/telemetry/kis_actionsinfosource.h +++ b/plugins/telemetry/actions_info_source.h @@ -1,56 +1,56 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISUSERFEEDBACK_ACTIONSINFOSOURCE_H #define KISUSERFEEDBACK_ACTIONSINFOSOURCE_H #include "QSharedPointer" #include "abstractdatasource.h" #include "kis_telemetry_tickets.h" #include "kuserfeedbackcore_export.h" #include #include -namespace KisUserFeedback { +namespace UserFeedback { /*! Data source reporting about actions. * * The default telemetry mode for this source is Provider::DetailedSystemInformation. */ -class ActionsInfoSource : public KUserFeedback::AbstractDataSource { +class TelemetryActionsInfoSource : public KUserFeedback::AbstractDataSource { public: - ActionsInfoSource(); + TelemetryActionsInfoSource(); QString description() const override; QVariant data() override; - void insert(QSharedPointer ticket); + void insert(QSharedPointer ticket); void clear(); private: struct actionInfo { - QSharedPointer ticket; + QSharedPointer ticket; int mutable countUse; }; private: QVariantList m_actionsInfo; QMap m_actionsInfoMap; }; } #endif // KISUSERFEEDBACK_ACTIONSINFOSOURCE_H diff --git a/plugins/telemetry/kis_assertinfosource.cpp b/plugins/telemetry/assert_info_source.cpp similarity index 88% rename from plugins/telemetry/kis_assertinfosource.cpp rename to plugins/telemetry/assert_info_source.cpp index 0eb60b124b..0f7da5cbfd 100644 --- a/plugins/telemetry/kis_assertinfosource.cpp +++ b/plugins/telemetry/assert_info_source.cpp @@ -1,63 +1,63 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include "kis_assertinfosource.h" +#include "assert_info_source.h" #include #include #include #include -using namespace KisUserFeedback; +using namespace UserFeedback; using namespace KUserFeedback; -KisUserFeedback::AssertInfoSource::AssertInfoSource() +UserFeedback::TelemetryAssertInfoSource::TelemetryAssertInfoSource() : AbstractDataSource(QStringLiteral("asserts"), Provider::DetailedSystemInformation) { } -QString KisUserFeedback::AssertInfoSource::description() const +QString UserFeedback::TelemetryAssertInfoSource::description() const { return QObject::tr("Information about asserts"); } -QVariant KisUserFeedback::AssertInfoSource::data() +QVariant UserFeedback::TelemetryAssertInfoSource::data() { QVariantMap m; KConfigGroup configGroup = KSharedConfig::openConfig()->group("KisAsserts"); QString assertText = configGroup.readEntry("FatalAssertion", "Empty"); if(assertText == "Empty" ) throw NoFatalError(); m.insert(QStringLiteral("assertText"), assertText); configGroup.writeEntry("FatalAssertion", "Empty"); QString assertFile = configGroup.readEntry("FatalFile", "Empty"); m.insert(QStringLiteral("assertFile"), assertFile); configGroup.writeEntry("FatalFile", "Empty"); QString assertLine = configGroup.readEntry("FatalLine", "Empty"); m.insert(QStringLiteral("assertLine"), assertLine); configGroup.writeEntry("FatalLine", "Empty"); return m; } const char *NoFatalError::what() const throw() { return "no fatal error \n"; } diff --git a/plugins/telemetry/kis_assertinfosource.h b/plugins/telemetry/assert_info_source.h similarity index 90% rename from plugins/telemetry/kis_assertinfosource.h rename to plugins/telemetry/assert_info_source.h index 6066c67056..ba24863e38 100644 --- a/plugins/telemetry/kis_assertinfosource.h +++ b/plugins/telemetry/assert_info_source.h @@ -1,46 +1,46 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISUSERFEEDBACK_ASSERTINFOSOURCE_H #define KISUSERFEEDBACK_ASSERTINFOSOURCE_H #include "abstractdatasource.h" #include "kuserfeedbackcore_export.h" #include -namespace KisUserFeedback { +namespace UserFeedback { /*! Data source reporting the assert info */ -class AssertInfoSource : public KUserFeedback::AbstractDataSource { +class TelemetryAssertInfoSource : public KUserFeedback::AbstractDataSource { public: - AssertInfoSource(); + TelemetryAssertInfoSource(); QString description() const override; QVariant data() override; }; } class NoFatalError : public std::exception { public: NoFatalError() = default; virtual const char* what() const throw(); }; #endif // KISUSERFEEDBACK_ASSERTINFOSOURCE_H diff --git a/plugins/telemetry/kis_cpuinfosource.cpp b/plugins/telemetry/cpu_info_source.cpp similarity index 89% rename from plugins/telemetry/kis_cpuinfosource.cpp rename to plugins/telemetry/cpu_info_source.cpp index 5a8a86eda4..677f8e4bbf 100644 --- a/plugins/telemetry/kis_cpuinfosource.cpp +++ b/plugins/telemetry/cpu_info_source.cpp @@ -1,57 +1,57 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include "kis_cpuinfosource.h" +#include "cpu_info_source.h" #include #include #include #include -using namespace KisUserFeedback; +using namespace UserFeedback; using namespace KUserFeedback; -CpuInfoSource::CpuInfoSource() +TelemetryCpuInfoSource::TelemetryCpuInfoSource() : AbstractDataSource(QStringLiteral("cpu"), Provider::DetailedSystemInformation) { } -QString CpuInfoSource::description() const +QString TelemetryCpuInfoSource::description() const { return QObject::tr("The amount and type of CPUs in the system."); } -QVariant CpuInfoSource::data() +QVariant TelemetryCpuInfoSource::data() { QVariantMap m; Vc_VERSIONED_NAMESPACE::CpuId::init(); #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) m.insert(QStringLiteral("architecture"), QSysInfo::currentCpuArchitecture()); #else m.insert(QStringLiteral("architecture"), QStringLiteral("unknown")); #endif m.insert(QStringLiteral("count"), QThread::idealThreadCount()); m.insert(QStringLiteral("model"),Vc_VERSIONED_NAMESPACE::CpuId::processorModel()); m.insert(QStringLiteral("family"),Vc_VERSIONED_NAMESPACE::CpuId::processorFamily()); m.insert(QStringLiteral("isIntel"),Vc_VERSIONED_NAMESPACE::CpuId::isIntel()); return m; } diff --git a/plugins/telemetry/kis_cpuinfosource.h b/plugins/telemetry/cpu_info_source.h similarity index 90% rename from plugins/telemetry/kis_cpuinfosource.h rename to plugins/telemetry/cpu_info_source.h index 9e280fdee9..3fb6cf54cd 100644 --- a/plugins/telemetry/kis_cpuinfosource.h +++ b/plugins/telemetry/cpu_info_source.h @@ -1,41 +1,41 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISUSERFEEDBACK_CPUINFOSOURCE_H #define KISUSERFEEDBACK_CPUINFOSOURCE_H #include "abstractdatasource.h" #include "kuserfeedbackcore_export.h" -namespace KisUserFeedback { +namespace UserFeedback { /*! Data source reporting the type and amount of CPUs. * * The default telemetry mode for this source is Provider::DetailedSystemInformation. */ -class CpuInfoSource : public KUserFeedback::AbstractDataSource { +class TelemetryCpuInfoSource : public KUserFeedback::AbstractDataSource { public: - CpuInfoSource(); + TelemetryCpuInfoSource(); QString description() const override; QVariant data() override; }; } #endif // KISUSERFEEDBACK_CPUINFOSOURCE_H diff --git a/plugins/telemetry/kis_imagepropertiessource.cpp b/plugins/telemetry/image_properties_source.cpp similarity index 83% rename from plugins/telemetry/kis_imagepropertiessource.cpp rename to plugins/telemetry/image_properties_source.cpp index 53feacf965..5e0342b1f7 100644 --- a/plugins/telemetry/kis_imagepropertiessource.cpp +++ b/plugins/telemetry/image_properties_source.cpp @@ -1,84 +1,84 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * #ifndef KISUSERFEEDBACK_ASSERTINFOSOURCE_H #define KISUSERFEEDBACK_ASSERTINFOSOURCE_H #include "abstractdatasource.h" #include "kuserfeedbackcore_export.h" #include namespace KisUserFeedback { /*! Data source reporting the assert info */ #include -#include -using namespace KisUserFeedback; +#include +using namespace UserFeedback; using namespace KUserFeedback; -ImagePropertiesSource::ImagePropertiesSource() +TelemetryImagePropertiesSource::TelemetryImagePropertiesSource() : AbstractDataSource(QStringLiteral("Images"), Provider::DetailedSystemInformation) { } -QString ImagePropertiesSource::description() const +QString TelemetryImagePropertiesSource::description() const { return QObject::tr("The informtion about images"); } -QVariant ImagePropertiesSource::data() +QVariant TelemetryImagePropertiesSource::data() { static int countCalls = 0; countCalls++; if (!countCalls % 2) { //kuserfeedback feature m_imageDumps.clear(); } - foreach (QSharedPointer imageDump, m_imagesDumpsMap) { + foreach (QSharedPointer imageDump, m_imagesDumpsMap) { KisImagePropertiesTicket* imagePropertiesTicket = nullptr; imagePropertiesTicket = dynamic_cast(imageDump.data()); if (imagePropertiesTicket) { QVariantMap m; m.insert(QStringLiteral("width"), imagePropertiesTicket->size().width()); m.insert(QStringLiteral("height"), imagePropertiesTicket->size().height()); m.insert(QStringLiteral("size"), imagePropertiesTicket->getImageSize()); m.insert(QStringLiteral("colorProfile"), imagePropertiesTicket->getColorProfile()); m.insert(QStringLiteral("colorSpace"), imagePropertiesTicket->getColorSpace()); m.insert(QStringLiteral("numLayers"), imagePropertiesTicket->getNumLayers()); m_imageDumps.push_back(m); } } m_imagesDumpsMap.clear(); return m_imageDumps; } -void ImagePropertiesSource::removeDumpProperties(QString id) +void TelemetryImagePropertiesSource::removeDumpProperties(QString id) { m_imagesDumpsMap.remove(id); } -void ImagePropertiesSource::createNewImageProperties(QSharedPointer ticket) +void TelemetryImagePropertiesSource::createNewImageProperties(QSharedPointer ticket) { m_imagesDumpsMap.insert(ticket->ticketId(), ticket); } diff --git a/plugins/telemetry/kis_imagepropertiessource.h b/plugins/telemetry/image_properties_source.h similarity index 82% rename from plugins/telemetry/kis_imagepropertiessource.h rename to plugins/telemetry/image_properties_source.h index 67e34fd2ca..d7ce4dfdf2 100644 --- a/plugins/telemetry/kis_imagepropertiessource.h +++ b/plugins/telemetry/image_properties_source.h @@ -1,50 +1,50 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef KISUSERFEEDBACK_IMAGEPROPERTIESSOURCE_H #define KISUSERFEEDBACK_IMAGEPROPERTIESSOURCE_H #include "abstractdatasource.h" #include "kuserfeedbackcore_export.h" #include "kis_telemetry_tickets.h" #include #include #include -namespace KisUserFeedback { +namespace UserFeedback { /*! Data source reporting about image properties info */ -class ImagePropertiesSource : public KUserFeedback::AbstractDataSource { +class TelemetryImagePropertiesSource : public KUserFeedback::AbstractDataSource { public: - ImagePropertiesSource(); + TelemetryImagePropertiesSource(); QString description() const override; QVariant data() override; void removeDumpProperties(QString id); - void createNewImageProperties(QSharedPointer ticket); + void createNewImageProperties(QSharedPointer ticket); private: QVariantList m_imageDumps; - QMap > m_imagesDumpsMap; + QMap > m_imagesDumpsMap; }; } #endif // KISUSERFEEDBACK_IMAGEPROPERTIESSOURCE_H diff --git a/plugins/telemetry/kis_telemetry.cpp b/plugins/telemetry/telemetry.cpp similarity index 79% rename from plugins/telemetry/kis_telemetry.cpp rename to plugins/telemetry/telemetry.cpp index 34ef524e89..81448a7147 100644 --- a/plugins/telemetry/kis_telemetry.cpp +++ b/plugins/telemetry/telemetry.cpp @@ -1,45 +1,45 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include "kis_telemetry.h" +#include "telemetry.h" #include "KPluginFactory" #include #include #include #include #include -#include "kis_telemetry_provider.h" +#include "telemetry_provider.h" #include "kis_telemetry_instance.h" -K_PLUGIN_FACTORY_WITH_JSON(KisTelemetryFactory, "kritatelemetry.json", registerPlugin();) +K_PLUGIN_FACTORY_WITH_JSON(KisTelemetryFactory, "kritatelemetry.json", registerPlugin();) -KisTelemetry::KisTelemetry(QObject* parent, const QVariantList&) +Telemetry::Telemetry(QObject* parent, const QVariantList&) : QObject(parent) { - KisTelemetryInstance::instance()->setProvider(new KisTelemetryProvider); + KisTelemetryInstance::instance()->setProvider(new TelemetryProvider); } -KisTelemetry::~KisTelemetry() +Telemetry::~Telemetry() { } -#include "kis_telemetry.moc" +#include "telemetry.moc" diff --git a/plugins/telemetry/kis_telemetry.h b/plugins/telemetry/telemetry.h similarity index 88% rename from plugins/telemetry/kis_telemetry.h rename to plugins/telemetry/telemetry.h index b8e05a8123..b31713c73d 100644 --- a/plugins/telemetry/kis_telemetry.h +++ b/plugins/telemetry/telemetry.h @@ -1,35 +1,35 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_TELEMETRY_H #define KIS_TELEMETRY_H #include "QScopedPointer" #include -class KisTelemetry : public QObject { +class Telemetry : public QObject { Q_OBJECT public: - KisTelemetry(QObject* parent, const QVariantList&); - ~KisTelemetry() override; + Telemetry(QObject* parent, const QVariantList&); + ~Telemetry() override; }; #endif diff --git a/plugins/telemetry/kis_telemetry_provider.cpp b/plugins/telemetry/telemetry_provider.cpp similarity index 75% rename from plugins/telemetry/kis_telemetry_provider.cpp rename to plugins/telemetry/telemetry_provider.cpp index ba0ab13fc0..f64e0a8390 100644 --- a/plugins/telemetry/kis_telemetry_provider.cpp +++ b/plugins/telemetry/telemetry_provider.cpp @@ -1,248 +1,248 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include "kis_telemetry_provider.h" +#include "telemetry_provider.h" #include "KPluginFactory" #include "KisPart.h" #include #include #include #include #include "Vc/cpuid.h" -#include "kis_actionsinfosource.h" -#include "kis_toolsinfosource.h" +#include "actions_info_source.h" +#include "tools_info_source.h" #include #include #include -#include +#include #include -#include +#include #include -KisTelemetryProvider::KisTelemetryProvider() +TelemetryProvider::TelemetryProvider() { m_installProvider.reset(new KUserFeedback::Provider); m_installProvider->setTelemetryMode(KUserFeedback::Provider::DetailedUsageStatistics); - std::unique_ptr cpu(new KisUserFeedback::CpuInfoSource()); + std::unique_ptr cpu(new UserFeedback::TelemetryCpuInfoSource()); m_installSources.push_back(std::move(cpu)); std::unique_ptr qt(new KUserFeedback::QtVersionSource()); m_installSources.push_back(std::move(qt)); std::unique_ptr compiler(new KUserFeedback::CompilerInfoSource()); m_installSources.push_back(std::move(compiler)); std::unique_ptr locale(new KUserFeedback::LocaleInfoSource()); m_installSources.push_back(std::move(locale)); std::unique_ptr opengl(new KUserFeedback::OpenGLInfoSource()); m_installSources.push_back(std::move(opengl)); std::unique_ptr platform(new KUserFeedback::PlatformInfoSource()); m_installSources.push_back(std::move(platform)); std::unique_ptr screen(new KUserFeedback::ScreenInfoSource()); m_installSources.push_back(std::move(screen)); for (auto& source : m_installSources) { m_installProvider->addDataSource(source.get()); } m_toolsProvider.reset(new KUserFeedback::Provider); m_toolsProvider.data()->setTelemetryMode(KUserFeedback::Provider::DetailedUsageStatistics); - std::unique_ptr tools(new KisUserFeedback::ToolsInfoSource); + std::unique_ptr tools(new UserFeedback::TelemetryToolsInfoSource); m_toolSources.push_back(std::move(tools)); for (auto& source : m_toolSources) { m_toolsProvider->addDataSource(source.get()); } m_assertsProvider.reset(new KUserFeedback::Provider); m_toolsProvider->setTelemetryMode(KUserFeedback::Provider::DetailedUsageStatistics); - std::unique_ptr asserts(new KisUserFeedback::AssertInfoSource); + std::unique_ptr asserts(new UserFeedback::TelemetryAssertInfoSource); m_assertsSources.push_back(std::move(asserts)); for (auto& source : m_assertsSources) { m_assertsProvider->addDataSource(source.get()); } m_imagePropertiesProvider.reset(new KUserFeedback::Provider); m_imagePropertiesProvider->setTelemetryMode(KUserFeedback::Provider::DetailedUsageStatistics); - std::unique_ptr imageProperties(new KisUserFeedback::ImagePropertiesSource); + std::unique_ptr imageProperties(new UserFeedback::TelemetryImagePropertiesSource); m_imagePropertiesSources.push_back(std::move(imageProperties)); for (auto& source : m_imagePropertiesSources) { m_imagePropertiesProvider.data()->addDataSource(source.get()); } m_actionsInfoProvider.reset(new KUserFeedback::Provider); m_actionsInfoProvider->setTelemetryMode(KUserFeedback::Provider::DetailedUsageStatistics); - std::unique_ptr actionsInfo(new KisUserFeedback::ActionsInfoSource); + std::unique_ptr actionsInfo(new UserFeedback::TelemetryActionsInfoSource); m_actionsSources.push_back(std::move(actionsInfo)); for (auto& source : m_actionsSources) { m_actionsInfoProvider->addDataSource(source.get()); } } -void KisTelemetryProvider::sendData(QString path, QString adress) +void TelemetryProvider::sendData(QString path, QString adress) { if (!path.endsWith(QLatin1Char('/'))) path += QLatin1Char('/'); TelemetryCategory enumPath = pathToKind(path); QString finalAdress = adress.isNull() ? m_adress : adress; switch (enumPath) { case tools: { m_toolsProvider.data()->setFeedbackServer(QUrl(finalAdress + path)); m_toolsProvider.data()->submit(); break; } case install: { m_installProvider.data()->setFeedbackServer(QUrl(finalAdress + path)); m_installProvider.data()->submit(); break; } case asserts: { m_assertsProvider.data()->setFeedbackServer(QUrl(finalAdress + path)); m_assertsProvider.data()->submit(); break; } case imageProperties: { m_imagePropertiesProvider.data()->setFeedbackServer(QUrl(finalAdress + path)); m_imagePropertiesProvider.data()->submit(); break; } case actions: { qDebug() << "Send actions!"; m_actionsInfoProvider.data()->setFeedbackServer(QUrl(finalAdress + path)); m_actionsInfoProvider.data()->submit(); break; } default: break; } } -void KisTelemetryProvider::getTimeTicket(QString id) +void TelemetryProvider::getTimeTicket(QString id) { - KisTicket* ticket = m_tickets.value(id).lock().data(); + KisTelemetryTicket* ticket = m_tickets.value(id).lock().data(); if (!ticket) { return; } KisTimeTicket* timeTicket = nullptr; KUserFeedback::AbstractDataSource* m_tools = m_toolSources[0].get(); - KisUserFeedback::ToolsInfoSource* tools = nullptr; + UserFeedback::TelemetryToolsInfoSource* tools = nullptr; timeTicket = dynamic_cast(ticket); - tools = dynamic_cast(m_tools); + tools = dynamic_cast(m_tools); KIS_SAFE_ASSERT_RECOVER_RETURN(timeTicket); KIS_SAFE_ASSERT_RECOVER_RETURN(tools); KIS_SAFE_ASSERT_RECOVER_RETURN(ticket); tools->deactivateTool(id); m_tickets.remove(id); } -void KisTelemetryProvider::putTimeTicket(QString id) +void TelemetryProvider::putTimeTicket(QString id) { if (m_tickets.count(id)) { return; } KUserFeedback::AbstractDataSource* m_tools = m_toolSources[0].get(); - KisUserFeedback::ToolsInfoSource* tools = nullptr; + UserFeedback::TelemetryToolsInfoSource* tools = nullptr; - QSharedPointer timeTicket = QSharedPointer::create(id); + QSharedPointer timeTicket = QSharedPointer::create(id); - tools = dynamic_cast(m_tools); + tools = dynamic_cast(m_tools); KIS_SAFE_ASSERT_RECOVER_RETURN(tools); - QWeakPointer weakTimeTicket(timeTicket); + QWeakPointer weakTimeTicket(timeTicket); m_tickets.insert(id, weakTimeTicket); tools->activateTool(timeTicket); } -void KisTelemetryProvider::saveImageProperites(QString fileName, KisImagePropertiesTicket::ImageInfo imageInfo) +void TelemetryProvider::saveImageProperites(QString fileName, KisImagePropertiesTicket::ImageInfo imageInfo) { KUserFeedback::AbstractDataSource* m_imageProperties = m_imagePropertiesSources[0].get(); - KisUserFeedback::ImagePropertiesSource* imageProperties = nullptr; + UserFeedback::TelemetryImagePropertiesSource* imageProperties = nullptr; - QSharedPointer imagePropertiesTicket = QSharedPointer::create(imageInfo, fileName); + QSharedPointer imagePropertiesTicket = QSharedPointer::create(imageInfo, fileName); - imageProperties = dynamic_cast(m_imageProperties); + imageProperties = dynamic_cast(m_imageProperties); KIS_SAFE_ASSERT_RECOVER_RETURN(imageProperties); if (m_tickets.count(fileName)) { imageProperties->removeDumpProperties(fileName); return; } - QWeakPointer weakimagePropertiesTicket(imagePropertiesTicket); + QWeakPointer weakimagePropertiesTicket(imagePropertiesTicket); m_tickets.insert(fileName, weakimagePropertiesTicket); imageProperties->createNewImageProperties(imagePropertiesTicket); } -void KisTelemetryProvider::saveActionInfo(QString id, KisActionInfoTicket::ActionInfo actionInfo) +void TelemetryProvider::saveActionInfo(QString id, KisActionInfoTicket::ActionInfo actionInfo) { static QString lastAction = "start name"; static QTime lastTime = QTime(0, 0, 0, 0); bool isSameAction = false; if (lastAction != actionInfo.name || QTime::currentTime().secsTo(lastTime)) { isSameAction = false; } else { isSameAction = true; } if (!isSameAction) { KUserFeedback::AbstractDataSource* m_actionsInfo = m_actionsSources[0].get(); - KisUserFeedback::ActionsInfoSource* actionsInfoSource = nullptr; + UserFeedback::TelemetryActionsInfoSource* actionsInfoSource = nullptr; - QSharedPointer actionsInfoTicket = QSharedPointer::create(actionInfo, id); + QSharedPointer actionsInfoTicket = QSharedPointer::create(actionInfo, id); - actionsInfoSource = dynamic_cast(m_actionsInfo); + actionsInfoSource = dynamic_cast(m_actionsInfo); KIS_SAFE_ASSERT_RECOVER_RETURN(actionsInfoSource); - QWeakPointer weakactionsInfoTicket(actionsInfoTicket); + QWeakPointer weakactionsInfoTicket(actionsInfoTicket); m_tickets.insert(id, weakactionsInfoTicket); actionsInfoSource->insert(actionsInfoTicket); qDebug()<<"ACTION STORED"; } lastTime = QTime::currentTime(); lastAction = actionInfo.name; } -KisTelemetryProvider::~KisTelemetryProvider() +TelemetryProvider::~TelemetryProvider() { } -KisTelemetryProvider::TelemetryCategory KisTelemetryProvider::pathToKind(QString path) +TelemetryProvider::TelemetryCategory TelemetryProvider::pathToKind(QString path) { if (path == "tools/") return tools; else if (path == "install/") return install; else if (path == "asserts/") return asserts; else if (path == "imageProperties/") return imageProperties; else if (path == "actions/") return actions; return tools; } diff --git a/plugins/telemetry/kis_telemetry_provider.h b/plugins/telemetry/telemetry_provider.h similarity index 92% rename from plugins/telemetry/kis_telemetry_provider.h rename to plugins/telemetry/telemetry_provider.h index 78be50f586..d9c95f8049 100644 --- a/plugins/telemetry/kis_telemetry_provider.h +++ b/plugins/telemetry/telemetry_provider.h @@ -1,84 +1,84 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_TELEMETRY_REGULAR_PROVIDER_H #define KIS_TELEMETRY_REGULAR_PROVIDER_H #include "QScopedPointer" #include #include #include #include #include #include #include #include #include #include -#include "kis_cpuinfosource.h" +#include "cpu_info_source.h" #include "kritatelemetry_export.h" #include #include #include #include #include #include "kis_telemetry_tickets.h" -class KRITATELEMETRY_EXPORT KisTelemetryProvider : public KisTelemetryAbstract { +class KRITATELEMETRY_EXPORT TelemetryProvider : public KisTelemetryAbstract { public: - KisTelemetryProvider(); + TelemetryProvider(); void sendData(QString path, QString adress = QString()) override; - virtual ~KisTelemetryProvider(); + virtual ~TelemetryProvider(); protected: void getTimeTicket(QString id) override; void putTimeTicket(QString id) override; void saveImageProperites(QString fileName, KisImagePropertiesTicket::ImageInfo imageInfo) override; void saveActionInfo(QString id, KisActionInfoTicket::ActionInfo actionInfo) override; private: enum TelemetryCategory { tools, install, asserts, imageProperties, actions }; private: QScopedPointer m_toolsProvider; std::vector > m_toolSources; QScopedPointer m_installProvider; std::vector > m_installSources; QScopedPointer m_assertsProvider; std::vector > m_assertsSources; QScopedPointer m_imagePropertiesProvider; std::vector > m_imagePropertiesSources; QScopedPointer m_actionsInfoProvider; std::vector > m_actionsSources; - QMultiMap > m_tickets; + QMultiMap > m_tickets; private: TelemetryCategory pathToKind(QString path); }; #endif diff --git a/plugins/telemetry/tests/CMakeLists.txt b/plugins/telemetry/tests/CMakeLists.txt index fa21c78842..b778e684e7 100644 --- a/plugins/telemetry/tests/CMakeLists.txt +++ b/plugins/telemetry/tests/CMakeLists.txt @@ -1,14 +1,14 @@ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_SOURCE_DIR}/sdk/tests) include(KritaAddBrokenUnitTest) macro_add_unittest_definitions() -ecm_add_test(kis_telemetry_tests.cpp +ecm_add_test(telemetry_tests.cpp TEST_NAME krita-telemetryTest LINK_LIBRARIES kritaui KUserFeedbackCore kritaplugintelemetry Qt5::Test) add_definitions(-DFILES_OUTPUT_DIR="${CMAKE_CURRENT_BINARY_DIR}") diff --git a/plugins/telemetry/tests/kis_telemetry_tests.cpp b/plugins/telemetry/tests/telemetry_tests.cpp similarity index 94% rename from plugins/telemetry/tests/kis_telemetry_tests.cpp rename to plugins/telemetry/tests/telemetry_tests.cpp index ee8f1e40d9..fb0c6ddfb7 100644 --- a/plugins/telemetry/tests/kis_telemetry_tests.cpp +++ b/plugins/telemetry/tests/telemetry_tests.cpp @@ -1,217 +1,217 @@ /* This file is part of the KDE project * Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include "kis_telemetry_tests.h" -#include "plugins/telemetry/kis_telemetry_provider.h" +#include "telemetry_tests.h" +#include "plugins/telemetry/telemetry_provider.h" #include #include #include #include #include #include #include #include class Server : public QTcpServer { Q_OBJECT public: explicit Server(QObject* parent = 0) : QTcpServer(parent) { } ~Server() { server_socket->close(); server_socket->deleteLater(); } public Q_SLOTS: void tcpReady() { array = server_socket->read(server_socket->bytesAvailable()); emit endRead(); } bool start_listen(int port_no) { if (!this->listen(QHostAddress::Any, port_no)) { qDebug() << tr("Error!") << tr("Cannot listen to port %1").arg(port_no); return false; } else { return true; } } QByteArray resultRead() { return array; } Q_SIGNALS: void endRead(); protected: void incomingConnection(qintptr descriptor) { server_socket = new QTcpSocket(this); if (!server_socket->setSocketDescriptor(descriptor)) { qDebug() << "Error set socket"; return; } connect(server_socket, SIGNAL(readyRead()), this, SLOT(tcpReady())); } private: QTcpSocket* server_socket; QByteArray array; }; class TestTimeTickets : public QObject { Q_OBJECT public: TestTimeTickets() { - m_provider = new KisTelemetryProvider(); + m_provider = new TelemetryProvider(); } ~TestTimeTickets() { } void testCountUse(int port) { Server server; server.start_listen(port); QEventLoop loop; connect(&server, SIGNAL(endRead()), &loop, SLOT(quit())); testUse("testTool2", m_countUse); QString localhost = QString("http://localhost:") + QString::number(port) + QString("/"); m_provider->sendData("tools", localhost); loop.exec(); loop.exec(); QByteArray result = server.resultRead(); checkCountUse(result, "Tool/Use/testTool2"); } void testZeroUse(int port) { Server server; server.start_listen(port); QEventLoop loop; connect(&server, SIGNAL(endRead()), &loop, SLOT(quit())); testUse("testTool3", m_countUse); QString localhost = QString("http://localhost:") + QString::number(port) + QString("/"); m_provider->sendData("tools", localhost); loop.exec(); loop.exec(); QByteArray result = server.resultRead(); checkCountUse(result, "Tool/Use/testTool3"); } void testTimeUse(int port) { Server server; server.start_listen(port); QEventLoop loop; m_time.push_back(2000); connect(&server, SIGNAL(endRead()), &loop, SLOT(quit())); uncorrectCountUse("Tool/Use/testTool3"); QString localhost = QString("http://localhost:") + QString::number(port) + QString("/"); m_provider->sendData("tools", localhost); loop.exec(); loop.exec(); QByteArray result = server.resultRead(); checkCountUse(result, "Tool/Use/testTool3", 0); } private: void testUse(QString toolID, int count) { for (int i = 0; i < count; i++) { m_provider->notifyToolAcion(KisTelemetryAbstract::ToolsStartUse, toolID); QTest::qWait(m_time[0]); m_provider->notifyToolAcion(KisTelemetryAbstract::ToolsStopUse, toolID); } } void uncorrectCountUse(QString toolID) { m_provider->notifyToolAcion(KisTelemetryAbstract::ToolsStartUse, toolID); QTest::qWait(m_time[0]); } void checkTimeUse(QByteArray request, QString toolName) { QJsonDocument document = QJsonDocument::fromJson(request); QJsonObject object = document.object(); QJsonArray array = object["Tools"].toArray(); for (int i = 0; i < array.size(); i++) { QJsonObject obj = array[i].toObject(); if (toolName != obj["toolName"].toString()) continue; QVERIFY(((obj["timeUseMSeconds"].toInt() + 10) > m_time[i]) && ((obj["timeUseMSeconds"].toInt() - 10) < m_time[i])); } } void checkCountUse(QByteArray request, QString toolName, int countUse = m_countUse) { QJsonDocument document = QJsonDocument::fromJson(request); QJsonObject object = document.object(); QJsonArray array = object["Tools"].toArray(); for (int i = 0; i < array.size(); i++) { QJsonObject obj = array[i].toObject(); if (toolName != obj["toolName"].toString()) continue; QVERIFY((countUse) == obj["countUse"].toInt()); } } private: KisTelemetryAbstract* m_provider; QVector m_time; const static int m_countUse = 4; }; -void KisTelemetryTest::testTimeTicket() +void TelemetryTest::testTimeTicket() { TestTimeTickets test1; test1.testTimeUse(23456); } -void KisTelemetryTest::testCountUse() +void TelemetryTest::testCountUse() { TestTimeTickets test2; test2.testCountUse(23457); } -void KisTelemetryTest::testZeroUse() +void TelemetryTest::testZeroUse() { TestTimeTickets test3; test3.testCountUse(23458); } -#include "kis_telemetry_tests.moc" -QTEST_MAIN(KisTelemetryTest) +#include "telemetry_tests.moc" +QTEST_MAIN(TelemetryTest) diff --git a/plugins/telemetry/tests/kis_telemetry_tests.h b/plugins/telemetry/tests/telemetry_tests.h similarity index 90% rename from plugins/telemetry/tests/kis_telemetry_tests.h rename to plugins/telemetry/tests/telemetry_tests.h index 903344e4a6..a19b67365d 100644 --- a/plugins/telemetry/tests/kis_telemetry_tests.h +++ b/plugins/telemetry/tests/telemetry_tests.h @@ -1,36 +1,36 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#ifndef __KIS_TELEMETRY_TEST_H -#define __KIS_TELEMETRY_TEST_H +#ifndef __TELEMETRY_TEST_H +#define __TELEMETRY_TEST_H #include -class KisTelemetryTest : public QObject +class TelemetryTest : public QObject { Q_OBJECT private Q_SLOTS: void testTimeTicket(); void testCountUse(); void testZeroUse(); }; #endif diff --git a/plugins/telemetry/kis_toolsinfosource.cpp b/plugins/telemetry/tools_info_source.cpp similarity index 82% rename from plugins/telemetry/kis_toolsinfosource.cpp rename to plugins/telemetry/tools_info_source.cpp index de8727c959..e6d8aa8f9c 100644 --- a/plugins/telemetry/kis_toolsinfosource.cpp +++ b/plugins/telemetry/tools_info_source.cpp @@ -1,99 +1,99 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#include "kis_toolsinfosource.h" +#include "tools_info_source.h" #include #include #include #include #include -using namespace KisUserFeedback; +using namespace UserFeedback; using namespace KUserFeedback; -ToolsInfoSource::ToolsInfoSource() +TelemetryToolsInfoSource::TelemetryToolsInfoSource() : AbstractDataSource(QStringLiteral("Tools"), Provider::DetailedSystemInformation) { } -QString ToolsInfoSource::description() const +QString TelemetryToolsInfoSource::description() const { return QObject::tr("Inforamation about tools"); } -QVariant ToolsInfoSource::data() +QVariant TelemetryToolsInfoSource::data() { static int countCalls = 0; countCalls++; if (!countCalls % 2) { //kuserfeedback feature m_tools.clear(); } foreach (toolInfo tool, m_toolsMap) { - KisTicket* ticket = tool.ticket.data(); + KisTelemetryTicket* ticket = tool.ticket.data(); KisTimeTicket* timeTicket = nullptr; timeTicket = dynamic_cast(ticket); if (timeTicket) { int timeUse = timeTicket->useTimeMSeconds(); if (!timeUse) { continue; } QVariantMap m; m.insert(QStringLiteral("toolName"), ticket->ticketId()); m.insert(QStringLiteral("timeUseMSeconds"), timeUse); m.insert(QStringLiteral("countUse"), tool.countUse); m_tools.push_back(m); } } m_toolsMap.clear(); return m_tools; } -void ToolsInfoSource::activateTool(QSharedPointer ticket) +void TelemetryToolsInfoSource::activateTool(QSharedPointer ticket) { QMutexLocker locker(&m_mutex); m_currentTools.insert(ticket->ticketId(), ticket); if (!m_toolsMap.count(ticket->ticketId())){ m_toolsMap.insert(ticket->ticketId(), {ticket, 0}); } } -void ToolsInfoSource::deactivateTool(QString id) +void TelemetryToolsInfoSource::deactivateTool(QString id) { QMutexLocker locker(&m_mutex); - KisTicket* ticket = m_currentTools.value(id).data(); + KisTelemetryTicket* ticket = m_currentTools.value(id).data(); KisTimeTicket* timeTicket = dynamic_cast(ticket); if (timeTicket) { QDateTime deactivateTime = QDateTime::currentDateTime(); timeTicket->setEndTime(deactivateTime); - KisTicket* mainTicket = m_toolsMap[id].ticket.data(); + KisTelemetryTicket* mainTicket = m_toolsMap[id].ticket.data(); KisTimeTicket* mainTimeTicket = dynamic_cast(mainTicket); if (mainTimeTicket) { m_toolsMap[id].countUse++; mainTimeTicket->addMSecs(timeTicket->useTimeMSeconds()); } } m_currentTools.remove(id); } diff --git a/plugins/telemetry/kis_toolsinfosource.h b/plugins/telemetry/tools_info_source.h similarity index 84% rename from plugins/telemetry/kis_toolsinfosource.h rename to plugins/telemetry/tools_info_source.h index 543506d458..76c6f6082f 100644 --- a/plugins/telemetry/kis_toolsinfosource.h +++ b/plugins/telemetry/tools_info_source.h @@ -1,65 +1,65 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library 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 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISUSERFEEDBACK_TOOLSINFOSOURCE_H #define KISUSERFEEDBACK_TOOLSINFOSOURCE_H #include "abstractdatasource.h" #include "kuserfeedbackcore_export.h" #include #include #include #include #include #include #include #include "kis_telemetry_abstract.h" #include "kis_telemetry_tickets.h" -namespace KisUserFeedback { +namespace UserFeedback { /*! Data source reporting the type and amount of CPUs. * * The default telemetry mode for this source is Provider::DetailedSystemInformation. */ -class ToolsInfoSource : public KUserFeedback::AbstractDataSource { +class TelemetryToolsInfoSource : public KUserFeedback::AbstractDataSource { public: - ToolsInfoSource(); + TelemetryToolsInfoSource(); QString description() const override; QVariant data() override; - void activateTool(QSharedPointer ticket); + void activateTool(QSharedPointer ticket); void deactivateTool(QString id); private: struct toolInfo{ - QSharedPointer ticket; + QSharedPointer ticket; int countUse ; }; private: QVariantList m_tools; QMap m_toolsMap; - QMap > m_currentTools; + QMap > m_currentTools; QMutex m_mutex; }; } #endif // KISUSERFEEDBACK_TOOLSINFOSOURCE_H