started to file updating for linux build

This commit is contained in:
leetthewire 2022-03-25 12:32:36 -07:00
parent 40ab540179
commit 39de79d3cd
6 changed files with 130 additions and 2 deletions

View file

@ -38,6 +38,7 @@ HEADERS += \
debug.h \
defines.h \
managementserver.h \
platforms/linux/leakdetector.h \
protocols/protocols_defs.h \
settings.h \
ui/notificationhandler.h \
@ -93,6 +94,7 @@ SOURCES += \
debug.cpp \
main.cpp \
managementserver.cpp \
platforms/linux/leakdetector.cpp \
protocols/protocols_defs.cpp \
settings.cpp \
ui/notificationhandler.cpp \
@ -191,6 +193,12 @@ macx {
linux:!android {
DEFINES += MVPN_LINUX
HEADERS += \
platforms/linux/linuxsystemtraynotificationhandler.h \
SOURCES += \
platforms/linux/linuxsystemtraynotificationhandler.cpp \
LIBS += /usr/lib/x86_64-linux-gnu/libcrypto.a
LIBS += /usr/lib/x86_64-linux-gnu/libssl.a

View file

@ -0,0 +1,75 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "leakdetector.h"
#include <QHash>
#include <QMutex>
#include <QObject>
#include <QTextStream>
#ifdef MVPN_DEBUG
static QMutex s_leakDetector;
QHash<QString, QHash<void*, uint32_t>> s_leaks;
#endif
LeakDetector::LeakDetector() {
#ifndef MVPN_DEBUG
qFatal("LeakDetector _must_ be created in debug builds only!");
#endif
}
LeakDetector::~LeakDetector() {
#ifdef MVPN_DEBUG
QTextStream out(stderr);
out << "== Mozilla VPN - Leak report ===================" << Qt::endl;
bool hasLeaks = false;
for (auto i = s_leaks.begin(); i != s_leaks.end(); ++i) {
QString className = i.key();
if (i->size() == 0) {
continue;
}
hasLeaks = true;
out << className << Qt::endl;
for (auto l = i->begin(); l != i->end(); ++l) {
out << " - ptr: " << l.key() << " size:" << l.value() << Qt::endl;
}
}
if (!hasLeaks) {
out << "No leaks detected." << Qt::endl;
}
#endif
}
#ifdef MVPN_DEBUG
void LeakDetector::logCtor(void* ptr, const char* typeName, uint32_t size) {
QMutexLocker lock(&s_leakDetector);
QString type(typeName);
if (!s_leaks.contains(type)) {
s_leaks.insert(type, QHash<void*, uint32_t>());
}
s_leaks[type].insert(ptr, size);
}
void LeakDetector::logDtor(void* ptr, const char* typeName, uint32_t size) {
QMutexLocker lock(&s_leakDetector);
QString type(typeName);
Q_ASSERT(s_leaks.contains(type));
QHash<void*, uint32_t>& leak = s_leaks[type];
Q_ASSERT(leak.contains(ptr));
Q_ASSERT(leak[ptr] == size);
leak.remove(ptr);
}
#endif

View file

@ -0,0 +1,41 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef LEAKDETECTOR_H
#define LEAKDETECTOR_H
#include <QObject>
#ifdef MVPN_DEBUG
# define MVPN_COUNT_CTOR(_type) \
do { \
static_assert(std::is_class<_type>(), \
"Token '" #_type "' is not a class type."); \
LeakDetector::logCtor((void*)this, #_type, sizeof(*this)); \
} while (0)
# define MVPN_COUNT_DTOR(_type) \
do { \
static_assert(std::is_class<_type>(), \
"Token '" #_type "' is not a class type."); \
LeakDetector::logDtor((void*)this, #_type, sizeof(*this)); \
} while (0)
#else
# define MVPN_COUNT_CTOR(_type)
# define MVPN_COUNT_DTOR(_type)
#endif
class LeakDetector {
public:
LeakDetector();
~LeakDetector();
#ifdef MVPN_DEBUG
static void logCtor(void* ptr, const char* typeName, uint32_t size);
static void logDtor(void* ptr, const char* typeName, uint32_t size);
#endif
};
#endif // LEAKDETECTOR_H

View file

@ -18,7 +18,7 @@ namespace {
Logger logger(LOG_LINUX, "LinuxSystemTrayNotificationHandler");
} // namespace
// static
//static
bool LinuxSystemTrayNotificationHandler::requiredCustomImpl() {
if (!QDBusConnection::sessionBus().isConnected()) {
return false;

View file

@ -27,7 +27,7 @@ NotificationHandler* NotificationHandler::create(QObject* parent) {
#else
# if defined(Q_OS_LINUX)
if (LinuxSystemTrayNotificationHandler::requiredCustomImpl()) {
if (LinuxSystemTrayNotificationHandler::requiredCustomImpl() == true) {
return new LinuxSystemTrayNotificationHandler(parent);
}
# endif

View file

@ -25,6 +25,10 @@
#include "../uilogic.h"
#ifdef __linux__
#include <math.h>
#endif
ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent):
PageLogicBase(logic, parent),
m_textEditShareOpenVpnCodeText{},