blob: 7a7ef83caf58e29ed2c74d95a8b66fdac785d06a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// Copyright 2007-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "Usage.h"
#include "ClientUser.h"
#include "LCD.h"
#include "NetworkConfig.h"
#include "OSInfo.h"
#include "Version.h"
#include "Global.h"
#include <QtCore/QTimer>
#include <QtNetwork/QHostAddress>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QtXml/QDomElement>
Usage::Usage(QObject *p) : QObject(p) {
qbReport.open(QBuffer::ReadWrite);
qdsReport.setDevice(&qbReport);
qdsReport.setVersion(QDataStream::Qt_4_4);
qdsReport << static_cast< unsigned int >(2);
// Wait 10 minutes (so we know they're actually using this), then...
QTimer::singleShot(60 * 10 * 1000, this, SLOT(registerUsage()));
}
void Usage::registerUsage() {
if (!Global::get().s.bUsage
|| Global::get().s.uiUpdateCounter == 0) // Only register usage if allowed by the user and first wizard run has finished
return;
QDomDocument doc;
QDomElement root = doc.createElement(QLatin1String("usage"));
doc.appendChild(root);
QDomElement tag;
QDomText t;
OSInfo::fillXml(doc, root);
tag = doc.createElement(QLatin1String("in"));
root.appendChild(tag);
t = doc.createTextNode(Global::get().s.qsAudioInput);
tag.appendChild(t);
tag = doc.createElement(QLatin1String("out"));
root.appendChild(tag);
t = doc.createTextNode(Global::get().s.qsAudioOutput);
tag.appendChild(t);
tag = doc.createElement(QLatin1String("lcd"));
root.appendChild(tag);
t = doc.createTextNode(QString::number(Global::get().lcd->hasDevices() ? 1 : 0));
tag.appendChild(t);
QBuffer *qb = new QBuffer();
qb->setData(doc.toString().toUtf8());
qb->open(QIODevice::ReadOnly);
QNetworkRequest req(QUrl(QLatin1String("https://usage-report.mumble.info/v1/report")));
Network::prepareRequest(req);
req.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml"));
QNetworkReply *rep = Global::get().nam->post(req, qb);
qb->setParent(rep);
connect(rep, SIGNAL(finished()), rep, SLOT(deleteLater()));
}
|