Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage statistics plugin #339

Merged
merged 8 commits into from
Dec 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ground/gcs/src/plugins/plugins.pro
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ plugin_sysalarmsmessaging.depends += plugin_uavobjects
plugin_sysalarmsmessaging.depends += plugin_uavtalk
SUBDIRS += plugin_sysalarmsmessaging

# Usage Statistics plugin
plugin_usagestatsgadget.subdir = usagestatsgadget
plugin_usagestatsgadget.depends = plugin_coreplugin
plugin_usagestatsgadget.depends += plugin_uploader
plugin_usagestatsgadget.depends += plugin_uavobjectutil
SUBDIRS += plugin_usagestatsgadget

############################
# Board plugins
# Those plugins define supported board models: each board manufacturer
Expand Down
4 changes: 2 additions & 2 deletions ground/gcs/src/plugins/uploader/uploader.pri
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include(uploaderng_dependencies.pri)
include(uploader_dependencies.pri)

LIBS *= -l$$qtLibraryName(Uploaderng)
LIBS *= -l$$qtLibraryName(Uploader)
12 changes: 12 additions & 0 deletions ground/gcs/src/plugins/uploader/uploader_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@
#define UPLOADER_GLOBAL_H

#include <QtCore/qglobal.h>
#include <QPointer>
#include <coreplugin/boardmanager.h>

namespace uploader
{
typedef enum { WAITING_CONNECT, WAITING_DISCONNECT, FAILURE, FAILURE_FILENOTFOUND, LOADING_FW, SUCCESS, DISCONNECTED, BOOTING, HALTING, RESCUING, BL_FROM_HALT, BL_FROM_RESCUE, CONNECTED_TO_TELEMETRY, UPLOADING_FW, UPLOADING_DESC, DOWNLOADING_PARTITION, UPLOADING_PARTITION, DOWNLOADING_PARTITION_BUNDLE, UPLOADING_PARTITION_BUNDLE} UploaderStatus;
}
struct deviceInfo
{
QPointer<Core::IBoardType> board;
QString bl_version;
QString max_code_size;
QString cpu_serial;
QString hw_revision;
};

#if defined(UPLOADER_LIBRARY)
# define UPLOADER_EXPORT Q_DECL_EXPORT
#else
Expand Down
1 change: 1 addition & 0 deletions ground/gcs/src/plugins/uploader/uploadergadgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Core::IUAVGadget* UploaderGadgetFactory::createGadget(QWidget *parent)
isautocapable=gadgetWidget->autoUpdateCapable();
connect(this,SIGNAL(autoUpdate()),gadgetWidget,SLOT(autoUpdate()));
connect(gadgetWidget,SIGNAL(autoUpdateSignal(UploaderStatus, QVariant)),this,SIGNAL(autoUpdateSignal(UploaderStatus ,QVariant)));
connect(gadgetWidget, SIGNAL(newBoardSeen(deviceInfo,deviceDescriptorStruct)), this, SIGNAL(newBoardSeen(deviceInfo,deviceDescriptorStruct)));
return new UploaderGadget(QString("Uploader"), gadgetWidget, parent);
}

Expand Down
2 changes: 2 additions & 0 deletions ground/gcs/src/plugins/uploader/uploadergadgetfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <coreplugin/iuavgadgetfactory.h>
#include "uploader_global.h"
#include "uavobjectutil/devicedescriptorstruct.h"

namespace Core {
class IUAVGadget;
Expand All @@ -55,6 +56,7 @@ class UPLOADER_EXPORT UploaderGadgetFactory : public Core::IUAVGadgetFactory
signals:
void autoUpdateSignal(UploaderStatus ,QVariant);
void autoUpdate();
void newBoardSeen(deviceInfo board, deviceDescriptorStruct device);
};

}
Expand Down
1 change: 1 addition & 0 deletions ground/gcs/src/plugins/uploader/uploadergadgetwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ void UploaderGadgetWidget::onAutopilotReady()
deviceDescriptorStruct device;
if(utilMngr->getBoardDescriptionStruct(device))
FirmwareOnDeviceUpdate(device, QString::number(utilMngr->getFirmwareCRC(), 16));
emit newBoardSeen(board, device);
}

/**
Expand Down
10 changes: 2 additions & 8 deletions ground/gcs/src/plugins/uploader/uploadergadgetwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@ typedef enum { STATUSICON_OK, STATUSICON_RUNNING, STATUSICON_FAIL, STATUSICON_IN
class UPLOADER_EXPORT UploaderGadgetWidget : public QWidget
{
Q_OBJECT
struct deviceInfo
{
QPointer<Core::IBoardType> board;
QString bl_version;
QString max_code_size;
QString cpu_serial;
QString hw_revision;
};

struct partitionStruc
{
QByteArray partitionData;
Expand All @@ -74,6 +67,7 @@ public slots:
void uploadFinish(bool);
void uploadProgress(UploaderStatus, QVariant);
void autoUpdateSignal(UploaderStatus, QVariant);
void newBoardSeen(deviceInfo board, deviceDescriptorStruct device);
private slots:
void onAutopilotConnect();
void onAutopilotDisconnect();
Expand Down
1 change: 1 addition & 0 deletions ground/gcs/src/plugins/usagestatsgadget/UsageStats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
11 changes: 11 additions & 0 deletions ground/gcs/src/plugins/usagestatsgadget/UsageStats.pluginspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<plugin name="UsageStats" version="1.0.0" compatVersion="1.0.0">
<vendor>dRonin</vendor>
<copyright>(C) 2015 dRonin</copyright>
<license>The GNU Public License (GPL) Version 3</license>
<description>Usage statistics gadget</description>
<url>http://dronin.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
<dependency name="Uploader" version="1.0.0"/>
</dependencyList>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include(../../plugins/uploader/uploader.pri)

17 changes: 17 additions & 0 deletions ground/gcs/src/plugins/usagestatsgadget/usagestatsgadget.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
QT += network
TEMPLATE = lib
TARGET = UsageStats
DEFINES += USAGESTATS_LIBRARY
include(usagestats_dependencies.pri)
HEADERS += \
usagestatsplugin.h \
usagestatsoptionpage.h
SOURCES += \
usagestatsplugin.cpp \
usagestatsoptionpage.cpp

OTHER_FILES += UsageStats.pluginspec \
UsageStats.json

FORMS += \
usagestatsoptionpage.ui
61 changes: 61 additions & 0 deletions ground/gcs/src/plugins/usagestatsgadget/usagestatsoptionpage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
******************************************************************************
* @file usagestatsoptionpage.cpp
* @author dRonin, http://dRonin.org/, Copyright (C) 2015
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup UsageStatsOptionPage
* @{
* @brief [Brief]
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, 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 General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "usagestatsoptionpage.h"
#include "ui_usagestatsoptionpage.h"
#include "usagestatsplugin.h"

UsageStatsOptionPage::UsageStatsOptionPage(QObject *parent) :
IOptionsPage(parent)
{
m_config=qobject_cast<UsageStatsPlugin *>(parent);
connect(this,SIGNAL(settingsUpdated()),m_config,SLOT(updateSettings()));
}
UsageStatsOptionPage::~UsageStatsOptionPage()
{
}
QWidget *UsageStatsOptionPage::createPage(QWidget *parent)
{

m_page = new Ui::UsageStatsOptionPage();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
m_page->cb_AllowSending->setChecked(m_config->getSendUsageStats());
m_page->cb_AllowPrivate->setChecked(m_config->getSendPrivateData());
return w;
}

void UsageStatsOptionPage::apply()
{
m_config->setSendUsageStats(m_page->cb_AllowSending->isChecked());
m_config->setSendPrivateData(m_page->cb_AllowPrivate->isChecked());
emit settingsUpdated();
}

void UsageStatsOptionPage::finish()
{
delete m_page;
}
68 changes: 68 additions & 0 deletions ground/gcs/src/plugins/usagestatsgadget/usagestatsoptionpage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
******************************************************************************
* @file usagestatsoptionpage.h
* @author dRonin, http://dRonin.org/, Copyright (C) 2015
* @addtogroup [Group]
* @{
* @addtogroup UsageStatsOptionPage
* @{
* @brief [Brief]
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, 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 General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef USAGESTATSOPTIONPAGE_H
#define USAGESTATSOPTIONPAGE_H

#include <QWidget>
#include "coreplugin/dialogs/ioptionspage.h"
#include <coreplugin/iconfigurableplugin.h>

class UsageStatsPlugin;
namespace Core {
class IUAVGadgetConfiguration;
}

namespace Ui {
class UsageStatsOptionPage;
}

using namespace Core;

class UsageStatsOptionPage : public IOptionsPage
{
Q_OBJECT
public:
UsageStatsOptionPage(QObject *parent = 0);
virtual ~UsageStatsOptionPage();

QString id() const { return QLatin1String("settings"); }
QString trName() const { return tr("settings"); }
QString category() const { return "Usage Statistics";}
QString trCategory() const { return "Usage Statistics"; }

QWidget *createPage(QWidget *parent);
void apply();
void finish();
signals:
void settingsUpdated();
private slots:
private:
Ui::UsageStatsOptionPage *m_page;
UsageStatsPlugin * m_config;
};

#endif // USAGESTATSOPTIONPAGE_H
109 changes: 109 additions & 0 deletions ground/gcs/src/plugins/usagestatsgadget/usagestatsoptionpage.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UsageStatsOptionPage</class>
<widget class="QWidget" name="UsageStatsOptionPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QCheckBox" name="cb_AllowSending">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="cb_AllowPrivate">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_AllowSending">
<property name="text">
<string>Allow sending application usage statistics to the project authors:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_AllowPrivate">
<property name="text">
<string>Allow sending private data (IP, FC CPU numbers):</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>cb_AllowSending</sender>
<signal>toggled(bool)</signal>
<receiver>label_AllowPrivate</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>95</y>
</hint>
<hint type="destinationlabel">
<x>107</x>
<y>204</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_AllowSending</sender>
<signal>toggled(bool)</signal>
<receiver>cb_AllowPrivate</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>95</y>
</hint>
<hint type="destinationlabel">
<x>301</x>
<y>204</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Loading