diff --git a/.travis.yml b/.travis.yml index eaf715d..2c0178d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,6 @@ notifications: on_success: never language: cpp sudo: false -cache: - ccache: true - pip: true - directories: - - /usr/local -before_cache: - - brew cleanup os: - osx env: @@ -31,4 +24,3 @@ script: - cd $BUILD_TYPE - cmake -GNinja -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. - ninja all && ninja $PROJECT_NAME-tests && ninja install - diff --git a/apps/DesktopStreamer/CMakeLists.txt b/apps/DesktopStreamer/CMakeLists.txt index 56a7bbb..f100b19 100644 --- a/apps/DesktopStreamer/CMakeLists.txt +++ b/apps/DesktopStreamer/CMakeLists.txt @@ -1,9 +1,10 @@ -# Copyright (c) 2013-2015, EPFL/Blue Brain Project -# Raphael Dumusc +# Copyright (c) 2013-2016, EPFL/Blue Brain Project +# Raphael Dumusc set(DESKTOPSTREAMER_HEADERS MainWindow.h + nameUtils.h Stream.h ) @@ -22,6 +23,12 @@ set(DESKTOPSTREAMER_LINK_LIBRARIES Qt5::Widgets ) +if(APPLE) + list(APPEND DESKTOPSTREAMER_SOURCES nameUtils.mm) +else() + list(APPEND DESKTOPSTREAMER_SOURCES nameUtils.cpp) +endif() + set(DEFLECT_DESKTOPSTREAMER_HOSTS "\ {\"DisplayWall Ground floor\", \"bbpav02.epfl.ch\"}, \ diff --git a/apps/DesktopStreamer/MainWindow.cpp b/apps/DesktopStreamer/MainWindow.cpp index b70eb61..daeef0a 100644 --- a/apps/DesktopStreamer/MainWindow.cpp +++ b/apps/DesktopStreamer/MainWindow.cpp @@ -39,6 +39,7 @@ /*********************************************************************/ #include "MainWindow.h" +#include "nameUtils.h" #include "Stream.h" #include @@ -94,7 +95,11 @@ MainWindow::MainWindow() _listView->setEnabled( !text.isEmpty( )); }); - _streamIdLineEdit->setText( QHostInfo::localHostName( )); + const auto username = nameutils::getFullUsername(); + if( username.isEmpty( )) + _streamIdLineEdit->setText( QHostInfo::localHostName( )); + else + _streamIdLineEdit->setText( username + "'s Desktop" ); connect( _streamButton, &QPushButton::clicked, this, &MainWindow::_update ); diff --git a/apps/DesktopStreamer/nameUtils.cpp b/apps/DesktopStreamer/nameUtils.cpp new file mode 100644 index 0000000..0445885 --- /dev/null +++ b/apps/DesktopStreamer/nameUtils.cpp @@ -0,0 +1,50 @@ +/* Copyright (c) 2016, EPFL/Blue Brain Project + * Raphael Dumusc + * + * This file is part of Deflect + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License version 3.0 as published + * by the Free Software Foundation. + * + * This library 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 Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "nameUtils.h" + +#ifndef _WIN32 +# include +#endif + +namespace nameutils +{ + +QString getFullUsername() +{ +#ifdef _WIN32 + return qgetenv( "USERNAME" ); +#else + auto username = qgetenv( "USER" ); + if( username.isEmpty( )) + username = qgetenv( "USERNAME" ); + if( username.isEmpty( )) + return {}; + + if( auto userinfo = getpwnam( username.constData( ))) + { + const auto fullname = QString{ userinfo->pw_gecos }; + if( !fullname.isEmpty( )) + return fullname; + } + return username; +#endif +} + +} diff --git a/apps/DesktopStreamer/nameUtils.h b/apps/DesktopStreamer/nameUtils.h new file mode 100644 index 0000000..20cbf81 --- /dev/null +++ b/apps/DesktopStreamer/nameUtils.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2016, EPFL/Blue Brain Project + * Raphael Dumusc + * + * This file is part of Deflect + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License version 3.0 as published + * by the Free Software Foundation. + * + * This library 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 Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include + +/** + * Cross-platform utilities to retrieve the name of the user. + */ +namespace nameutils +{ + +/** + * Retrieve the full name of the user (e.g. "John Doe"). + * @return full name if available, else the basic username or an empty string. + */ +QString getFullUsername(); + +} diff --git a/apps/DesktopStreamer/nameUtils.mm b/apps/DesktopStreamer/nameUtils.mm new file mode 100644 index 0000000..48ad618 --- /dev/null +++ b/apps/DesktopStreamer/nameUtils.mm @@ -0,0 +1,36 @@ +/* Copyright (c) 2016, EPFL/Blue Brain Project + * Raphael Dumusc + * + * This file is part of Deflect + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License version 3.0 as published + * by the Free Software Foundation. + * + * This library 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 Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "nameUtils.h" + +#import + +namespace nameutils +{ + +QString getFullUsername() +{ + const auto fullname = QString{ [NSFullUserName() UTF8String] }; + if( !fullname.isEmpty( )) + return fullname; + + return qgetenv( "USER" ); +} + +} diff --git a/doc/Changelog.md b/doc/Changelog.md index 45f4337..b0c35aa 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -5,6 +5,8 @@ Changelog {#Changelog} ### 0.12.0 (git master) +* [140](https://github.com/BlueBrain/Deflect/pull/140): + The DesktopStreamer app uses the full user name as the default stream name. * [139](https://github.com/BlueBrain/Deflect/pull/139): OSX: AppNap is now disabled for all QmlStreamers. The AppNapSuspender class is now available in Deflect library for use in external applications.