Merge pull request #3512 from birarda/domain-wizard

allow user to select domain ID from their High Fidelity domains
This commit is contained in:
Brad Hefta-Gaub 2014-09-30 19:53:11 -07:00
commit 98fe700105
14 changed files with 200 additions and 78 deletions

View file

@ -644,7 +644,7 @@ void AudioMixer::run() {
QJsonObject audioGroupObject = settingsObject[AUDIO_GROUP_KEY].toObject();
// check the payload to see if we have asked for dynamicJitterBuffer support
const QString DYNAMIC_JITTER_BUFFER_JSON_KEY = "dynamic-jitter-buffer";
const QString DYNAMIC_JITTER_BUFFER_JSON_KEY = "dynamic_jitter_buffer";
_streamSettings._dynamicJitterBuffers = audioGroupObject[DYNAMIC_JITTER_BUFFER_JSON_KEY].toBool();
if (_streamSettings._dynamicJitterBuffers) {
qDebug() << "Enable dynamic jitter buffers.";
@ -653,21 +653,21 @@ void AudioMixer::run() {
}
bool ok;
const QString DESIRED_JITTER_BUFFER_FRAMES_KEY = "static-desired-jitter-buffer-frames";
const QString DESIRED_JITTER_BUFFER_FRAMES_KEY = "static_desired_jitter_buffer_frames";
_streamSettings._staticDesiredJitterBufferFrames = audioGroupObject[DESIRED_JITTER_BUFFER_FRAMES_KEY].toString().toInt(&ok);
if (!ok) {
_streamSettings._staticDesiredJitterBufferFrames = DEFAULT_STATIC_DESIRED_JITTER_BUFFER_FRAMES;
}
qDebug() << "Static desired jitter buffer frames:" << _streamSettings._staticDesiredJitterBufferFrames;
const QString MAX_FRAMES_OVER_DESIRED_JSON_KEY = "max-frames-over-desired";
const QString MAX_FRAMES_OVER_DESIRED_JSON_KEY = "max_frames_over_desired";
_streamSettings._maxFramesOverDesired = audioGroupObject[MAX_FRAMES_OVER_DESIRED_JSON_KEY].toString().toInt(&ok);
if (!ok) {
_streamSettings._maxFramesOverDesired = DEFAULT_MAX_FRAMES_OVER_DESIRED;
}
qDebug() << "Max frames over desired:" << _streamSettings._maxFramesOverDesired;
const QString USE_STDEV_FOR_DESIRED_CALC_JSON_KEY = "use-stdev-for-desired-calc";
const QString USE_STDEV_FOR_DESIRED_CALC_JSON_KEY = "use_stdev_for_desired_calc";
_streamSettings._useStDevForJitterCalc = audioGroupObject[USE_STDEV_FOR_DESIRED_CALC_JSON_KEY].toBool();
if (_streamSettings._useStDevForJitterCalc) {
qDebug() << "Using Philip's stdev method for jitter calc if dynamic jitter buffers enabled";
@ -675,28 +675,28 @@ void AudioMixer::run() {
qDebug() << "Using Fred's max-gap method for jitter calc if dynamic jitter buffers enabled";
}
const QString WINDOW_STARVE_THRESHOLD_JSON_KEY = "window-starve-threshold";
const QString WINDOW_STARVE_THRESHOLD_JSON_KEY = "window_starve_threshold";
_streamSettings._windowStarveThreshold = audioGroupObject[WINDOW_STARVE_THRESHOLD_JSON_KEY].toString().toInt(&ok);
if (!ok) {
_streamSettings._windowStarveThreshold = DEFAULT_WINDOW_STARVE_THRESHOLD;
}
qDebug() << "Window A starve threshold:" << _streamSettings._windowStarveThreshold;
const QString WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES_JSON_KEY = "window-seconds-for-desired-calc-on-too-many-starves";
const QString WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES_JSON_KEY = "window_seconds_for_desired_calc_on_too_many_starves";
_streamSettings._windowSecondsForDesiredCalcOnTooManyStarves = audioGroupObject[WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES_JSON_KEY].toString().toInt(&ok);
if (!ok) {
_streamSettings._windowSecondsForDesiredCalcOnTooManyStarves = DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES;
}
qDebug() << "Window A length:" << _streamSettings._windowSecondsForDesiredCalcOnTooManyStarves << "seconds";
const QString WINDOW_SECONDS_FOR_DESIRED_REDUCTION_JSON_KEY = "window-seconds-for-desired-reduction";
const QString WINDOW_SECONDS_FOR_DESIRED_REDUCTION_JSON_KEY = "window_seconds_for_desired_reduction";
_streamSettings._windowSecondsForDesiredReduction = audioGroupObject[WINDOW_SECONDS_FOR_DESIRED_REDUCTION_JSON_KEY].toString().toInt(&ok);
if (!ok) {
_streamSettings._windowSecondsForDesiredReduction = DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION;
}
qDebug() << "Window B length:" << _streamSettings._windowSecondsForDesiredReduction << "seconds";
const QString REPETITION_WITH_FADE_JSON_KEY = "repetition-with-fade";
const QString REPETITION_WITH_FADE_JSON_KEY = "repetition_with_fade";
_streamSettings._repetitionWithFade = audioGroupObject[REPETITION_WITH_FADE_JSON_KEY].toBool();
if (_streamSettings._repetitionWithFade) {
qDebug() << "Repetition with fade enabled";
@ -704,13 +704,13 @@ void AudioMixer::run() {
qDebug() << "Repetition with fade disabled";
}
const QString PRINT_STREAM_STATS_JSON_KEY = "print-stream-stats";
const QString PRINT_STREAM_STATS_JSON_KEY = "print_stream_stats";
_printStreamStats = audioGroupObject[PRINT_STREAM_STATS_JSON_KEY].toBool();
if (_printStreamStats) {
qDebug() << "Stream stats will be printed to stdout";
}
const QString FILTER_KEY = "enable-filter";
const QString FILTER_KEY = "enable_filter";
if (audioGroupObject[FILTER_KEY].isBool()) {
_enableFilter = audioGroupObject[FILTER_KEY].toBool();
}
@ -718,7 +718,7 @@ void AudioMixer::run() {
qDebug() << "Filter enabled";
}
const QString UNATTENUATED_ZONE_KEY = "unattenuated-zone";
const QString UNATTENUATED_ZONE_KEY = "unattenuated_zone";
QString unattenuatedZoneString = audioGroupObject[UNATTENUATED_ZONE_KEY].toString();
if (!unattenuatedZoneString.isEmpty()) {
@ -742,7 +742,7 @@ void AudioMixer::run() {
<< QString("%1, %2, %3").arg(destinationCenter.x).arg(destinationCenter.y).arg(destinationCenter.z);
}
const QString ATTENATION_PER_DOULING_IN_DISTANCE = "attenuation-per-doubling-in-distance";
const QString ATTENATION_PER_DOULING_IN_DISTANCE = "attenuation_per_doubling_in_distance";
if (audioGroupObject[ATTENATION_PER_DOULING_IN_DISTANCE].isString()) {
bool ok = false;
float attenuation = audioGroupObject[ATTENATION_PER_DOULING_IN_DISTANCE].toString().toFloat(&ok);

View file

@ -4,9 +4,9 @@
"label": "Metaverse Registration",
"settings": [
{
"name": "access-token",
"name": "access_token",
"label": "Access Token",
"help": "This is an access token generated on the <a href='https://data.highfidelity.io/tokens'>My Tokens</a> page of your High Fidelity account.<br/>Generate a token with the 'domains' scope and paste it here.<br/>This is required to associate this domain-server with a domain in your account."
"help": "This is an access token generated on the <a href='https://data.highfidelity.io/tokens' target='_blank'>My Tokens</a> page of your High Fidelity account.<br/>Generate a token with the 'domains' scope and paste it here.<br/>This is required to associate this domain-server with a domain in your account."
},
{
"name": "id",
@ -20,12 +20,12 @@
"label": "Security",
"settings": [
{
"name": "http-username",
"name": "http_username",
"label": "HTTP Username",
"help": "Username used for basic HTTP authentication."
},
{
"name": "http-password",
"name": "http_password",
"label": "HTTP Password",
"type": "password",
"help": "Password used for basic HTTP authentication. Leave this blank if you do not want to change it.",
@ -39,20 +39,20 @@
"assignment-types": [0],
"settings": [
{
"name": "enable-filter",
"name": "enable_filter",
"type": "checkbox",
"label": "Enable Positional Filter",
"help": "positional audio stream uses lowpass filter",
"default": true
},
{
"name": "unattenuated-zone",
"name": "unattenuated_zone",
"label": "Unattenuated Zone",
"help": "Boxes for source and listener (corner x, corner y, corner z, size x, size y, size z, corner x, corner y, corner z, size x, size y, size z)",
"placeholder": "no zone"
},
{
"name": "attenuation-per-doubling-in-distance",
"name": "attenuation_per_doubling_in_distance",
"label": "Attenuattion per doubling in distance",
"help": "Factor between 0.0 and 1.0 (0.0: No attenuation, 1.0: extreme attenuation)",
"placeholder": "0.18",
@ -60,7 +60,7 @@
"advanced": true
},
{
"name": "dynamic-jitter-buffer",
"name": "dynamic_jitter_buffer",
"type": "checkbox",
"label": "Dynamic Jitter Buffers",
"help": "dynamically buffer client audio based on perceived jitter in packet receipt timing",
@ -68,7 +68,7 @@
"advanced": true
},
{
"name": "static-desired-jitter-buffer-frames",
"name": "static_desired_jitter_buffer_frames",
"label": "Static Desired Jitter Buffer Frames",
"help": "If dynamic jitter buffers is disabled, this determines the target number of frames maintained by the AudioMixer's jitter buffers",
"placeholder": "1",
@ -76,7 +76,7 @@
"advanced": true
},
{
"name": "max-frames-over-desired",
"name": "max_frames_over_desired",
"label": "Max Frames Over Desired",
"help": "The highest number of frames an AudioMixer's ringbuffer can exceed the desired jitter buffer frames by",
"placeholder": "10",
@ -84,7 +84,7 @@
"advanced": true
},
{
"name": "use-stdev-for-desired-calc",
"name": "use_stdev_for_desired_calc",
"type": "checkbox",
"label": "Use Stdev for Desired Jitter Frames Calc:",
"help": "use Philip's method (stdev of timegaps) to calculate desired jitter frames (otherwise Fred's max timegap method is used)",
@ -92,7 +92,7 @@
"advanced": true
},
{
"name": "window-starve-threshold",
"name": "window_starve_threshold",
"label": "Window Starve Threshold",
"help": "If this many starves occur in an N-second window (N is the number in the next field), then the desired jitter frames will be re-evaluated using Window A.",
"placeholder": "3",
@ -100,7 +100,7 @@
"advanced": true
},
{
"name": "window-seconds-for-desired-calc-on-too-many-starves",
"name": "window_seconds_for_desired_calc_on_too_many_starves",
"label": "Timegaps Window (A) Seconds:",
"help": "Window A contains a history of timegaps. Its max timegap is used to re-evaluate the desired jitter frames when too many starves occur within it.",
"placeholder": "50",
@ -108,7 +108,7 @@
"advanced": true
},
{
"name": "window-seconds-for-desired-reduction",
"name": "window_seconds_for_desired_reduction",
"label": "Timegaps Window (B) Seconds:",
"help": "Window B contains a history of timegaps. Its max timegap is used as a ceiling for the desired jitter frames value.",
"placeholder": "10",
@ -116,7 +116,7 @@
"advanced": true
},
{
"name": "repetition-with-fade",
"name": "repetition_with_fade",
"type": "checkbox",
"label": "Repetition with Fade:",
"help": "dropped frames and mixing during starves repeat the last frame, eventually fading to silence",
@ -124,7 +124,7 @@
"advanced": true
},
{
"name": "print-stream-stats",
"name": "print_stream_stats",
"type": "checkbox",
"label": "Print Stream Stats:",
"help": "audio upstream and downstream stats of each agent printed to audio-mixer stdout",

View file

@ -73,4 +73,4 @@ span.port {
#small-save-button {
width: 100%;
margin-bottom: 15px;
}
}

File diff suppressed because one or more lines are too long

View file

@ -4,9 +4,7 @@ var Settings = {
var viewHelpers = {
getFormGroup: function(groupName, setting, values, isAdvanced, isLocked) {
setting_id = groupName + "_" + setting.name
console.log(setting.name + " in " + groupName + " is " + isLocked)
setting_name = groupName + "." + setting.name
form_group = "<div class='form-group" + (isAdvanced ? " advanced-setting" : "") + "'>"
@ -26,22 +24,21 @@ var viewHelpers = {
if (setting.type === 'checkbox') {
form_group += "<label class='" + label_class + "'>" + setting.label + "</label>"
form_group += "<div class='checkbox" + (isLocked ? " disabled" : "") + "'>"
form_group += "<label for='" + setting_id + "'>"
form_group += "<input type='checkbox' id='" + setting_id + "' " +
form_group += "<label for='" + setting_name + "'>"
form_group += "<input type='checkbox' name='" + setting_name + "' " +
(setting_value ? "checked" : "") + (isLocked ? " disabled" : "") + "/>"
form_group += " " + setting.help + "</label>";
form_group += "</div>"
} else {
input_type = _.has(setting, 'type') ? setting.type : "text"
form_group += "<label for='" + setting_id + "' class='" + label_class + "'>" + setting.label + "</label>";
form_group += "<input type='" + input_type + "' class='form-control' id='" + setting_id +
form_group += "<label for='" + setting_name + "' class='" + label_class + "'>" + setting.label + "</label>";
form_group += "<input type='" + input_type + "' class='form-control' name='" + setting_name +
"' placeholder='" + (_.has(setting, 'placeholder') ? setting.placeholder : "") +
"' value='" + setting_value + "'" + (isLocked ? " disabled" : "") + "/>"
form_group += "<span class='help-block'>" + setting.help + "</span>"
}
form_group += "</div>"
return form_group
}
@ -89,6 +86,10 @@ $(document).ready(function(){
$(this).blur()
})
$('#settings-form').on('click', '#choose-domain-btn', function(){
chooseFromHighFidelityDomains($(this))
})
var panelsSource = $('#panels-template').html()
Settings.panelsTemplate = _.template(panelsSource)
@ -108,16 +109,24 @@ function reloadSettings() {
$('.nav-stacked').html(Settings.sidebarTemplate(data))
$('#panels').html(Settings.panelsTemplate(data))
Settings.initialValues = form2js('settings-form', "_", false, cleanupFormValues, true);
Settings.initialValues = form2js('settings-form', ".", false, cleanupFormValues, true);
// add tooltip to locked settings
$('label.locked').tooltip({
placement: 'right',
title: 'This setting is in the master config file and cannot be changed'
})
appendDomainSelectionModal()
});
}
function appendDomainSelectionModal() {
var metaverseInput = $("[name='metaverse.id']");
var chooseButton = $("<button type='button' id='choose-domain-btn' class='btn btn-primary' style='margin-top:10px'>Choose ID from my domains</button>");
metaverseInput.after(chooseButton);
}
var SETTINGS_ERROR_MESSAGE = "There was a problem saving domain settings. Please try again!";
$('body').on('click', '.save-button', function(e){
@ -127,7 +136,9 @@ $('body').on('click', '.save-button', function(e){
});
// grab a JSON representation of the form via form2js
var formJSON = form2js('settings-form', "_", false, cleanupFormValues, true);
var formJSON = form2js('settings-form', ".", false, cleanupFormValues, true);
console.log(formJSON);
// re-enable all inputs
$("input").each(function(){
@ -162,13 +173,13 @@ function badgeSidebarForDifferences(changedInput) {
var panelParentID = changedInput.closest('.panel').attr('id')
// get a JSON representation of that section
var rootJSON = form2js(panelParentID, "_", false, cleanupFormValues, true);
var rootJSON = form2js(panelParentID, ".", false, cleanupFormValues, true);
var panelJSON = rootJSON[panelParentID]
var badgeValue = 0
for (var setting in panelJSON) {
if (panelJSON[setting] != Settings.initialValues[panelParentID][ setting]) {
if (panelJSON[setting] != Settings.initialValues[panelParentID][setting]) {
badgeValue += 1
}
}
@ -208,7 +219,7 @@ function showRestartModal() {
function cleanupFormValues(node) {
if (node.type && node.type === 'checkbox') {
return { name: node.id, value: node.checked ? true : false };
return { name: node.name, value: node.checked ? true : false };
} else {
return false;
}
@ -220,4 +231,71 @@ function showAlertMessage(message, isSuccess) {
alertBox.addClass(isSuccess ? 'alert-success' : 'alert-danger');
alertBox.html(message);
alertBox.fadeIn();
}
function chooseFromHighFidelityDomains(clickedButton) {
// setup the modal to help user pick their domain
if (Settings.initialValues.metaverse.access_token) {
// add a spinner to the choose button
clickedButton.html("Loading domains...")
clickedButton.attr('disabled', 'disabled')
// get a list of user domains from data-web
data_web_domains_url = "https://data.highfidelity.io/api/v1/domains?access_token="
$.getJSON(data_web_domains_url + Settings.initialValues.metaverse.access_token, function(data){
modal_buttons = {
cancel: {
label: 'Cancel',
className: 'btn-default'
}
}
if (data.data.domains.length) {
// setup a select box for the returned domains
modal_body = "<p>Choose the High Fidelity domain you want this domain-server to represent.<br/>This will set your domain ID on the settings page.</p>"
domain_select = $("<select id='domain-name-select' class='form-control'></select>")
_.each(data.data.domains, function(domain){
domain_select.append("<option value='" + domain.id + "'>" + domain.name + "</option>")
})
modal_body += "<label for='domain-name-select'>Domains</label>" + domain_select[0].outerHTML
modal_buttons["success"] = {
label: 'Choose domain',
callback: function() {
domainID = $('#domain-name-select').val()
// set the domain ID on the form
$("[name='metaverse.id']").val(domainID).change();
}
}
} else {
modal_buttons["success"] = {
label: 'Create new domain',
callback: function() {
window.open("https://data.highfidelity.io/domains", '_blank');
}
}
modal_body = "<p>You do not have any domains in your High Fidelity account." +
"<br/><br/>Go to your domains page to create a new one. Once your domain is created re-open this dialog to select it.</p>"
}
bootbox.dialog({
title: "Choose matching domain",
message: modal_body,
buttons: modal_buttons
})
// remove the spinner from the choose button
clickedButton.html("Choose from my domains")
clickedButton.removeAttr('disabled')
})
} else {
bootbox.alert({
message: "You must have an access token to query your High Fidelity domains.<br><br>" +
"Please follow the instructions on the settings page to add an access token.",
title: "Access token required"
})
}
}

View file

@ -75,6 +75,7 @@
<!--#include virtual="footer.html"-->
<script src='/js/underscore-min.js'></script>
<script src='/js/bootbox.min.js'></script>
<script src='/js/settings.js'></script>
<script src='/js/form2js.min.js'></script>
<!--#include virtual="page-end.html"-->

View file

@ -81,6 +81,11 @@ DomainServer::DomainServer(int argc, char* argv[]) :
void DomainServer::restart() {
qDebug() << "domain-server is restarting.";
// make sure all static instances are reset
LimitedNodeList::getInstance()->reset();
AccountManager::getInstance(true);
exit(DomainServer::EXIT_CODE_REBOOT);
}
@ -1396,8 +1401,8 @@ bool DomainServer::isAuthenticatedRequest(HTTPConnection* connection, const QUrl
const QByteArray HTTP_COOKIE_HEADER_KEY = "Cookie";
const QString ADMIN_USERS_CONFIG_KEY = "admin-users";
const QString ADMIN_ROLES_CONFIG_KEY = "admin-roles";
const QString BASIC_AUTH_USERNAME_KEY_PATH = "security.http-username";
const QString BASIC_AUTH_PASSWORD_KEY_PATH = "security.http-password";
const QString BASIC_AUTH_USERNAME_KEY_PATH = "security.http_username";
const QString BASIC_AUTH_PASSWORD_KEY_PATH = "security.http_password";
const QByteArray UNAUTHENTICATED_BODY = "You do not have permission to access this domain-server.";

View file

@ -39,6 +39,28 @@ DomainServerSettingsManager::DomainServerSettingsManager() :
void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList) {
_configMap.loadMasterAndUserConfig(argumentList);
// for now we perform a temporary transition from http-username and http-password to http_username and http_password
const QVariant* oldUsername = valueForKeyPath(_configMap.getUserConfig(), "security.http-username");
const QVariant* oldPassword = valueForKeyPath(_configMap.getUserConfig(), "security.http-password");
if (oldUsername || oldPassword) {
QVariantMap& settingsMap = *reinterpret_cast<QVariantMap*>(_configMap.getUserConfig()["security"].data());
// remove old keys, move to new format
if (oldUsername) {
settingsMap["http_username"] = oldUsername->toString();
settingsMap.remove("http-username");
}
if (oldPassword) {
settingsMap["http_password"] = oldPassword->toString();
settingsMap.remove("http-password");
}
// save the updated settings
persistToFile();
}
}
const QString SETTINGS_PATH = "/settings.json";

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <memory>
#include <QtCore/QDataStream>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
@ -25,9 +27,14 @@
const bool VERBOSE_HTTP_REQUEST_DEBUGGING = false;
AccountManager& AccountManager::getInstance() {
static AccountManager sharedInstance;
return sharedInstance;
AccountManager& AccountManager::getInstance(bool forceReset) {
static std::auto_ptr<AccountManager> sharedInstance(new AccountManager());
if (forceReset) {
sharedInstance.reset(new AccountManager());
}
return *sharedInstance;
}
Q_DECLARE_METATYPE(OAuthAccessToken)

View file

@ -42,7 +42,7 @@ const QByteArray ACCESS_TOKEN_AUTHORIZATION_HEADER = "Authorization";
class AccountManager : public QObject {
Q_OBJECT
public:
static AccountManager& getInstance();
static AccountManager& getInstance(bool forceReset = false);
void authenticatedRequest(const QString& path,
QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,

View file

@ -35,29 +35,32 @@ const char SOLO_NODE_TYPES[2] = {
const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://data.highfidelity.io");
LimitedNodeList* LimitedNodeList::_sharedInstance = NULL;
std::auto_ptr<LimitedNodeList> LimitedNodeList::_sharedInstance;
LimitedNodeList* LimitedNodeList::createInstance(unsigned short socketListenPort, unsigned short dtlsPort) {
if (!_sharedInstance) {
NodeType::init();
NodeType::init();
if (_sharedInstance.get()) {
qDebug() << "LimitedNodeList called with existing instance." <<
"Releasing auto_ptr, deleting existing instance and creating a new one.";
_sharedInstance = new LimitedNodeList(socketListenPort, dtlsPort);
// register the SharedNodePointer meta-type for signals/slots
qRegisterMetaType<SharedNodePointer>();
} else {
qDebug("LimitedNodeList createInstance called with existing instance.");
delete _sharedInstance.release();
}
_sharedInstance = std::auto_ptr<LimitedNodeList>(new LimitedNodeList(socketListenPort, dtlsPort));
// register the SharedNodePointer meta-type for signals/slots
qRegisterMetaType<SharedNodePointer>();
return _sharedInstance;
return _sharedInstance.get();
}
LimitedNodeList* LimitedNodeList::getInstance() {
if (!_sharedInstance) {
if (!_sharedInstance.get()) {
qDebug("LimitedNodeList getInstance called before call to createInstance. Returning NULL pointer.");
}
return _sharedInstance;
return _sharedInstance.get();
}

View file

@ -14,6 +14,7 @@
#include <stdint.h>
#include <iterator>
#include <memory>
#ifndef _WIN32
#include <unistd.h> // not on windows, not needed for mac or windows
@ -118,7 +119,7 @@ signals:
void nodeKilled(SharedNodePointer);
void publicSockAddrChanged(const HifiSockAddr& publicSockAddr);
protected:
static LimitedNodeList* _sharedInstance;
static std::auto_ptr<LimitedNodeList> _sharedInstance;
LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort);
LimitedNodeList(LimitedNodeList const&); // Don't implement, needed to avoid copies of singleton

View file

@ -24,30 +24,31 @@
#include "SharedUtil.h"
#include "UUID.h"
NodeList* NodeList::_sharedInstance = NULL;
NodeList* NodeList::createInstance(char ownerType, unsigned short socketListenPort, unsigned short dtlsPort) {
if (!_sharedInstance) {
NodeType::init();
NodeType::init();
if (_sharedInstance.get()) {
qDebug() << "NodeList called with existing instance." <<
"Releasing auto_ptr, deleting existing instance and creating a new one.";
_sharedInstance = new NodeList(ownerType, socketListenPort, dtlsPort);
LimitedNodeList::_sharedInstance = _sharedInstance;
// register the SharedNodePointer meta-type for signals/slots
qRegisterMetaType<SharedNodePointer>();
} else {
qDebug("NodeList createInstance called with existing instance.");
delete _sharedInstance.release();
}
return _sharedInstance;
_sharedInstance = std::auto_ptr<LimitedNodeList>(new NodeList(ownerType, socketListenPort, dtlsPort));
// register the SharedNodePointer meta-type for signals/slots
qRegisterMetaType<SharedNodePointer>();
return static_cast<NodeList*>(_sharedInstance.get());
}
NodeList* NodeList::getInstance() {
if (!_sharedInstance) {
if (!_sharedInstance.get()) {
qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.");
}
return _sharedInstance;
return static_cast<NodeList*>(_sharedInstance.get());
}
NodeList::NodeList(char newOwnerType, unsigned short socketListenPort, unsigned short dtlsListenPort) :

View file

@ -84,8 +84,6 @@ public slots:
signals:
void limitOfSilentDomainCheckInsReached();
private:
static NodeList* _sharedInstance;
NodeList(char ownerType, unsigned short socketListenPort, unsigned short dtlsListenPort);
NodeList(NodeList const&); // Don't implement, needed to avoid copies of singleton
void operator=(NodeList const&); // Don't implement, needed to avoid copies of singleton