Merge branch 'master' into testing/pr/Absolucy/macos

This merges #1162 into Barrier.

Thanks!

Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
This commit is contained in:
Dom Rodriguez 2021-10-31 17:04:49 +00:00
commit fca18b63c5
No known key found for this signature in database
GPG Key ID: 72DCF1231E54BD43
113 changed files with 776 additions and 564 deletions

View File

@ -1,36 +0,0 @@
---
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.

79
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,79 @@
name: Bug Report
description: File a bug report (for questions, ideas & support, use the Discussions tab, or IRC for quick answers, but make sure to stay on the channel!)
labels: [bug, triage]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see! Screenshots are also helpful - please attach to the issue (when created), rather than linking to image hosting sites.
validations:
required: true
- type: dropdown
id: version
attributes:
label: Version
description: What version of Barrier are you running?
options:
- v2.0.0-RC1
- v2.0.0-RC2
- v2.0.0
- v2.1.1
- v2.1.2
- v2.3.0
- v2.3.1
- v2.3.2-alpha
- v2.3.2
- v2.3.3
- From Git HEAD or commit (specify below)
validations:
required: true
- type: input
id: git-commit-if
attributes:
label: Git commit hash (if applicable)
description: "When building Barrier from Git, what commit hash did you checkout from?"
placeholder: b0c0b42b
validations:
required: false
- type: textarea
id: pkg-mgr-origin
attributes:
label: If applicable, where did you install Barrier from?
description: This includes Snaps, Flatpaks, and self-built executables.
validations:
required: false
- type: dropdown
id: os
attributes:
label: What OSes are you seeing the problem on? (Check all that apply)
multiple: true
options:
- Linux
- Windows
- macOS
validations:
required: true
- type: textarea
id: os-version
attributes:
label: What OS versions are you using?
description: This applies to both client(s) and the server.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: textarea
id: misc-info
attributes:
label: Any other information
description: Please enter any other information we should know, if applicable.

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1 @@
blank_issues_enabled: false

View File

@ -292,6 +292,8 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
list (APPEND libs Wtsapi32 Userenv Wininet comsuppw Shlwapi)
add_definitions (
/DSYSAPI_WIN32=1
/DWINAPI_MSWINDOWS=1
/DWIN32
/D_WINDOWS
/D_CRT_SECURE_NO_WARNINGS

59
LICENSE
View File

@ -286,3 +286,62 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 2 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -8,7 +8,7 @@ and a [snap](https://snapcraft.io/barrier).
### Contact info:
- `#barrier` on libera IRC network
- `#barrier` on LiberaChat IRC network
#### CI Build Status
@ -65,7 +65,7 @@ Note that if the keyboard's Scroll Lock is active then this will prevent the mou
Please be aware that the *only* way to draw our attention to a bug is to create a new issue in [the issue tracker](https://github.com/debauchee/barrier/issues). Write a clear, concise, detailed report and you will get a clear, concise, detailed response. Priority is always given to issues that affect a wider range of users.
For short and simple questions or to just say hello find us on the Freenode IRC network in the #barrier channel.
For short and simple questions or to just say hello find us on the LiberaChat IRC network in the #barrier channel.
### Contributions
@ -107,7 +107,8 @@ A: Start the binary with the argument `--config <path_to_saved_configuration>`
Q: After loading my configuration on the client the field 'Server IP' is still empty!
A: Edit your configuration to include the servers ip adress manually with
A: Edit your configuration to include the server's ip address manually with
(...)
section: options
serverhostname=<AAA.BBB.CCC.DDD>

View File

@ -63,9 +63,15 @@ jobs:
artifactName: Windows Release Installer
- job: LinuxBuild
strategy:
matrix:
ubuntu-18.04:
imageName: 'ubuntu-18.04'
ubuntu-20.04:
imageName: 'ubuntu-20.04'
displayName: Linux Build
pool:
vmImage: 'ubuntu-16.04'
vmImage: $(imageName)
steps:
- script: sudo apt-get update -y
- script: sudo apt-get install -y libxtst-dev qtdeclarative5-dev libavahi-compat-libdnssd-dev libcurl4-openssl-dev
@ -75,13 +81,22 @@ jobs:
- job: MacBuild
displayName: Mac Build
pool:
vmImage: 'macOS-10.14'
strategy:
matrix:
Release:
big-sur-Release:
imageName: "macOS-11"
B_BUILD_TYPE: Release
BARRIER_VERSION_STAGE: Release
catalina-Release:
imageName: "macOS-10.15"
B_BUILD_TYPE: Release
BARRIER_VERSION_STAGE: Release
mojave-Release:
imageName: "macOS-10.14"
B_BUILD_TYPE: Release
BARRIER_VERSION_STAGE: Release
pool:
vmImage: $(imageName)
variables:
VERBOSE: 1
TERM: xterm-256color

View File

@ -65,7 +65,7 @@ if exist bin\Debug (
mkdir bin\Release\platforms
copy %B_QT_FULLPATH%\plugins\platforms\qwindows.dll bin\Release\platforms\ > NUL
) else (
echo Remember to copy supporting binaries and confiuration files!
echo Remember to copy supporting binaries and configuration files!
)
echo Build completed successfully

View File

@ -1,10 +1,10 @@
#!/bin/sh
cd "$(dirname $0)" || exit 1
cd "$(dirname "$0")" || exit 1
# some environments have cmake v2 as 'cmake' and v3 as 'cmake3'
# check for cmake3 first then fallback to just cmake
B_CMAKE=`type cmake3 2>/dev/null`
if [ $? -eq 0 ]; then
B_CMAKE=`echo $B_CMAKE | cut -d' ' -f3`
B_CMAKE=`echo "$B_CMAKE" | cut -d' ' -f3`
else
B_CMAKE=cmake
fi
@ -26,7 +26,7 @@ B_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=$B_BUILD_TYPE $B_CMAKE_FLAGS"
rm -rf build
mkdir build || exit 1
cd build || exit 1
echo Starting Barrier $B_BUILD_TYPE build...
echo "Starting Barrier $B_BUILD_TYPE build..."
$B_CMAKE $B_CMAKE_FLAGS .. || exit 1
make || exit 1
echo "Build completed successfully"

View File

@ -54,7 +54,7 @@ Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks:
; to avoid duplicate entries remove the existing rule (fails if it doesn't exist) before adding
Filename: {sys}\netsh.exe; Parameters: "advfirewall firewall delete rule name=""{#MyAppListenerDesc}"""; Flags: runhidden
Filename: {sys}\netsh.exe; Parameters: "advfirewall firewall add rule name=""{#MyAppListenerDesc}"" protocol=TCP dir=in localport=24800 action=allow"; Flags: runhidden
Filename: {sys}\sc.exe; Parameters: "create {#MyAppServiceName} start= auto binPath= ""{app}\{#MyAppServiceExe}"""; Flags: runhidden
Filename: {sys}\sc.exe; Parameters: "create {#MyAppServiceName} start= auto binPath= ""\""{app}\{#MyAppServiceExe}\"""""; Flags: runhidden
Filename: {sys}\sc.exe; Parameters: "description {#MyAppServiceName} ""{#MyAppServiceDesc}"""; Flags: runhidden
Filename: {sys}\sc.exe; Parameters: "start {#MyAppServiceName}"; Flags: runhidden
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Use the same verbose variable as CMake
[ "$VERBOSE" == "1" ] && set -x
[ "$VERBOSE" = "1" ] && set -x
# Exit on unset variables or pipe errors
set -uo pipefail
@ -14,10 +14,10 @@ B_BARRIERC="Barrier.app/Contents/MacOS/barrierc"
B_BARRIERS="Barrier.app/Contents/MacOS/barriers"
# Colorized output
function info() { tput bold; echo "$@" ; tput sgr0 ;}
function error() { tput bold; tput setaf 1; echo "$@"; tput sgr0 ; }
function success() { tput bold; tput setaf 2; echo "$@"; tput sgr0 ; }
function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
info() { tput bold; echo "$@"; tput sgr0 ; }
error() { tput bold; tput setaf 1; echo "$@"; tput sgr0 ; }
success() { tput bold; tput setaf 2; echo "$@"; tput sgr0 ; }
warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
info "Checking for bundle contents"
if [ ! -d "Barrier.app/Contents" ]; then
@ -40,7 +40,7 @@ if which -s port ; then
info "MacPorts found, searching for macdeployqt"
DEPLOYQT="$(port contents qt5-qttools | grep --only --max-count 1 '/.*macdeployqt')"
if [ ! -x "$DEPLOYQT" ]; then
error Please install package qt5-qttools
error "Please install package qt5-qttools"
exit 1
fi
fi
@ -50,13 +50,13 @@ if which -s brew ; then
info "Homebrew found, searching for macdeployqt"
DEPLOYQT="$(brew list qt@5 | grep --only '/.*macdeployqt' | head -1)"
if [ ! -x "$DEPLOYQT" ]; then
error Please install package qt
error "Please install package qt"
exit 1
fi
fi
# Use macdeployqt to include libraries and create dmg
if [ "$B_BUILDTYPE" == "Release" ]; then
if [ "$B_BUILDTYPE" = "Release" ]; then
info "Building Release disk image (dmg)"
"$DEPLOYQT" Barrier.app -dmg \
-executable="$B_BARRIERC" \

View File

@ -1,30 +1,30 @@
#!/bin/sh
# add warning for users running manually
function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated."
warn "Please use build_dist.sh instead to deploy using macdeployqt"
# change this to rename the installer package
B_DMG="Barrier-@BARRIER_VERSION@.dmg"
cd "$( dirname '$0' )"
cd "$( dirname "$0" )"
OWNDIR="$( pwd )"
B_REREF_SCRIPT="$OWNDIR/reref_dylibs.sh"
if [ ! -x $B_REREF_SCRIPT ]; then
echo Missing script: $B_REREF_SCRIPT
if [ ! -x "$B_REREF_SCRIPT" ]; then
echo "Missing script: $B_REREF_SCRIPT"
exit 1
fi
# remove any old copies so there's no confusion about whether this
# process completes successfully or not
rm -rf temp.dmg $B_DMG
rm -rf temp.dmg "$B_DMG"
cd Barrier.app/Contents 2>/dev/null
if [ $? -ne 0 ]; then
echo Please make sure that the build completed successfully
echo before trying to create the installer.
echo "Please make sure that the build completed successfully"
echo "before trying to create the installer."
exit 1
fi
@ -77,7 +77,7 @@ hdiutil create -size 64m -fs HFS+ -volname "Barrier" temp.dmg || exit 1
hdiutil attach temp.dmg -mountpoint mnt || exit 1
cp -r Barrier.app mnt/ || exit 1
hdiutil detach mnt || exit 1
hdiutil convert temp.dmg -format UDZO -o $B_DMG || exit 1
hdiutil convert temp.dmg -format UDZO -o "$B_DMG" || exit 1
rm temp.dmg
echo "dmg $B_DMB created successfully"
echo "dmg $B_DMG created successfully"

View File

@ -5,28 +5,28 @@ B_TARGET=$1
if [ "x$B_TARGET" = "x" ]; then
# add warning for users running manually
function warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
warn() { tput bold; tput setaf 3; echo "$@"; tput sgr0 ; }
warn "The scripts build_installer.sh and reref_dylibs.sh have been deprecated."
warn "Please use build_dist.sh instead to deploy using macdeployqt"
echo Which binary needs to be re-referenced?
echo "Which binary needs to be re-referenced?"
exit 1
fi
cd $(dirname $B_TARGET) || exit 1
cd "$(dirname "$B_TARGET")" || exit 1
# where to find non-system libraries relative to target's directory.
# the vast majority of the time this should be empty
B_REL_PATH=$2
# we're in target's directory now. trim off the path
B_TARGET=$(basename $B_TARGET)
B_TARGET=$(basename "$B_TARGET")
# get a list of non-system libraries and make local copies
B_LIBS=$(otool -XL $B_TARGET | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)')
B_LIBS=$(otool -XL "$B_TARGET" | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)')
[ $? -ne 0 ] && exit 1
for B_LIB in $B_LIBS; do
B_LIB_NAME=$(basename $B_LIB)
B_LIB_NAME=$(basename "$B_LIB")
# otool reports barrier as "barrier:" which fails self-reference test below
B_LIB_NAME=${B_LIB_NAME//:}
@ -34,16 +34,16 @@ for B_LIB in $B_LIBS; do
[ "$B_TARGET" = "$B_LIB_NAME" ] && continue
B_DST=${B_REL_PATH}${B_LIB_NAME}
if [ ! -e $B_DST ]; then
cp $B_LIB $B_DST || exit 1
chmod u+rw $B_DST || exit 1
if [ ! -e "$B_DST" ]; then
cp "$B_LIB" "$B_DST" || exit 1
chmod u+rw "$B_DST" || exit 1
# recursively call this script on libraries purposefully not passing
# $B_REL_PATH so that it is only used explicitly
$0 $B_DST
$0 "$B_DST"
fi
# adjust the target's metadata to point to the local copy
# rather than the system-wide copy which would only exist on
# a development machine
install_name_tool -change $B_LIB @loader_path/$B_DST $B_TARGET || exit 1
install_name_tool -change "$B_LIB" "@loader_path/$B_DST" "$B_TARGET" || exit 1
done

View File

@ -47,7 +47,7 @@ section: links
end
# The aliases section is to map the full names of the computers to their logical names used in the screens section
# One way to find the actual name of a comptuer is to run hostname from a command window
# One way to find the actual name of a computer is to run hostname from a command window
section: aliases
# Laptop is actually known as John-Smiths-MacBook-3.local
John-Smiths-MacBook-3.local:

View File

@ -0,0 +1 @@
Fixed incorrect setup of Barrier service path on Windows.

View File

@ -1,7 +1,7 @@
#!/bin/bash
# Checks if directory exists, otherwise asks to install package.
function check_dir_exists() {
check_dir_exists() {
local path=$1
local package=$2
@ -11,7 +11,7 @@ function check_dir_exists() {
fi
}
if [ ! $BARRIER_BUILD_ENV ]; then
if [ -z "$BARRIER_BUILD_ENV" ]; then
check_dir_exists '/Applications/Xcode.app' 'Xcode'
printf "Modifying environment for Barrier build...\n"

View File

@ -1,4 +1,4 @@
Thank you for chosing Barrier!
Thank you for choosing Barrier!
https://github.com/debauchee/barrier/
Barrier allows you to share your keyboard and mouse between computers over a network.

View File

@ -5,6 +5,5 @@ Comment=Keyboard and mouse sharing solution
Exec=barrier
Icon=barrier
Terminal=false
Categories=Utility;DesktopUtility;
Categories=Utility;RemoteAccess;
Keywords=keyboard;mouse;sharing;network;share;

View File

@ -1,10 +1,10 @@
#!/bin/sh
ICNS_BASE=../dist/macos/bundle/Barrier.app/Contents/Resources
if ! which magick >/dev/null 2>&1; then
echo "Need ImageMagic for this"
echo "Need ImageMagick for this"
exit 10
fi
cd $(dirname $0) || exit $?
cd "$(dirname "$0")" || exit $?
if [ ! -r barrier.png ]; then
echo "Use inkscape (or another vector graphics editor) to create barrier.png from barrier.svg first"
exit 10
@ -12,11 +12,11 @@ fi
rm -rf work || exit $?
mkdir -p work || exit $?
for s in 16 24 32 48 64 128 256 512 1024; do
magick convert barrier.png -resize ${s}x${s} -depth 8 work/${s}.png || exit $?
magick convert barrier.png -resize "${s}x${s}" -depth 8 "work/${s}.png" || exit $?
done
# windows icon
magick convert work/{16,24,32,48,64,128}.png barrier.png barrier.ico || exit $?
# macos icon
png2icns $ICNS_BASE/Barrier.icns work/{16,32,256,512,1024}.png || exit $?
png2icns "$ICNS_BASE/Barrier.icns" work/{16,32,256,512,1024}.png || exit $?
rm -rf work
echo Done

View File

@ -20,4 +20,3 @@ add_subdirectory(barriers)
if (WIN32)
add_subdirectory(barrierd)
endif()

View File

@ -46,4 +46,3 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install (TARGETS barrierc DESTINATION bin)
endif()

View File

@ -66,4 +66,3 @@ createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events
{
return new OSXClientTaskBarReceiver(logBuffer, events);
}

View File

@ -73,7 +73,7 @@ BEGIN
VALUE "ProductName", "Barrier"
VALUE "ProductVersion", BARRIER_VERSION
VALUE "OriginalFilename", "barrierd.exe"
VALUE "FileDescription", "Open source KVM software deamon"
VALUE "FileDescription", "Open source KVM software daemon"
VALUE "InternalName", "barrierd"
END
END

View File

@ -46,5 +46,3 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install (TARGETS barriers DESTINATION bin)
endif()

View File

@ -40,4 +40,3 @@ class AboutDialog : public QDialog, public Ui::AboutDialogBase
};
#endif

View File

@ -164,4 +164,3 @@ QTextStream& operator<<(QTextStream& outStream, const Action& action)
return outStream;
}

View File

@ -44,4 +44,3 @@ const char* BaseConfig::m_SwitchCornerNames[] =
"bottom-left",
"bottom-right"
};

View File

@ -30,35 +30,34 @@ CommandProcess::CommandProcess(QString cmd, QStringList arguments, QString input
QString CommandProcess::run()
{
QProcess process;
QString standardOutput, standardError;
process.setReadChannel(QProcess::StandardOutput);
process.start(m_Command, m_Arguments);
bool success = process.waitForStarted();
QString output, error;
if (success)
{
if (!m_Input.isEmpty()) {
process.write(m_Input.toLocal8Bit());
process.write(m_Input.toStdString().c_str());
}
if (process.waitForFinished()) {
standardOutput = QString::fromLocal8Bit(process.readAllStandardOutput().trimmed());
standardError = QString::fromLocal8Bit(process.readAllStandardError().trimmed());
output = process.readAllStandardOutput().trimmed();
error = process.readAllStandardError().trimmed();
}
}
int code = process.exitCode();
if (!standardError.isEmpty() || !success || code != 0)
if (!error.isEmpty() || !success || code != 0)
{
throw std::runtime_error(
std::string(
QString("Code: %1\nError: %2")
.arg(process.exitCode())
.arg(standardError.isEmpty() ? "Unknown" : standardError)
.toLocal8Bit().constData()));
.arg(error.isEmpty() ? "Unknown" : error)
.toStdString());
}
emit finished();
return standardOutput;
return output;
}

View File

@ -16,7 +16,8 @@
*/
#include "Fingerprint.h"
#include "QUtility.h"
#include "common/DataDirectories.h"
#include <QDir>
#include <QTextStream>
@ -123,8 +124,10 @@ void Fingerprint::persistDirectory()
QString Fingerprint::directoryPath()
{
auto profileDir = QString::fromStdString(DataDirectories::profile());
return QString("%1/%2")
.arg(profilePath())
.arg(profileDir)
.arg(kDirName);
}

View File

@ -104,12 +104,14 @@ void IpcClient::sendCommand(const QString& command, ElevateMode const elevate)
stream.writeRawData(kIpcMsgCommand, 4);
QByteArray utf8Command = command.toUtf8();
std::string stdStringCommand = command.toStdString();
const char* charCommand = stdStringCommand.c_str();
int length = (int)strlen(charCommand);
char lenBuf[4];
intToBytes(utf8Command.size(), lenBuf, 4);
intToBytes(length, lenBuf, 4);
stream.writeRawData(lenBuf, 4);
stream.writeRawData(utf8Command.constData(), utf8Command.size());
stream.writeRawData(charCommand, length);
char elevateBuf[1];
// Refer to enum ElevateMode documentation for why this flag is mapped this way

View File

@ -54,4 +54,3 @@ class KeySequence
};
#endif

View File

@ -78,4 +78,3 @@ class KeySequenceWidget : public QPushButton
};
#endif

View File

@ -31,6 +31,7 @@
#include "ProcessorArch.h"
#include "SslCertificate.h"
#include "ShutdownCh.h"
#include "common/DataDirectories.h"
#include <QtCore>
#include <QtGui>
@ -524,7 +525,7 @@ void MainWindow::startBarrier()
// launched the process (e.g. when launched with elevation). setting the
// profile dir on launch ensures it uses the same profile dir is used
// no matter how its relaunched.
args << "--profile-dir" << QString("\"%1\"").arg(profilePath());
args << "--profile-dir" << QString::fromStdString("\"" + DataDirectories::profile() + "\"");
#endif
if ((barrierType() == barrierClient && !clientArgs(args, app))
@ -624,7 +625,7 @@ QString MainWindow::configFilename()
if (m_pRadioInternalConfig->isChecked())
{
// TODO: no need to use a temporary file, since we need it to
// be permenant (since it'll be used for Windows services, etc).
// be permanent (since it'll be used for Windows services, etc).
m_pTempConfigFile = new QTemporaryFile();
if (!m_pTempConfigFile->open())
{
@ -729,7 +730,7 @@ void MainWindow::stopBarrier()
void MainWindow::stopService()
{
// send empty command to stop service from laucning anything.
// send empty command to stop service from launching anything.
m_IpcClient.sendCommand("", appConfig().elevateMode());
}

View File

@ -211,4 +211,3 @@ private slots:
};
#endif

View File

@ -1,4 +1,4 @@
/*
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
@ -45,4 +45,3 @@ void NewScreenWidget::mousePressEvent(QMouseEvent* event)
pDrag->exec(Qt::CopyAction, Qt::CopyAction);
}

View File

@ -37,4 +37,3 @@ class NewScreenWidget : public QLabel
};
#endif

View File

@ -44,4 +44,3 @@ class QBarrierApplication : public QApplication
};
#endif

View File

@ -19,7 +19,6 @@
#include "ProcessorArch.h"
#include "CommandProcess.h"
#include "common/DataDirectories.h"
#if defined(Q_OS_LINUX)
#include <QProcess>
@ -113,11 +112,3 @@ QString getOSInformation()
return result;
}
QString profilePath()
{
// Get path to current profile directory, properly converted
// from an OS locale std::string to Unicode QString.
auto localePath = DataDirectories::profile();
return QString::fromLocal8Bit(localePath.c_str(), localePath.size());
}

View File

@ -29,4 +29,3 @@ QString hash(const QString& string);
QString getFirstMacAddress();
qProcessorArch getProcessorArch();
QString getOSInformation();
QString profilePath();

View File

@ -105,4 +105,3 @@ QDataStream& operator<<(QDataStream& outStream, const Screen& screen);
QDataStream& operator>>(QDataStream& inStream, Screen& screen);
#endif

View File

@ -152,4 +152,3 @@ void ScreenSettingsDialog::on_m_pListAliases_itemSelectionChanged()
{
m_pButtonRemoveAlias->setEnabled(!m_pListAliases->selectedItems().isEmpty());
}

View File

@ -50,4 +50,3 @@ class ScreenSettingsDialog : public QDialog, public Ui::ScreenSettingsDialogBase
};
#endif

View File

@ -141,4 +141,3 @@ bool ScreenSetupModel::dropMimeData(const QMimeData* data, Qt::DropAction action
return true;
}

View File

@ -68,4 +68,3 @@ class ScreenSetupModel : public QAbstractTableModel
};
#endif

View File

@ -225,4 +225,3 @@ QStyleOptionViewItem ScreenSetupView::viewOptions() const
option.textElideMode = Qt::ElideMiddle;
return option;
}

View File

@ -58,4 +58,3 @@ class ScreenSetupView : public QTableView
};
#endif

View File

@ -138,4 +138,3 @@ enum {
};
#endif

View File

@ -76,7 +76,7 @@ void ServerConfigDialog::showEvent(QShowEvent* event)
if (!m_Message.isEmpty())
{
// TODO: ideally this massage box should pop up after the dialog is shown
// TODO: ideally this message box should pop up after the dialog is shown
QMessageBox::information(this, tr("Configure server"), m_Message);
}
}

View File

@ -63,4 +63,3 @@ class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase
};
#endif

View File

@ -37,7 +37,7 @@ SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
#elif defined(Q_OS_WIN)
// when areo is disabled on windows, the next/back buttons
// when aero is disabled on windows, the next/back buttons
// are hidden (must be a qt bug) -- resizing the window
// to +1 of the original height seems to fix this.
// NOTE: calling setMinimumSize after this will break

View File

@ -19,4 +19,3 @@
// included in both the GUI and the child apps (server & client)
const char ShutdownCh = 'S';

View File

@ -17,7 +17,7 @@
#include "SslCertificate.h"
#include "Fingerprint.h"
#include "QUtility.h"
#include "common/DataDirectories.h"
#include <QProcess>
#include <QDir>
@ -43,13 +43,13 @@ static const char kConfigFile[] = "barrier.conf";
SslCertificate::SslCertificate(QObject *parent) :
QObject(parent)
{
m_ProfileDir = profilePath();
if (m_ProfileDir.isEmpty()) {
m_ProfileDir = DataDirectories::profile();
if (m_ProfileDir.empty()) {
emit error(tr("Failed to get profile directory."));
}
}
std::pair<bool, QString> SslCertificate::runTool(const QStringList& args)
std::pair<bool, std::string> SslCertificate::runTool(const QStringList& args)
{
QString program;
#if defined(Q_OS_WIN)
@ -68,15 +68,17 @@ std::pair<bool, QString> SslCertificate::runTool(const QStringList& args)
#endif
QProcess process;
QString standardOutput, standardError;
process.setEnvironment(environment);
process.start(program, args);
bool success = process.waitForStarted();
bool success = process.waitForStarted();
std::string output;
QString standardError;
if (success && process.waitForFinished())
{
standardOutput = QString::fromLocal8Bit(process.readAllStandardOutput().trimmed());
standardError = QString::fromLocal8Bit(process.readAllStandardError().trimmed());
output = process.readAllStandardOutput().trimmed().toStdString();
standardError = process.readAllStandardError().trimmed();
}
int code = process.exitCode();
@ -87,15 +89,15 @@ std::pair<bool, QString> SslCertificate::runTool(const QStringList& args)
.arg(program)
.arg(process.exitCode())
.arg(standardError.isEmpty() ? "Unknown" : standardError));
return {false, standardOutput};
return {false, output};
}
return {true, standardOutput};
return {true, output};
}
void SslCertificate::generateCertificate()
{
auto filename = getCertificatePath();
auto filename = QString::fromStdString(getCertificatePath());
QFile file(filename);
if (!file.exists() || !isCertificateValid(filename)) {
@ -106,7 +108,7 @@ void SslCertificate::generateCertificate()
arguments.append("-x509");
arguments.append("-nodes");
// valide duration
// valid duration
arguments.append("-days");
arguments.append(kCertificateLifetime);
@ -120,7 +122,7 @@ void SslCertificate::generateCertificate()
arguments.append("-newkey");
arguments.append("rsa:2048");
QDir sslDir(getCertificateDirectory());
QDir sslDir(QString::fromStdString(getCertificateDirectory()));
if (!sslDir.exists()) {
sslDir.mkpath(".");
}
@ -157,17 +159,20 @@ void SslCertificate::generateFingerprint(const QString& certificateFilename)
auto ret = runTool(arguments);
bool success = ret.first;
std::string output = ret.second;
if (!success) {
return;
}
// find the fingerprint from the tool output
QString fingerprint = ret.second;
auto i = fingerprint.indexOf('=');
if (i != -1) {
fingerprint.remove(0, i+1);
auto i = output.find_first_of('=');
if (i != std::string::npos) {
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 {
@ -175,14 +180,14 @@ void SslCertificate::generateFingerprint(const QString& certificateFilename)
}
}
QString SslCertificate::getCertificatePath()
std::string SslCertificate::getCertificatePath()
{
return getCertificateDirectory() + QDir::separator() + kCertificateFilename;
return getCertificateDirectory() + QDir::separator().toLatin1() + kCertificateFilename;
}
QString SslCertificate::getCertificateDirectory()
std::string SslCertificate::getCertificateDirectory()
{
return m_ProfileDir + QDir::separator() + kSslDir;
return m_ProfileDir + QDir::separator().toLatin1() + kSslDir;
}
bool SslCertificate::isCertificateValid(const QString& path)
@ -193,7 +198,7 @@ bool SslCertificate::isCertificateValid(const QString& path)
BIO* bio = BIO_new(BIO_s_file());
auto ret = BIO_read_filename(bio, path.toLocal8Bit().constData());
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);

View File

@ -36,13 +36,13 @@ signals:
void generateFinished();
private:
std::pair<bool, QString> runTool(const QStringList& args);
std::pair<bool, std::string> runTool(const QStringList& args);
void generateFingerprint(const QString& certificateFilename);
QString getCertificatePath();
QString getCertificateDirectory();
std::string getCertificatePath();
std::string getCertificateDirectory();
bool isCertificateValid(const QString& path);
private:
QString m_ProfileDir;
std::string m_ProfileDir;
};

View File

@ -40,4 +40,3 @@ void TrashScreenWidget::dropEvent(QDropEvent* event)
else
event->ignore();
}

View File

@ -39,4 +39,3 @@ class TrashScreenWidget : public QLabel
};
#endif

View File

@ -97,6 +97,12 @@ int main(int argc, char* argv[])
QApplication::setQuitOnLastWindowClosed(false);
if (QGuiApplication::platformName() == "wayland") {
QMessageBox::warning(
NULL, "Barrier",
"You are using wayland session, which is currently not fully supported by Barrier.");
}
QSettings settings;
AppConfig appConfig (&settings);

View File

@ -72,7 +72,7 @@ std::string ArchInternetWindows::urlEncode(const std::string& url)
std::string result(buffer);
// the win32 url encoding funcitons are pretty useless (to us) and only
// the win32 url encoding functions are pretty useless (to us) and only
// escape "unsafe" chars, but not + or =, so we need to replace these
// manually (and probably many other chars).
barrier::string::findReplaceAll(result, "+", "%2B");

View File

@ -83,7 +83,7 @@ XArchEvalWinsock::eval() const noexcept
/* 10052 */{WSAENETRESET, "The connection must be reset because the Windows Sockets implementation dropped it"},
/* 10053 */{WSAECONNABORTED, "The virtual circuit was aborted due to timeout or other failure"},
/* 10054 */{WSAECONNRESET, "The virtual circuit was reset by the remote side"},
/* 10055 */{WSAENOBUFS, "No buffer space is available or a buffer deadlock has occured. The socket cannot be created"},
/* 10055 */{WSAENOBUFS, "No buffer space is available or a buffer deadlock has occurred. The socket cannot be created"},
/* 10056 */{WSAEISCONN, "The socket is already connected"},
/* 10057 */{WSAENOTCONN, "The socket is not connected"},
/* 10058 */{WSAESHUTDOWN, "The socket has been shutdown"},
@ -100,7 +100,7 @@ XArchEvalWinsock::eval() const noexcept
/* 10069 */{WSAEDQUOT, "Undocumented WinSock error code"},
/* 10070 */{WSAESTALE, "Undocumented WinSock error code"},
/* 10071 */{WSAEREMOTE, "Undocumented WinSock error code"},
/* 10091 */{WSASYSNOTREADY, "Underlying network subsytem is not ready for network communication"},
/* 10091 */{WSASYSNOTREADY, "Underlying network subsystem is not ready for network communication"},
/* 10092 */{WSAVERNOTSUPPORTED, "The version of WinSock API support requested is not provided in this implementation"},
/* 10093 */{WSANOTINITIALISED, "WinSock subsystem not properly initialized"},
/* 10101 */{WSAEDISCON, "Virtual circuit has gracefully terminated connection"},

View File

@ -133,10 +133,10 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
return true;
}
bool
ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
#if WINAPI_MSWINDOWS
bool
ArgParser::parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
if (isArg(i, argc, argv, NULL, "--service")) {
LOG((CLOG_WARN "obsolete argument --service, use barrierd instead."));
argsBase.m_shouldExit = true;
@ -153,25 +153,46 @@ ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* con
}
return true;
#elif WINAPI_XWINDOWS
}
#endif
#if WINAPI_CARBON
bool
ArgParser::parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
// no options for carbon
return false;
}
#endif
#if WINAPI_XWINDOWS
bool
ArgParser::parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
if (isArg(i, argc, argv, "-display", "--display", 1)) {
// use alternative display
argsBase.m_display = argv[++i];
}
else if (isArg(i, argc, argv, NULL, "--no-xinitthreads")) {
argsBase.m_disableXInitThreads = true;
}
else {
} else {
// option not supported here
return false;
}
return true;
}
#endif
bool
ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
#if WINAPI_MSWINDOWS
return parseMSWindowsArg(argsBase, argc, argv, i);
#elif WINAPI_CARBON
// no options for carbon
return false;
return parseCarbonArg(argsBase, argc, argv, i);
#elif WINAPI_XWINDOWS
return parseXWindowsArg(argsBase, argc, argv, i);
#endif
}

View File

@ -53,6 +53,9 @@ private:
bool checkUnexpectedArgs();
static ArgsBase& argsBase() { return *m_argsBase; }
bool parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
bool parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
bool parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
private:
App* m_app;

View File

@ -18,6 +18,7 @@
#include "barrier/DropHelper.h"
#include "base/Log.h"
#include "io/fstream.h"
#include <fstream>
@ -35,7 +36,7 @@ DropHelper::writeToDir(const String& destination, DragFileList& fileList, String
dropTarget.append("/");
#endif
dropTarget.append(fileList.at(0).getFilename());
file.open(dropTarget.c_str(), std::ios::out | std::ios::binary);
barrier::open_utf8_path(file, dropTarget, std::ios::out | std::ios::binary);
if (!file.is_open()) {
LOG((CLOG_ERR "drop file failed: can not open %s", dropTarget.c_str()));
}

View File

@ -56,7 +56,7 @@ public:
//! Deactivate screen saver
/*!
Deactivate (i.e. hide) the screen saver, reseting the screen saver
Deactivate (i.e. hide) the screen saver, resetting the screen saver
timer.
*/
virtual void deactivate() = 0;

View File

@ -267,8 +267,8 @@ extern const char* kMsgDSetOptions;
// 2 means the file transfer is finished.
extern const char* kMsgDFileTransfer;
// drag infomation: primary <-> secondary
// transfer drag infomation. The first 2 bytes are used for storing
// drag information: primary <-> secondary
// transfer drag information. The first 2 bytes are used for storing
// the number of dragging objects. Then the following string consists
// of each object's directory.
extern const char* kMsgDDragInfo;

View File

@ -34,7 +34,6 @@
#include "base/log_outputters.h"
#include "base/Log.h"
#include "common/DataDirectories.h"
#include "base/Unicode.h"
#include "arch/win32/ArchMiscWindows.h"
#include "arch/win32/XArchWindows.h"
@ -258,7 +257,7 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
switch (m->type()) {
case kIpcCommand: {
IpcCommandMessage* cm = static_cast<IpcCommandMessage*>(m);
String command = Unicode::UTF8ToText(cm->command());
String command = cm->command();
// if empty quotes, clear.
if (command == "\"\"") {

View File

@ -62,7 +62,7 @@ Log::Log()
{
assert(s_log == NULL);
// other initalization
// other initialization
m_maxPriority = g_defaultMaxPriority;
m_maxNewlineLength = 0;
insert(new ConsoleLogOutputter);

View File

@ -20,7 +20,7 @@
#include "base/TMethodJob.h"
#include "arch/Arch.h"
#include "base/String.h"
#include "io/fstream.h"
#include <fstream>
enum EFileLogOutputter {
@ -260,7 +260,7 @@ FileLogOutputter::write(ELevel level, const char *message)
bool moveFile = false;
std::ofstream m_handle;
m_handle.open(m_fileName.c_str(), std::fstream::app);
barrier::open_utf8_path(m_handle, m_fileName, std::fstream::app);
if (m_handle.is_open() && m_handle.fail() != true) {
m_handle << message << std::endl;

View File

@ -119,7 +119,7 @@ public:
*/
NetworkAddress getServerAddress() const;
//! Return true if recieved file size is valid
//! Return true if received file size is valid
bool isReceivedFileSizeValid();
//! Return expected file size

View File

@ -18,13 +18,8 @@
#pragma once
#if defined(_WIN32)
# define SYSAPI_WIN32 1
# define WINAPI_MSWINDOWS 1
#elif HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include "config.h"
#else
# error "config.h missing"
#endif
// VC++ has built-in sized types

View File

@ -16,12 +16,26 @@
*/
#include "../DataDirectories.h"
#include "KnownFolderPaths.h"
#include "encoding_utilities.h"
#include <Shlobj.h>
std::string known_folder_path(const KNOWNFOLDERID& id)
{
std::string path;
WCHAR* buffer;
HRESULT result = SHGetKnownFolderPath(id, 0, NULL, &buffer);
if (result == S_OK) {
path = win_wchar_to_utf8(buffer);
CoTaskMemFree(buffer);
}
return path;
}
const std::string& DataDirectories::profile()
{
if (_profile.empty())
_profile = localAppDataPath() + "\\Barrier";
_profile = known_folder_path(FOLDERID_LocalAppData) + "\\Barrier";
return _profile;
}
const std::string& DataDirectories::profile(const std::string& path)
@ -33,7 +47,7 @@ const std::string& DataDirectories::profile(const std::string& path)
const std::string& DataDirectories::global()
{
if (_global.empty())
_global = programDataPath() + "\\Barrier";
_global = known_folder_path(FOLDERID_ProgramData) + "\\Barrier";
return _global;
}
const std::string& DataDirectories::global(const std::string& path)
@ -45,7 +59,7 @@ const std::string& DataDirectories::global(const std::string& path)
const std::string& DataDirectories::systemconfig()
{
// systemconfig() is a special case in that it will track the current value
// of global() unless and until it is explictly set otherwise
// of global() unless and until it is explicitly set otherwise
// previously it would default to the windows folder which was horrible!
if (_systemconfig.empty())
return global();

View File

@ -1,63 +0,0 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2018 Debauchee Open Source Group
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package 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, see <http://www.gnu.org/licenses/>.
*/
#include "KnownFolderPaths.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <Shlobj.h>
static std::string wide_to_mb(const wchar_t* source, int length)
{
int ansiLength = WideCharToMultiByte(CP_ACP, 0, source, length, NULL, 0, NULL, NULL);
if (ansiLength > 0) {
std::string ansiString(ansiLength, 0);
ansiLength = WideCharToMultiByte(CP_ACP, 0, source, length, &ansiString[0], ansiLength, NULL, NULL);
if (ansiLength > 0) {
return ansiString;
}
}
return {};
}
static std::string known_folder_path(const KNOWNFOLDERID& id)
{
std::string path;
WCHAR* buffer;
HRESULT result = SHGetKnownFolderPath(id, 0, NULL, &buffer);
if (result == S_OK) {
auto length = lstrlenW(buffer);
path = wide_to_mb(buffer, length);
CoTaskMemFree(buffer);
}
return path;
}
std::string desktopPath()
{
return known_folder_path(FOLDERID_Desktop);
}
std::string localAppDataPath()
{
return known_folder_path(FOLDERID_LocalAppData);
}
std::string programDataPath()
{
return known_folder_path(FOLDERID_ProgramData);
}

View File

@ -1,24 +0,0 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2018 Debauchee Open Source Group
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
std::string desktopPath();
std::string localAppDataPath();
std::string programDataPath();

View File

@ -0,0 +1,37 @@
/*
barrier -- mouse and keyboard sharing utility
Copyright (C) Barrier contributors
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
found in the file LICENSE that should have accompanied this file.
This package 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, see <http://www.gnu.org/licenses/>.
*/
#include "encoding_utilities.h"
#include <stringapiset.h>
std::string win_wchar_to_utf8(const WCHAR* utfStr)
{
int utfLength = lstrlenW(utfStr);
int mbLength = WideCharToMultiByte(CP_UTF8, 0, utfStr, utfLength, NULL, 0, NULL, NULL);
std::string mbStr(mbLength, 0);
WideCharToMultiByte(CP_UTF8, 0, utfStr, utfLength, &mbStr[0], mbLength, NULL, NULL);
return mbStr;
}
std::vector<WCHAR> utf8_to_win_char(const std::string& str)
{
int result_len = MultiByteToWideChar(CP_UTF8, 0, str.data(), str.size(), NULL, 0);
std::vector<WCHAR> result;
result.resize(result_len + 1, 0);
MultiByteToWideChar(CP_UTF8, 0, str.data(), str.size(), result.data(), result_len);
return result;
}

View File

@ -0,0 +1,28 @@
/*
barrier -- mouse and keyboard sharing utility
Copyright (C) Barrier contributors
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
found in the file LICENSE that should have accompanied this file.
This package 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef BARRIER_LIB_COMMON_WIN32_ENCODING_UTILITIES_H
#define BARRIER_LIB_COMMON_WIN32_ENCODING_UTILITIES_H
#include <windows.h>
#include <string>
#include <vector>
std::string win_wchar_to_utf8(const WCHAR* utfStr);
std::vector<WCHAR> utf8_to_win_char(const std::string& str);
#endif

57
src/lib/io/fstream.cpp Normal file
View File

@ -0,0 +1,57 @@
/*
barrier -- mouse and keyboard sharing utility
Copyright (C) Barrier contributors
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
found in the file LICENSE that should have accompanied this file.
This package 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, see <http://www.gnu.org/licenses/>.
*/
#include "fstream.h"
#if SYSAPI_WIN32
#include "common/win32/encoding_utilities.h"
#endif
#include <fstream>
namespace barrier {
namespace {
template<class Stream>
void open_utf8_path_impl(Stream& stream, const std::string& path, std::ios_base::openmode mode)
{
#if SYSAPI_WIN32
// on Windows we need to use a private constructor from wchar_t* string.
auto wchar_path = utf8_to_win_char(path);
stream.open(wchar_path.data(), mode);
#else
stream.open(path.c_str(), mode);
#endif
}
} // namespace
void open_utf8_path(std::ifstream& stream, const std::string& path, std::ios_base::openmode mode)
{
open_utf8_path_impl(stream, path, mode);
}
void open_utf8_path(std::ofstream& stream, const std::string& path, std::ios_base::openmode mode)
{
open_utf8_path_impl(stream, path, mode);
}
void open_utf8_path(std::fstream& stream, const std::string& path, std::ios_base::openmode mode)
{
open_utf8_path_impl(stream, path, mode);
}
} // namespace barrier

35
src/lib/io/fstream.h Normal file
View File

@ -0,0 +1,35 @@
/*
barrier -- mouse and keyboard sharing utility
Copyright (C) Barrier contributors
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
found in the file LICENSE that should have accompanied this file.
This package 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef BARRIER_LIB_IO_FSTREAM_H
#define BARRIER_LIB_IO_FSTREAM_H
#include <iosfwd>
#include <ios>
namespace barrier {
void open_utf8_path(std::ifstream& stream, const std::string& path,
std::ios_base::openmode mode = std::ios_base::in);
void open_utf8_path(std::ofstream& stream, const std::string& path,
std::ios_base::openmode mode = std::ios_base::out);
void open_utf8_path(std::fstream& stream, const std::string& path,
std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out);
} // namespace barrier
#endif

View File

@ -29,7 +29,6 @@
#include "base/EventQueue.h"
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
#include "base/Unicode.h"
enum EIpcLogOutputter {
kBufferMaxSize = 1000,
@ -197,7 +196,7 @@ IpcLogOutputter::sendBuffer()
return;
}
IpcLogLineMessage message(Unicode::textToUTF8(getChunk(kMaxSendLines)));
IpcLogLineMessage message(getChunk(kMaxSendLines));
m_sending = true;
m_ipcServer.send(message, kIpcClientGui);
m_sending = false;

View File

@ -25,7 +25,7 @@ class IJob;
//! Thread handle
/*!
Creating a Thread creates a new context of execution (i.e. thread) that
runs simulatenously with the calling thread. A Thread is only a handle
runs simultaneously with the calling thread. A Thread is only a handle
to a thread; deleting a Thread does not cancel or destroy the thread it
refers to and multiple Thread objects can refer to the same thread.
@ -122,7 +122,7 @@ public:
/*!
Change the priority of the thread. Normal priority is 0, 1 is
the next lower, etc. -1 is the next higher, etc. but boosting
the priority may not be permitted and will be silenty ignored.
the priority may not be permitted and will be silently ignored.
*/
void setPriority(int n);

View File

@ -43,7 +43,7 @@ public:
If \c hostname can be parsed as a numerical address then that's how
it's used, otherwise it's used as a host name. If \c hostname ends
in ":[0-9]+" then that suffix is extracted and used as the port,
overridding the port parameter. The resulting port must be a valid
overriding the port parameter. The resulting port must be a valid
port number (zero is not a valid port number) otherwise \c XSocketAddress
is thrown with an error of \c XSocketAddress::kBadPort. The hostname
is not resolved by the c'tor; use \c resolve to do that.

View File

@ -25,6 +25,7 @@
#include "base/Log.h"
#include "base/String.h"
#include "common/DataDirectories.h"
#include "io/fstream.h"
#include <openssl/ssl.h>
#include <openssl/err.h>
@ -658,7 +659,7 @@ SecureSocket::disconnect()
void SecureSocket::formatFingerprint(std::string& fingerprint, bool hex, bool separator)
{
if (hex) {
// to hexidecimal
// to hexadecimal
barrier::string::toHex(fingerprint, 2);
}
@ -666,7 +667,7 @@ void SecureSocket::formatFingerprint(std::string& fingerprint, bool hex, bool se
barrier::string::uppercase(fingerprint);
if (separator) {
// add colon to separate each 2 charactors
// add colon to separate each 2 characters
size_t separators = fingerprint.size() / 2;
for (size_t i = 1; i < separators; i++) {
fingerprint.insert(i * 3 - 1, ":");
@ -708,7 +709,7 @@ SecureSocket::verifyCertFingerprint()
// check if this fingerprint exist
std::string fileLine;
std::ifstream file;
file.open(trustedServersFilename.c_str());
barrier::open_utf8_path(file, trustedServersFilename);
if (!file.is_open()) {
LOG((CLOG_NOTE "Unable to open trustedServersFile: %s", trustedServersFilename.c_str() ));
@ -830,7 +831,7 @@ SecureSocket::showSecureCipherInfo()
}
#if OPENSSL_VERSION_NUMBER < 0x10100000L
// m_ssl->m_ssl->session->ciphers is not forward compatable,
// m_ssl->m_ssl->session->ciphers is not forward compatible,
// In future release of OpenSSL, it's not visible,
STACK_OF(SSL_CIPHER) * cStack = m_ssl->m_ssl->session->ciphers;
#else

View File

@ -803,7 +803,7 @@ MSWindowsDesks::checkDesk()
// if active desktop changed then tell the old and new desk threads
// about the change. don't switch desktops when the screensaver is
// active becaue we'd most likely switch to the screensaver desktop
// active because we'd most likely switch to the screensaver desktop
// which would have the side effect of forcing the screensaver to
// stop.
if (name != m_activeDeskName && !m_screensaver->isActive()) {

View File

@ -61,12 +61,12 @@ const KeyID MSWindowsKeyState::s_virtualKey[] =
/* 0x012 */ { kKeyAlt_L }, // VK_MENU
/* 0x013 */ { kKeyPause }, // VK_PAUSE
/* 0x014 */ { kKeyCapsLock }, // VK_CAPITAL
/* 0x015 */ { kKeyKana }, // VK_HANGUL, VK_KANA
/* 0x016 */ { kKeyNone }, // undefined
/* 0x015 */ { kKeyNone }, // undefined
/* 0x016 */ { kKeyKana }, // VK_HANGUL, VK_KANA, VK_IME_ON
/* 0x017 */ { kKeyNone }, // VK_JUNJA
/* 0x018 */ { kKeyNone }, // VK_FINAL
/* 0x019 */ { kKeyKanzi }, // VK_HANJA, VK_KANJI
/* 0x01a */ { kKeyNone }, // undefined
/* 0x01a */ { kKeyEisuToggle }, // VK_IME_OFF
/* 0x01b */ { kKeyEscape }, // VK_ESCAPE
/* 0x01c */ { kKeyHenkan }, // VK_CONVERT
/* 0x01d */ { kKeyMuhenkan }, // VK_NONCONVERT
@ -1330,7 +1330,7 @@ MSWindowsKeyState::getKeyID(UINT virtualKey, KeyButton button) const
if ((LOWORD(m_keyLayout) & 0xffffu) == 0x0412u) { // 0x0412 : Korean Locale ID
if (virtualKey == VK_HANGUL || virtualKey == VK_HANJA) {
// If shift-space is used to change the input mode,
// the extented bit is not set. So add it to get right key id.
// the extended bit is not set. So add it to get right key id.
button |= 0x100u;
}
}

View File

@ -41,9 +41,9 @@
#include "base/IEventQueue.h"
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
#include "common/win32/KnownFolderPaths.h"
#include <string.h>
#include <Shlobj.h>
#include <comutil.h>
#include <algorithm>
@ -1916,12 +1916,14 @@ const std::string&
MSWindowsScreen::getDropTarget() const
{
if (m_dropTargetPath.empty()) {
m_dropTargetPath = desktopPath();
if (!m_dropTargetPath.empty()) {
LOG((CLOG_DEBUG "using desktop for drop target: %s", m_dropTargetPath.c_str()));
// SHGetFolderPath is deprecated in vista, but use it for xp support.
char desktopPath[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) {
m_dropTargetPath = std::string(desktopPath);
LOG((CLOG_INFO "using desktop for drop target: %s", m_dropTargetPath.c_str()));
}
else {
LOG((CLOG_ERR "failed to get desktop path, no drop target available"));
LOG((CLOG_ERR "failed to get desktop path, no drop target available, error=%d", GetLastError()));
}
}
return m_dropTargetPath;

View File

@ -81,7 +81,7 @@ private:
//! Relauncher error
/*!
An error occured in the process watchdog.
An error occurred in the process watchdog.
*/
class XMSWindowsWatchdogError : public XBarrier {
public:

View File

@ -52,7 +52,7 @@ OSXClipboard::OSXClipboard() :
OSStatus syncErr = PasteboardSynchronize(m_pboard);
if (syncErr != noErr) {
LOG((CLOG_DEBUG "failed to syncronize clipboard: error %i", syncErr));
LOG((CLOG_DEBUG "failed to synchronize clipboard: error %i", syncErr));
}
}

View File

@ -68,7 +68,7 @@ fakeDragging(const char* str, int cursorX, int cursorY)
dispatch_async(dispatch_get_main_queue(), ^{
NSRect screen = [[NSScreen mainScreen] frame];
NSLog ( @"screen size: witdh = %f height = %f", screen.size.width, screen.size.height);
NSLog ( @"screen size: width = %f height = %f", screen.size.width, screen.size.height);
NSLog ( @"mouseLocation: %d %d", cursorX, cursorY);
int newPosX = 0;

View File

@ -43,6 +43,9 @@ static const UInt32 s_launchpadVK = 131;
static const UInt32 s_osxNumLock = 1 << 16;
static const UInt32 s_int4VK = 0x8a; // international4
static const UInt32 s_int5VK = 0x8b; // international5
struct KeyEntry {
public:
KeyID m_keyID;
@ -126,7 +129,10 @@ static const KeyEntry s_controlKeys[] = {
// JIS keyboards only
{ kKeyEisuToggle, kVK_JIS_Eisu },
{ kKeyKana, kVK_JIS_Kana }
{ kKeyKana, kVK_JIS_Kana },
{ kKeyMuhenkan, s_int5VK },
{ kKeyHenkan, s_int4VK },
{ kKeyZenkaku, kVK_ANSI_Grave }
};

View File

@ -538,7 +538,7 @@ OSXScreen::fakeMouseButton(ButtonID id, bool press)
// As long as the click is within the time window and distance window
// increase clickState (double click, triple click, etc)
// This will allow for higher than triple click but the quartz documenation
// This will allow for higher than triple click but the quartz documentation
// does not specify that this should be limited to triple click
if (press) {
if ((ARCH->time() - m_lastClickTime) <= clickTime && diff <= maxDiff) {
@ -1618,7 +1618,7 @@ OSXScreen::userSwitchCallback(EventHandlerCallRef nextHandler,
//
// OSXScreen::watchSystemPowerThread(void*)
//
// main of thread monitoring system power (sleep/wakup) using a CFRunLoop
// main of thread monitoring system power (sleep/wakeup) using a CFRunLoop
//
void

View File

@ -115,7 +115,7 @@ private:
// the X display
Display* m_display;
// window to receive xscreensaver repsonses
// window to receive xscreensaver responses
Window m_xscreensaverSink;
// the target for the events we generate

View File

@ -1136,9 +1136,9 @@ Server::processOptions()
return;
}
m_switchNeedsShift = false; // it seems if i don't add these
m_switchNeedsShift = false; // it seems if I don't add these
m_switchNeedsControl = false; // lines, the 'reload config' option
m_switchNeedsAlt = false; // doesnt' work correct.
m_switchNeedsAlt = false; // doesn't work correct.
bool newRelativeMoves = m_relativeMoves;
for (Config::ScreenOptions::const_iterator index = options->begin();

View File

@ -167,7 +167,7 @@ public:
*/
void getClients(std::vector<std::string>& list) const;
//! Return true if recieved file size is valid
//! Return true if received file size is valid
bool isReceivedFileSizeValid();
//! Return expected file data size
@ -357,7 +357,7 @@ private:
// force the cursor off of \p client
void forceLeaveClient(BaseClientProxy* client);
// thread funciton for sending file
// thread function for sending file
void sendFileThread(void*);
// thread function for writing file to drop directory