Compare commits

..

35 Commits

Author SHA1 Message Date
Dom Rodriguez
012a7dc055 [actions](stale): Add further configuration to GitHub Action - stale.
This commit fleshes out the messages and labels applied to stale
issuse/PRs, configures 'exempt' labels, and additionally the number of
days before a issue is marked stale/closed.

Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
2020-09-17 16:52:15 +01:00
walker0643
0699536382 Create stale.yml 2020-09-17 11:20:11 -04:00
Dom Rodriguez
c1d131fd38 Merge pull request #873 from debauchee/enhancement/style/editorconfig
[style](editorconfig): Commit initial EditorConfig config for code style
2020-09-14 23:04:06 +01:00
Dom Rodriguez
167a1075fa [style](editorconfig): Commit initial EditorConfig config for code style
Soon to be added: wiki page about expected code style for Barrier.
Also, docs when that's ready.

Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
2020-09-14 13:12:53 +01:00
Dom Rodriguez
9745df29cd Merge pull request #869 from NikoHD203/patch-1
Update gui_de.ts
2020-09-13 16:22:00 +01:00
NikoHD203
4aee34848e Update gui_de.ts
wrong grammar
2020-09-09 11:52:55 +02:00
Dom Rodriguez
5a02070b54 Remove old issue template
This is in relation to #856.

Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
2020-08-31 03:24:53 +01:00
Dom Rodriguez
b38f844dc0 Merge pull request #856 from debauchee/enhancement/github/templates/bug
Update issue templates
2020-08-31 03:24:06 +01:00
Dom Rodriguez
3804198105 Update issue templates
Our current templates do not use the latest GitHub templates, so this updates them. I have adjusted and removed some wording to make the template simpler, as I have found some users neglect to fill in the template, or partially fill it in. I hope this helps with the bug reporting process.
2020-08-28 22:13:51 +01:00
Povilas Kanapickas
600d31f29b Merge pull request #848 from chewi/TEST_ENV
Rename TEST_ENV macro to BARRIER_TEST_ENV
2020-08-23 14:25:48 +03:00
James Le Cuirot
1418196af1 Rename TEST_ENV macro to BARRIER_TEST_ENV
As requested in #846.
2020-08-22 19:25:35 +01:00
Povilas Kanapickas
c3aba1b20b Merge pull request #846 from chewi/tests
Add BARRIER_BUILD_TESTS and BARRIER_USE_EXTERNAL_GTEST CMake options
2020-08-22 21:21:11 +03:00
Povilas Kanapickas
7dbfa63a63 Merge pull request #847 from chewi/getenv
Replace all instances of C's getenv with C++'s std::getenv
2020-08-22 21:20:30 +03:00
James Le Cuirot
7aa110475e Replace all instances of C's getenv with C++'s std::getenv 2020-08-22 19:05:24 +01:00
James Le Cuirot
fa46480c35 Respect DISPLAY environment variable in XWindows tests
XWindowsScreenTests was failing under Gentoo's package manager. I have
also addressed this in XWindowsScreenSaverTests, which is currently
unused.
2020-08-22 17:36:55 +01:00
Povilas Kanapickas
b204520864 Merge pull request #832 from tom-tan/add-os-barrier-keymap-for-jis-kbd
Add key mappings for `Kana`, `Eisu_toggle` and `Muhenkan`
2020-08-22 13:47:35 +03:00
Povilas Kanapickas
d58a9fbe84 Merge pull request #803 from p12tic/crypto-cert-fixes
Regenerate server certificate when it is broken or has too small key size
2020-08-22 13:38:46 +03:00
James Le Cuirot
bd1db368b3 Add BARRIER_USE_EXTERNAL_GTEST CMake option to use external GTest 2020-08-21 23:13:58 +01:00
James Le Cuirot
4a031b8ce5 Add BARRIER_BUILD_TESTS CMake option to make tests optional 2020-08-21 22:56:57 +01:00
Tomoya Tanjo
4aefd64add Add missing comma 2020-08-12 18:33:32 +09:00
Tomoya Tanjo
0fdcf8b225 Add key mappings for Kana, Eisu and Muhenkan 2020-08-12 16:20:29 +09:00
Dom Rodriguez
d186548a53 Update Debian changelog to v2.3.3 2020-08-07 18:33:54 +01:00
Povilas Kanapickas
36ae769987 Merge pull request #818 from tom-tan/add-eisu-muhenkan
Add key entries for `Eisu_toggle` and `Muhenkan`
2020-08-07 10:57:57 +03:00
Dom Rodriguez
9a9d22105c Merge pull request #822 from M1cha/kbd-backlight
add support for keyboard backlight media keys
2020-08-04 20:53:02 +01:00
Dom Rodriguez
6b71871204 [Build]: Bump Build.properties 2020-08-04 15:50:49 +01:00
Michael Zimmermann
7452b64482 add support for keyboard backlight media keys
I've tested this with a german Apple Magic Keyboard with Numeric Keypad (Space Gray)
connected to a non-Apple Linux Laptop running Arch Linux.
keycode 237 (keysym 0x1008ff06, XF86KbdBrightnessDown)
keycode 238 (keysym 0x1008ff05, XF86KbdBrightnessUp)
2020-08-01 13:28:48 +02:00
Tomoya Tanjo
4d32e29275 Add Eisu_toggle and Muhenkan keys 2020-07-27 22:04:00 +09:00
Povilas Kanapickas
c815abf0e8 gui: Show certificate-related info in logs 2020-07-19 11:56:18 +03:00
Povilas Kanapickas
345bb4b62b gui: Regenerate certificate if it's invalid or the key is too small 2020-07-19 11:56:17 +03:00
Povilas Kanapickas
7210bfa615 gui: Extract certificate path generation to separate functions 2020-07-19 11:56:16 +03:00
Povilas Kanapickas
93ef15774b gui: Don't store openssl output as state of the object 2020-07-19 11:56:15 +03:00
Povilas Kanapickas
bd3a8be956 net: Always report the filename of the cert that fails to load 2020-07-19 11:56:14 +03:00
Povilas Kanapickas
3d0186695f net: Simplify error reporting 2020-07-19 11:56:13 +03:00
Dom Rodriguez
bbd1accb93 Merge pull request #797 from maxiberta/short-tags
Shorten snap version on tagged revisions
2020-07-14 23:39:54 +01:00
Maximiliano Bertacchini
ef769d4802 Shorten snap version on tagged revisions 2020-07-14 18:58:52 -03:00
51 changed files with 441 additions and 128 deletions

9
.editorconfig Normal file
View File

@@ -0,0 +1,9 @@
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

View File

@@ -1,30 +0,0 @@
### Operating Systems ###
Server: microOS Tiara
Client: Applesoft Windy OS 10
**READ ME, DELETE ME**: On Windows, hold the Windows key and press 'r', type 'winver' and hit return to get your OS version. On Mac, hit the Apple menu (top left of the screen) and check 'About this Mac'. Linux users... you know what you're using ;)
### Barrier Version ###
1.9.π
**READ ME, DELETE ME**: Go to the 'Help' (on Windows) or 'Barrier' (on macOS) menu and then 'About Barrier' to check your version. Verify that you are using the same version across all of your machines, and that your issue still occurs with the latest release available at https://github.com/debauchee/barrier/
### Steps to reproduce bug ###
**READ ME, DELETE ME**: Try to be succinct. If your bug is intermittent, try and describe what you're doing when it happens most.
1. Click things.
2. Type things.
3. Bug occurs.
4. ...
### Other info ###
* When did the problem start to occur? When I...
* Is there a way to work around it? No/Yes, you can...
* Does this bug prevent you from using Barrier entirely? Yes/No
Put anything else you can think of here.

36
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,36 @@
---
name: Bug report
about: Please fill in this template as much as you can, to help us, help you.
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
Please do not link to image hosting sites, as these can be ephemeral. Instead, attach them to the issue.
**Desktop (please complete the following information):**
- OS: [e.g. Windows]
- Barrier version [e.g 2.3.3]
**Additional context**
Add any other context about the problem here.

30
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Mark stale issues and pull requests
on:
schedule:
- cron: "30 1 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions."
stale-pr-message: "This PR has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions."
close-issue-message: "This issue will now be closed due to inactivty. It may be reopened if the demand indicates it should be."
close-pr-message: "This PR will now be closed due to inactivty. It may be reopened if the demand indicates it should be."
days-before-stale: 60
days-before-close: 7
stale-issue-label: "no-issue-activity"
stale-pr-label: "no-pr-activity"
exempt-issue-labels: "work-in-progress,security,critical"
exempt-pr-labels: "awaiting-approval,work-in-progress"

View File

@@ -3,5 +3,5 @@
#
BARRIER_VERSION_MAJOR = 2
BARRIER_VERSION_MINOR = 3
BARRIER_VERSION_PATCH = 2
BARRIER_VERSION_STAGE = snapshot
BARRIER_VERSION_PATCH = 3
BARRIER_VERSION_STAGE = release

View File

@@ -20,6 +20,8 @@ project (barrier C CXX)
option (BARRIER_BUILD_GUI "Build the GUI" ON)
option (BARRIER_BUILD_INSTALLER "Build the installer" ON)
option (BARRIER_BUILD_TESTS "Build the tests" ON)
option (BARRIER_USE_EXTERNAL_GTEST "Use external installation of Google Test framework" OFF)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (CMAKE_CXX_STANDARD 14)
@@ -49,7 +51,6 @@ else()
endif()
set (libs)
include_directories (BEFORE SYSTEM ./ext/gtest/include)
if (UNIX)
if (NOT APPLE)

152
debian/changelog vendored
View File

@@ -1,3 +1,155 @@
barrier (2.3.3) UNRELEASED; urgency=medium
[ Aaron Bieber ]
* tell build system about openbsd
[ Tetja Rediske ]
* make non-gui variants build without avahi
[ Erik Nordstrøm ]
* Replace hard-coded names of build directory in build_installer.sh script for macOS with looking at the location of the script by the script itself when it is run. This makes it possible to have differently named build dirs for debug and release builds, and without restricting what each of those directories must be named.
* Remove shell script that changes directory and then executes barrier on macOS, and execute barrier directly instead.
* Add settings in the Info.plist file that enable high-DPI support on macOS.
[ Daniel Seither ]
* Remove unused variables
* IpcLogOutputter: Put member initializers in execution order
* OSXDragView: Get rid of uninitialized variable warning
* Add override specifiers
* Let tray image blend into macOS menu bar
[ Vasily Galkin ]
* Man page: fix incorrect name of user conf file in barriers.1
[ Keegan Quinn ]
* Cast values to fix build errors on OS X 10.11.
[ Maximiliano Bertacchini ]
* Update readme with mention of the snap package.
[ Javier Candeira ]
* Fix #503 - Clarify on README how to report issues
[ Micael Jarniac ]
* Build status badges added to a table
[ Maximiliano Bertacchini ]
* Add build-essential to the snap's build deps.
* Explicitly disable wayland support in the snap.
* Add comment on snap env var
[ Vasily Galkin ]
* Fix infinite loop on fast TCP disconnection
[ Dom Rodriguez ]
* README: Add OpenBSD to list of supported OSes
[ Åke Engelbrektson ]
* Update gui_sv.ts
[ the-wes ]
* Add more detailed description of what Barrier does
[ James Le Cuirot ]
* Use -pthread flag and simplify pthread build logic
* Only require Qt5 when building the GUI
[ Tomáš Chvátal ]
* Fix desktop file Categories to match standard
[ Chris Simons ]
* Add script that uses macdeployqt instead of `reref_dylibs.sh` shell script to create the `.app` bundle
* Use `build_dist.sh` in CMake instead of `build_installer.sh` Have CMake always build a bundle, the `build_dist.sh` script will only build a dmg if the build type is "Release"
* Add warnings for users manually running `build_installer.sh` and `reref_dylibs.sh` manually
* Homebrew (Ruby) throws an error when it gets `SIGPIPE` from the `--max-count` on `grep`.
* added barrierc and barriers to macdeployqt targets
* Change MacOS Build Steps
* Fix TIS/TSM in logs
* Elevate XSocketAddressInUse to ERROR
* Allow selecting Fingerprint Qlabel
* replace tabs with spaces
* Change log level on several status messages (Fixes #652, Fixes #516)
[ Ben Plessinger ]
* A few more log cleanups
[ Vasily Galkin ]
* Remove unused IEventQueue::isEmpty() method to simplify code understanding
[ Povilas Kanapickas ]
* XWindowsEventQueueBuffer: Fix delays when waiting for new events
[ Jonathan Martens ]
* Fix Auto config missing hostname prompt #704
[ Vasily Galkin ]
* Windows 8+: make waiting for messages correspond to emptiness check
[ Povilas Kanapickas ]
* gui: Use enum class to scope enum values
* lib/client: Use std::string directly instead of String typedef
* lib/arch: Use std::string directly instead of String typedef
* lib/net: Use std::string directly instead of String typedef
* lib/server: Use std::string directly instead of String typedef
* lib/base: Use std::string directly instead of String typedef
* lib/ipc: Use std::string directly instead of String typedef
* lib/net: Add missing include
* lib/platform: Use std::string directly instead of String typedef
* test: Enable building of tests
* test: Reduce the number of implicit include directories
* test: Remove unresolved merge conflict markers
* test: Fix referenced library name
* test: Update to new APIs
* tests: Fix crash in XWindowsKeyStateTests
* test: Fix undefined behavior of deleting incomplete type
* tests: Disable test that depends on external state
* Use noexcept instead of exception specifications
* lib/common: Remove no longer used stdexcept.h
[ Jonathan Martens ]
* Make connection message a NOTE for consistency
[ zhexiwang ]
* Added toggleScreen function, using hot key to loop through all screens. Comparing to switchToScreen, it is more handy since the user only need to hit one hotkey.
[ GeorgH93 ]
* Fix build on Windows
* Keep errorlevel
[ Povilas Kanapickas ]
* Revert "Make connection message a NOTE for consistency"
[ Chris Simons ]
* add comments explaining the use of CLOG_PRINT
[ Dom Rodriguez ]
* Remove ext/gtest, ext/gmock to replace with Git submodule
* Add gtest/gmock framework, locked at 1.6.0
* Fix CI infrastructure (.bat/.sh) to initialise Git submodules before build
[ Maximiliano Bertacchini ]
* Fix snap build failing to initialize submodules.
[ Niklas Hambüchen ]
* ui: Settings: Explain what "double tap" means
[ Dom Rodriguez ]
* Prepare for v2.3.3 release
[ Maximiliano Bertacchini ]
* Shorten snap version on tagged revisions
[ Tomoya Tanjo ]
* Add Eisu_toggle and Muhenkan keys
[ Michael Zimmermann ]
* add support for keyboard backlight media keys
[ Dom Rodriguez ]
* [Build]: Bump Build.properties
-- root <root@873b8d543aab> Fri, 07 Aug 2020 16:25:54 +0000
barrier (2.3.2) disco; urgency=medium
[ walker0643 ]

View File

@@ -1,7 +1,7 @@
name: barrier
base: core18
version: master
version-script: git describe --tags --long | sed "s/^v//"
version-script: git describe --tags | sed "s/^v//"
adopt-info: appstream-flathub
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

View File

@@ -19,7 +19,10 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/lib)
add_subdirectory(lib)
add_subdirectory(cmd)
add_subdirectory(test)
if (BARRIER_BUILD_TESTS)
add_subdirectory(test)
endif()
if (BARRIER_BUILD_GUI)
add_subdirectory(gui)

View File

@@ -22,7 +22,7 @@ add_executable (barrier WIN32
include_directories (./src)
target_link_libraries (barrier Qt5::Core Qt5::Widgets Qt5::Network)
target_link_libraries (barrier Qt5::Core Qt5::Widgets Qt5::Network ${OPENSSL_LIBS})
target_compile_definitions (barrier PRIVATE -DBARRIER_VERSION_STAGE="${BARRIER_VERSION_STAGE}")
target_compile_definitions (barrier PRIVATE -DBARRIER_REVISION="${BARRIER_REVISION}")

View File

@@ -984,7 +984,7 @@ Klicken sie doppelt auf eine Anzeige um die Einstellungen zu bearbeiten.</transl
<message>
<location filename="res/ServerConfigDialogBase.ui" line="419"/>
<source>&amp;Check clients every</source>
<translation type="finished">Prüfe auf Meldungen vom &amp;Client aller</translation>
<translation type="finished">Prüfe auf Meldungen vom &amp;Client alle</translation>
</message>
<message>
<location filename="res/ServerConfigDialogBase.ui" line="470"/>
@@ -1408,4 +1408,4 @@ Server response:
<translation type="unfinished"></translation>
</message>
</context>
</TS>
</TS>

View File

@@ -949,6 +949,10 @@ void MainWindow::updateSSLFingerprint()
{
if (m_AppConfig->getCryptoEnabled() && m_pSslCertificate == nullptr) {
m_pSslCertificate = new SslCertificate(this);
connect(m_pSslCertificate, &SslCertificate::info, [&](QString info)
{
appendLogInfo(info);
});
m_pSslCertificate->generateCertificate();
}
if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) {

View File

@@ -23,6 +23,12 @@
#include <QDir>
#include <QCoreApplication>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
static const char kCertificateLifetime[] = "365";
static const char kCertificateSubjectInfo[] = "/CN=Barrier";
static const char kCertificateFilename[] = "Barrier.pem";
@@ -37,13 +43,13 @@ static const char kConfigFile[] = "barrier.conf";
SslCertificate::SslCertificate(QObject *parent) :
QObject(parent)
{
m_ProfileDir = QString::fromStdString(DataDirectories::profile());
if (m_ProfileDir.isEmpty()) {
m_ProfileDir = DataDirectories::profile();
if (m_ProfileDir.empty()) {
emit error(tr("Failed to get profile directory."));
}
}
bool SslCertificate::runTool(const QStringList& args)
std::pair<bool, std::string> SslCertificate::runTool(const QStringList& args)
{
QString program;
#if defined(Q_OS_WIN)
@@ -66,11 +72,12 @@ bool SslCertificate::runTool(const QStringList& args)
process.start(program, args);
bool success = process.waitForStarted();
std::string output;
QString standardError;
if (success && process.waitForFinished())
{
m_ToolOutput = process.readAllStandardOutput().trimmed();
output = process.readAllStandardOutput().trimmed().toStdString();
standardError = process.readAllStandardError().trimmed();
}
@@ -82,26 +89,18 @@ bool SslCertificate::runTool(const QStringList& args)
.arg(program)
.arg(process.exitCode())
.arg(standardError.isEmpty() ? "Unknown" : standardError));
return false;
return {false, output};
}
return true;
return {true, output};
}
void SslCertificate::generateCertificate()
{
QString sslDirPath = QString("%1%2%3")
.arg(m_ProfileDir)
.arg(QDir::separator())
.arg(kSslDir);
QString filename = QString("%1%2%3")
.arg(sslDirPath)
.arg(QDir::separator())
.arg(kCertificateFilename);
auto filename = QString::fromStdString(getCertificatePath());
QFile file(filename);
if (!file.exists()) {
if (!file.exists() || !isCertificateValid(filename)) {
QStringList arguments;
// self signed certificate
@@ -123,7 +122,7 @@ void SslCertificate::generateCertificate()
arguments.append("-newkey");
arguments.append("rsa:2048");
QDir sslDir(sslDirPath);
QDir sslDir(QString::fromStdString(getCertificateDirectory()));
if (!sslDir.exists()) {
sslDir.mkpath(".");
}
@@ -136,7 +135,7 @@ void SslCertificate::generateCertificate()
arguments.append("-out");
arguments.append(filename);
if (!runTool(arguments)) {
if (!runTool(arguments).first) {
return;
}
@@ -158,21 +157,90 @@ void SslCertificate::generateFingerprint(const QString& certificateFilename)
arguments.append("-in");
arguments.append(certificateFilename);
if (!runTool(arguments)) {
auto ret = runTool(arguments);
bool success = ret.first;
std::string output = ret.second;
if (!success) {
return;
}
// find the fingerprint from the tool output
int i = m_ToolOutput.indexOf("=");
if (i != -1) {
auto i = output.find_first_of('=');
if (i != std::string::npos) {
i++;
QString fingerprint = m_ToolOutput.mid(
i, m_ToolOutput.size() - i);
auto fingerprint = output.substr(
i, output.size() - i);
Fingerprint::local().trust(fingerprint, false);
Fingerprint::local().trust(QString::fromStdString(fingerprint), false);
emit info(tr("SSL fingerprint generated."));
}
else {
emit error(tr("Failed to find SSL fingerprint."));
}
}
std::string SslCertificate::getCertificatePath()
{
return getCertificateDirectory() + QDir::separator().toLatin1() + kCertificateFilename;
}
std::string SslCertificate::getCertificateDirectory()
{
return m_ProfileDir + QDir::separator().toLatin1() + kSslDir;
}
bool SslCertificate::isCertificateValid(const QString& path)
{
OpenSSL_add_all_algorithms();
ERR_load_BIO_strings();
ERR_load_crypto_strings();
BIO* bio = BIO_new(BIO_s_file());
auto ret = BIO_read_filename(bio, path.toStdString().c_str());
if (!ret) {
emit info(tr("Could not read from default certificate file."));
BIO_free_all(bio);
return false;
}
X509* cert = PEM_read_bio_X509(bio, NULL, 0, NULL);
if (!cert) {
emit info(tr("Error loading default certificate file to memory."));
BIO_free_all(bio);
return false;
}
EVP_PKEY* pubkey = X509_get_pubkey(cert);
if (!pubkey) {
emit info(tr("Default certificate key file does not contain valid public key"));
X509_free(cert);
BIO_free_all(bio);
return false;
}
auto type = EVP_PKEY_type(EVP_PKEY_id(pubkey));
if (type != EVP_PKEY_RSA && type != EVP_PKEY_DSA) {
emit info(tr("Public key in default certificate key file is not RSA or DSA"));
EVP_PKEY_free(pubkey);
X509_free(cert);
BIO_free_all(bio);
return false;
}
auto bits = EVP_PKEY_bits(pubkey);
if (bits < 2048) {
// We could have small keys in old barrier installations
emit info(tr("Public key in default certificate key file is too small."));
EVP_PKEY_free(pubkey);
X509_free(cert);
BIO_free_all(bio);
return false;
}
EVP_PKEY_free(pubkey);
X509_free(cert);
BIO_free_all(bio);
return true;
}

View File

@@ -18,6 +18,7 @@
#pragma once
#include <QObject>
#include <string>
class SslCertificate : public QObject
{
@@ -35,10 +36,13 @@ signals:
void generateFinished();
private:
bool runTool(const QStringList& args);
std::pair<bool, std::string> runTool(const QStringList& args);
void generateFingerprint(const QString& certificateFilename);
std::string getCertificatePath();
std::string getCertificateDirectory();
bool isCertificateValid(const QString& path);
private:
QString m_ProfileDir;
QString m_ToolOutput;
std::string m_ProfileDir;
};

View File

@@ -61,7 +61,7 @@ execSelfNonDaemonized()
}
bool alreadyDaemonized() {
return getenv("_BARRIER_DAEMONIZED") != NULL;
return std::getenv("_BARRIER_DAEMONIZED") != NULL;
}
#endif

View File

@@ -24,7 +24,9 @@
#include "common/stdset.h"
#include "common/stdvector.h"
#ifdef BARRIER_TEST_ENV
#include <gtest/gtest_prod.h>
#endif
namespace barrier {
@@ -327,6 +329,7 @@ public:
//@}
private:
#ifdef BARRIER_TEST_ENV
FRIEND_TEST(KeyMapTests,
findBestKey_requiredDown_matchExactFirstItem);
FRIEND_TEST(KeyMapTests,
@@ -340,6 +343,7 @@ private:
FRIEND_TEST(KeyMapTests,
findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem);
FRIEND_TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch);
#endif
private:
//! Ways to synthesize a key

View File

@@ -42,7 +42,7 @@ public:
Screen(IPlatformScreen* platformScreen, IEventQueue* events);
virtual ~Screen();
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
Screen() : m_mock(true) { }
#endif

View File

@@ -43,6 +43,7 @@ const KeyNameMapEntry kKeyNameMap[] = {
{ "Control_R", kKeyControl_R },
{ "Delete", kKeyDelete },
{ "Down", kKeyDown },
{ "EisuToggle", kKeyEisuToggle },
{ "Eject", kKeyEject },
{ "End", kKeyEnd },
{ "Escape", kKeyEscape },
@@ -89,6 +90,7 @@ const KeyNameMapEntry kKeyNameMap[] = {
{ "Hyper_L", kKeyHyper_L },
{ "Hyper_R", kKeyHyper_R },
{ "Insert", kKeyInsert },
{ "Kana", kKeyKana },
{ "KP_0", kKeyKP_0 },
{ "KP_1", kKeyKP_1 },
{ "KP_2", kKeyKP_2 },
@@ -130,6 +132,7 @@ const KeyNameMapEntry kKeyNameMap[] = {
{ "Menu", kKeyMenu },
{ "Meta_L", kKeyMeta_L },
{ "Meta_R", kKeyMeta_R },
{ "Muhenkan", kKeyMuhenkan },
{ "NumLock", kKeyNumLock },
{ "PageDown", kKeyPageDown },
{ "PageUp", kKeyPageUp },

View File

@@ -109,11 +109,13 @@ static const KeyID kKeyPause = 0xEF13; /* Pause, hold */
static const KeyID kKeyScrollLock = 0xEF14;
static const KeyID kKeySysReq = 0xEF15;
static const KeyID kKeyEscape = 0xEF1B;
static const KeyID kKeyMuhenkan = 0xEF22; /* Cancel Conversion */
static const KeyID kKeyHenkan = 0xEF23; /* Start/Stop Conversion */
static const KeyID kKeyKana = 0xEF26; /* Kana */
static const KeyID kKeyHiraganaKatakana = 0xEF27; /* Hiragana/Katakana toggle */
static const KeyID kKeyZenkaku = 0xEF2A; /* Zenkaku/Hankaku */
static const KeyID kKeyKanzi = 0xEF2A; /* Kanzi */
static const KeyID kKeyEisuToggle = 0xEF30; /* Alphanumeric toggle */
static const KeyID kKeyHangul = 0xEF31; /* Hangul */
static const KeyID kKeyHanja = 0xEF34; /* Hanja */
static const KeyID kKeyDelete = 0xEFFF; /* Delete, rubout */
@@ -284,6 +286,8 @@ static const KeyID kKeyAppUser1 = 0xE0B6;
static const KeyID kKeyAppUser2 = 0xE0B7;
static const KeyID kKeyBrightnessDown = 0xE0B8;
static const KeyID kKeyBrightnessUp = 0xE0B9;
static const KeyID kKeyKbdBrightnessDown = 0xE0BA;
static const KeyID kKeyKbdBrightnessUp = 0xE0BB;
static const KeyID kKeyMissionControl = 0xE0C0;
static const KeyID kKeyLaunchpad = 0xE0C1;

View File

@@ -59,7 +59,7 @@ public:
// sending dragging information to server
void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
void handleDataForTest() { handleData(Event(), NULL); }
#endif

View File

@@ -18,7 +18,7 @@
#include "../DataDirectories.h"
#include <unistd.h> // sysconf
#include <stdlib.h> // getenv
#include <cstdlib> // getenv
#include <sys/types.h> // getpwuid(_r)
#include <pwd.h> // getpwuid(_r)
@@ -63,7 +63,7 @@ static std::string profile_basedir()
#ifdef WINAPI_XWINDOWS
// linux/bsd adheres to freedesktop standards
// https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
const char* dir = getenv("XDG_DATA_HOME");
const char* dir = std::getenv("XDG_DATA_HOME");
if (dir != NULL)
return dir;
return unix_home() + "/.local/share";

View File

@@ -82,7 +82,7 @@ private:
ClientList m_clients;
mutable std::mutex m_clientsMutex;
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
public:
IpcServer() :
m_mock(true),

View File

@@ -329,7 +329,7 @@ SecureSocket::initSsl(bool server)
initContext(server);
}
bool SecureSocket::loadCertificates(std::string& filename)
bool SecureSocket::loadCertificates(const std::string& filename)
{
if (filename.empty()) {
showError("ssl certificate is not specified");
@@ -341,9 +341,7 @@ bool SecureSocket::loadCertificates(std::string& filename)
file.close();
if (!exist) {
std::string errorMsg("ssl certificate doesn't exist: ");
errorMsg.append(filename);
showError(errorMsg.c_str());
showError("ssl certificate doesn't exist: " + filename);
return false;
}
}
@@ -351,19 +349,19 @@ bool SecureSocket::loadCertificates(std::string& filename)
int r = 0;
r = SSL_CTX_use_certificate_file(m_ssl->m_context, filename.c_str(), SSL_FILETYPE_PEM);
if (r <= 0) {
showError("could not use ssl certificate");
showError("could not use ssl certificate: " + filename);
return false;
}
r = SSL_CTX_use_PrivateKey_file(m_ssl->m_context, filename.c_str(), SSL_FILETYPE_PEM);
if (r <= 0) {
showError("could not use ssl private key");
showError("could not use ssl private key: " + filename);
return false;
}
r = SSL_CTX_check_private_key(m_ssl->m_context);
if (!r) {
showError("could not verify ssl private key");
showError("could not verify ssl private key: " + filename);
return false;
}
@@ -403,7 +401,7 @@ SecureSocket::initContext(bool server)
SSL_CTX_set_options(m_ssl->m_context, SSL_OP_NO_SSLv3);
if (m_ssl->m_context == NULL) {
showError();
showError("");
}
}
@@ -618,16 +616,15 @@ SecureSocket::checkResult(int status, int& retry)
if (isFatal()) {
retry = 0;
showError();
showError("");
disconnect();
}
}
void
SecureSocket::showError(const char* reason)
void SecureSocket::showError(const std::string& reason)
{
if (reason != NULL) {
LOG((CLOG_ERR "%s", reason));
if (!reason.empty()) {
LOG((CLOG_ERR "%s", reason.c_str()));
}
std::string error = getError();

View File

@@ -55,7 +55,7 @@ public:
EJobResult doRead() override;
EJobResult doWrite() override;
void initSsl(bool server);
bool loadCertificates(std::string& CertFile);
bool loadCertificates(const std::string& filename);
private:
// SSL
@@ -65,7 +65,7 @@ private:
int secureConnect(int s);
bool showCertificate();
void checkResult(int n, int& retry);
void showError(const char* reason = NULL);
void showError(const std::string& reason);
std::string getError();
void disconnect();
void formatFingerprint(std::string& fingerprint, bool hex = true, bool separator = true);

View File

@@ -69,7 +69,7 @@ const KeyID MSWindowsKeyState::s_virtualKey[] =
/* 0x01a */ { kKeyNone }, // undefined
/* 0x01b */ { kKeyEscape }, // VK_ESCAPE
/* 0x01c */ { kKeyHenkan }, // VK_CONVERT
/* 0x01d */ { kKeyNone }, // VK_NONCONVERT
/* 0x01d */ { kKeyMuhenkan }, // VK_NONCONVERT
/* 0x01e */ { kKeyNone }, // VK_ACCEPT
/* 0x01f */ { kKeyNone }, // VK_MODECHANGE
/* 0x020 */ { kKeyNone }, // VK_SPACE

View File

@@ -122,7 +122,11 @@ static const KeyEntry s_controlKeys[] = {
{ kKeyMissionControl, s_missionControlVK },
{ kKeyLaunchpad, s_launchpadVK },
{ kKeyBrightnessUp, s_brightnessUp },
{ kKeyBrightnessDown, s_brightnessDown }
{ kKeyBrightnessDown, s_brightnessDown },
// JIS keyboards only
{ kKeyEisuToggle, kVK_JIS_Eisu },
{ kKeyKana, kVK_JIS_Kana }
};

View File

@@ -136,7 +136,7 @@ private:
bool m_lock;
};
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
public: // yuck
#endif
typedef std::vector<KeyModifierMask> KeyModifierMaskList;
@@ -169,7 +169,7 @@ private:
// autorepeat state
XKeyboardState m_keyboardState;
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
public:
SInt32 group() const { return m_group; }
void group(const SInt32& group) { m_group = group; }

View File

@@ -877,7 +877,7 @@ XWindowsScreen::openDisplay(const char* displayName)
{
// get the DISPLAY
if (displayName == NULL) {
displayName = getenv("DISPLAY");
displayName = std::getenv("DISPLAY");
if (displayName == NULL) {
displayName = ":0.0";
}

View File

@@ -1250,7 +1250,7 @@ XK_uhorn
// map "Internet" keys to KeyIDs
static const KeySym s_map1008FF[] =
{
/* 0x00 */ 0, 0, kKeyBrightnessUp, kKeyBrightnessDown, 0, 0, 0, 0,
/* 0x00 */ 0, 0, kKeyBrightnessUp, kKeyBrightnessDown, 0, kKeyKbdBrightnessUp, kKeyKbdBrightnessDown, 0,
/* 0x08 */ 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x10 */ 0, kKeyAudioDown, kKeyAudioMute, kKeyAudioUp,
/* 0x14 */ kKeyAudioPlay, kKeyAudioStop, kKeyAudioPrev, kKeyAudioNext,

View File

@@ -174,7 +174,7 @@ public:
Config(IEventQueue* events);
virtual ~Config();
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
Config() : m_inputFilter(NULL) { }
#endif

View File

@@ -333,7 +333,7 @@ public:
InputFilter(const InputFilter&);
virtual ~InputFilter();
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
InputFilter() : m_primaryClient(NULL) { }
#endif

View File

@@ -37,7 +37,7 @@ public:
PrimaryClient(const std::string& name, barrier::Screen* screen);
~PrimaryClient();
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
PrimaryClient() : BaseClientProxy("") { }
#endif

View File

@@ -110,7 +110,7 @@ public:
barrier::Screen* screen, IEventQueue* events, ServerArgs const& args);
~Server();
#ifdef TEST_ENV
#ifdef BARRIER_TEST_ENV
Server() : m_mock(true), m_config(NULL) { }
void setActive(BaseClientProxy* active) { m_active = active; }
#endif

View File

@@ -14,19 +14,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include_directories(
../../ext/gtest
../../ext/gtest/include
../../ext/gmock
../../ext/gmock/include)
add_library(gtest STATIC ../../ext/gtest/src/gtest-all.cc)
add_library(gmock STATIC ../../ext/gmock/src/gmock-all.cc)
if (BARRIER_USE_EXTERNAL_GTEST)
include (FindPkgConfig)
find_package(GTest REQUIRED)
pkg_check_modules(GMOCK REQUIRED gmock)
include_directories(
${GTEST_INCLUDE_DIRS}
${GMOCK_INCLUDE_DIRS}
)
else()
include_directories(
../../ext/gtest
../../ext/gtest/include
../../ext/gmock
../../ext/gmock/include
)
if (UNIX)
# ignore warnings in gtest and gmock
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w")
add_library(gtest STATIC ../../ext/gtest/src/gtest-all.cc)
add_library(gmock STATIC ../../ext/gmock/src/gmock-all.cc)
set(GTEST_LIBRARIES gtest)
set(GMOCK_LIBRARIES gmock)
if (UNIX)
# ignore warnings in gtest and gmock
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w")
endif()
endif()
add_subdirectory(integtests)

View File

@@ -68,8 +68,6 @@ endif()
include_directories(
../../
../../../ext/gtest/include
../../../ext/gmock/include
)
if (UNIX)
@@ -80,4 +78,4 @@ endif()
add_executable(integtests ${sources})
target_link_libraries(integtests
arch base client common io ipc mt net platform server synlib gtest gmock ${libs} ${OPENSSL_LIBS})
arch base client common io ipc mt net platform server synlib ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS})

View File

@@ -19,7 +19,7 @@
// TODO: fix, tests failing intermittently on mac.
#ifndef WINAPI_CARBON
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "test/global/TestEventQueue.h"
#include "ipc/IpcServer.h"

View File

@@ -18,7 +18,7 @@
// TODO: fix, tests failing intermittently on mac.
#ifndef WINAPI_CARBON
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "test/mock/server/MockConfig.h"
#include "test/mock/server/MockPrimaryClient.h"

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "test/mock/barrier/MockEventQueue.h"
#include "test/mock/barrier/MockKeyMap.h"

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "test/mock/barrier/MockKeyMap.h"
#include "test/mock/barrier/MockEventQueue.h"

View File

@@ -23,6 +23,7 @@
#include "platform/XWindowsScreenSaver.h"
#include "test/global/gtest.h"
#include <cstdlib>
#include <X11/Xlib.h>
using ::testing::_;
@@ -30,7 +31,12 @@ using ::testing::_;
// TODO: not working on build machine for some reason
TEST(CXWindowsScreenSaverTests, activate_defaultScreen_todo)
{
Display* display = XOpenDisplay(":0.0");
const char* displayName = std::getenv("DISPLAY");
if (displayName == NULL) {
displayName = ":0.0";
}
Display* display = XOpenDisplay(displayName);
Window window = DefaultRootWindow(display);
MockEventQueue eventQueue;
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(1);

View File

@@ -20,16 +20,22 @@
#include "platform/XWindowsScreen.h"
#include "test/global/gtest.h"
#include <cstdlib>
using ::testing::_;
TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect)
{
const char* displayName = std::getenv("DISPLAY");
if (displayName == NULL) {
displayName = ":0.0";
}
MockEventQueue eventQueue;
EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2);
EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2);
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2);
XWindowsScreen screen(new XWindowsImpl(), ":0.0", false, false, 0, &eventQueue);
XWindowsScreen screen(new XWindowsImpl(), displayName, false, false, 0, &eventQueue);
screen.fakeMouseMove(10, 20);

View File

@@ -17,7 +17,7 @@
#pragma once
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "barrier/App.h"

View File

@@ -17,7 +17,7 @@
#pragma once
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "barrier/ArgParser.h"

View File

@@ -17,7 +17,7 @@
#pragma once
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "barrier/Screen.h"

View File

@@ -17,7 +17,7 @@
#pragma once
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "server/Config.h"

View File

@@ -17,7 +17,7 @@
#pragma once
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "server/InputFilter.h"

View File

@@ -17,7 +17,7 @@
#pragma once
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "server/PrimaryClient.h"
#include "base/String.h"

View File

@@ -17,7 +17,7 @@
#pragma once
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "server/Server.h"

View File

@@ -50,8 +50,6 @@ list(APPEND headers ${platform_sources})
include_directories(
../../
../../../ext/gtest/include
../../../ext/gmock/include
../../../ext
)
@@ -67,4 +65,4 @@ endif()
add_executable(unittests ${sources})
target_link_libraries(unittests
arch base client server common io net platform server synlib mt ipc gtest gmock ${libs} ${OPENSSL_LIBS})
arch base client server common io net platform server synlib mt ipc ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS})

View File

@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define BARRIER_TEST_ENV
#include "barrier/KeyMap.h"
#include "test/global/gtest.h"

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define TEST_ENV
#define BARRIER_TEST_ENV
#include "test/mock/ipc/MockIpcServer.h"