Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(DEFLECT_DEB_DEPENDS freeglut3-dev libxi-dev libxmu-dev
libboost-program-options-dev libboost-test-dev
qtbase5-dev qtdeclarative5-dev)
set(DEFLECT_PORT_DEPENDS boost freeglut qt5)
set(DEFLECT_BREW_DEPENDS boost freeglut jpeg-turbo qt5)

include(Common)

Expand Down
16 changes: 14 additions & 2 deletions apps/DesktopStreamer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
# Copyright (c) 2013-2017, EPFL/Blue Brain Project
# Raphael Dumusc <raphael.dumusc@epfl.ch>

include_directories(${CMAKE_CURRENT_BINARY_DIR}) # for autogenerated ui_* file

set(DESKTOPSTREAMER_HEADERS
defaults.h
MainWindow.h
nameUtils.h
Stream.h
)

set(DESKTOPSTREAMER_SOURCES
defaults.cpp
main.cpp
MainWindow.cpp
MainWindow.ui
Expand All @@ -31,8 +35,8 @@ set(DEFLECT_DESKTOPSTREAMER_HOSTS
{\"DisplayWall 6th floor\", \"bbpav06.bbp.epfl.ch\"}"
CACHE STRING "List of default hosts for the DesktopStreamer application"
)
set_source_files_properties(MainWindow.cpp PROPERTIES COMPILE_DEFINITIONS
_HOSTS=${DEFLECT_DESKTOPSTREAMER_HOSTS}
set_source_files_properties(defaults.cpp PROPERTIES COMPILE_DEFINITIONS
_DEFAULT_HOSTS=${DEFLECT_DESKTOPSTREAMER_HOSTS}
)

set(DESKTOPSTREAMER_APP_NAME desktopstreamer)
Expand All @@ -57,6 +61,14 @@ if(APPLE)
else()
list(APPEND DESKTOPSTREAMER_LINK_LIBRARIES "-framework CoreGraphics")
endif()

# Configure 'defaults.json' and copy it in the app bundle's 'Resources' folder
string(REGEX REPLACE "\"," "\":" _JSON_HOSTS ${DEFLECT_DESKTOPSTREAMER_HOSTS})
set(_defaults_file ${CMAKE_CURRENT_BINARY_DIR}/defaults.json)
configure_file(defaults.json.in ${_defaults_file})
list(APPEND DESKTOPSTREAMER_SOURCES ${_defaults_file})
set_source_files_properties(${_defaults_file} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
else()
list(APPEND DESKTOPSTREAMER_SOURCES nameUtils.cpp)
endif()
Expand Down
7 changes: 4 additions & 3 deletions apps/DesktopStreamer/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*********************************************************************/
/* Copyright (c) 2011-2012, The University of Texas at Austin. */
/* Copyright (c) 2013-2016, EPFL/Blue Brain Project */
/* Copyright (c) 2013-2017, EPFL/Blue Brain Project */
/* Raphael Dumusc <raphael.dumusc@epfl.ch> */
/* All rights reserved. */
/* */
Expand Down Expand Up @@ -39,7 +39,9 @@
/*********************************************************************/

#include "MainWindow.h"

#include "Stream.h"
#include "defaults.h"
#include "nameUtils.h"

#include <deflect/version.h>
Expand Down Expand Up @@ -69,7 +71,6 @@ typedef __int32 int32_t;

namespace
{
const std::vector<std::pair<QString, QString>> defaultHosts = {_HOSTS};
const QString streamButtonDefaultText = "Stream";
const QString streamSelected = "Stream selected item(s)";
const int SHARE_DESKTOP_UPDATE_DELAY = 0;
Expand All @@ -83,7 +84,7 @@ MainWindow::MainWindow()
{
setupUi(this);

for (const auto& entry : defaultHosts)
for (const auto& entry : defaults::getHosts())
_hostComboBox->addItem(entry.first, entry.second);

_hostComboBox->setCurrentIndex(-1); // no default host selected initially
Expand Down
2 changes: 1 addition & 1 deletion apps/DesktopStreamer/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#ifndef DESKTOPSTREAMER_MAINWINDOW_H
#define DESKTOPSTREAMER_MAINWINDOW_H

#include <apps/DesktopStreamer/ui_MainWindow.h>
#include "ui_MainWindow.h" // Generated by CMake in CMAKE_CURRENT_BINARY_DIR

#ifdef __APPLE__
#include <deflect/AppNapSuspender.h>
Expand Down
87 changes: 87 additions & 0 deletions apps/DesktopStreamer/defaults.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*********************************************************************/
/* Copyright (c) 2017, EPFL/Blue Brain Project */
/* Raphael Dumusc <raphael.dumusc@epfl.ch> */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* 1. Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* */
/* 2. Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of The University of Texas at Austin. */
/*********************************************************************/

#include "defaults.h"

#include <QApplication>
#include <QFile>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>

#include <iostream>

namespace defaults
{
std::vector<std::pair<QString, QString>> getHosts()
{
#ifdef __APPLE__
const auto appPath = QApplication::applicationDirPath();
QFile file{appPath + "/../Resources/defaults.json"};
if (!file.exists() || !file.open(QIODevice::ReadOnly))
{
std::cerr << "could not open file 'defaults.json'" << std::endl;
return {};
}
QJsonParseError error;
const auto doc = QJsonDocument::fromJson(file.readAll(), &error);
if (doc.isNull())
{
std::cerr << "defaults.json parsing error: "
<< error.errorString().toStdString() << std::endl;
return {};
}
std::vector<std::pair<QString, QString>> hosts;
for (const auto& value : doc.object()["hosts"].toArray())
{
const auto entry = value.toObject();
if (entry.size() != 1)
continue;
const auto name = entry.begin().key();
const auto addr = entry.begin().value().toString();
if (!name.isEmpty() && !addr.isEmpty())
hosts.emplace_back(name, addr);
}
return hosts;
#else
return {_DEFAULT_HOSTS}; // CMake DEFLECT_DESKTOPSTREAMER_HOSTS
#endif
}
}
52 changes: 52 additions & 0 deletions apps/DesktopStreamer/defaults.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*********************************************************************/
/* Copyright (c) 2017, EPFL/Blue Brain Project */
/* Raphael Dumusc <raphael.dumusc@epfl.ch> */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* 1. Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* */
/* 2. Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of The University of Texas at Austin. */
/*********************************************************************/

#ifndef DEFAULTS_H
#define DEFAULTS_H

#include <QString>
#include <vector>

namespace defaults
{
/** @return the list of default hosts as [name, address] pairs. */
std::vector<std::pair<QString, QString>> getHosts();
}

#endif
5 changes: 5 additions & 0 deletions apps/DesktopStreamer/defaults.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hosts": [
${_JSON_HOSTS}
]
}
4 changes: 4 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changelog {#Changelog}

## Deflect 0.13 (git master)

* [161](https://github.com/BlueBrain/Deflect/pull/161):
DesktopStreamer OSX: the default hosts are read from a json file in the app
bundle. This is useful for external users who want to adapt the official
BlueBrain releases to their own needs without recompiling.
* [156](https://github.com/BlueBrain/Deflect/pull/156):
Deflect can be released as a Debian/Ubuntu package. Once installed,
DesktopStreamer can be launched from the desktop's applications menu.
Expand Down