Merge branch 'master' of https://github.com/worklist/hifi into blendface

This commit is contained in:
Andrzej Kapolka 2013-09-19 16:37:26 -07:00
commit 5c841616dc
11 changed files with 79 additions and 139 deletions

View file

@ -988,31 +988,31 @@ HTML_INDEX_NUM_ENTRIES = 100
# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# for more information.
GENERATE_DOCSET = NO
GENERATE_DOCSET = YES
# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
# feed. A documentation feed provides an umbrella under which multiple
# documentation sets from a single provider (such as a company or product suite)
# can be grouped.
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_FEEDNAME = "HiFi documentation"
# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
# should uniquely identify the documentation set bundle. This should be a
# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
# will append .docset to the name.
DOCSET_BUNDLE_ID = org.doxygen.Project
DOCSET_BUNDLE_ID = io.highfidelity.HiFi
# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely
# identify the documentation publisher. This should be a reverse domain-name
# style string, e.g. com.mycompany.MyDocSet.documentation.
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
DOCSET_PUBLISHER_ID = io.highfidelity.HiFi.HighFidelity
# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
DOCSET_PUBLISHER_NAME = Publisher
DOCSET_PUBLISHER_NAME = High Fidelity
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the

View file

@ -80,22 +80,11 @@ void childClient() {
qDebug() << "Received an assignment -" << *deployedAssignment << "\n";
// switch our nodelist DOMAIN_IP
if (packetData[0] == PACKET_TYPE_CREATE_ASSIGNMENT ||
deployedAssignment->getAttachedPublicSocket()->sa_family == AF_INET) {
// switch our nodelist domain IP and port to whoever sent us the assignment
if (packetData[0] == PACKET_TYPE_CREATE_ASSIGNMENT) {
sockaddr* domainSocket = NULL;
if (packetData[0] == PACKET_TYPE_CREATE_ASSIGNMENT) {
// the domain server IP address is the address we got this packet from
domainSocket = (sockaddr*) &senderSocket;
} else {
// grab the domain server IP address from the packet from the AS
domainSocket = (sockaddr*) deployedAssignment->getAttachedPublicSocket();
}
nodeList->setDomainIP(QHostAddress(domainSocket));
nodeList->setDomainIP(QHostAddress((sockaddr*) &senderSocket));
nodeList->setDomainPort(ntohs(senderSocket.sin_port));
qDebug("Destination IP for assignment is %s\n", nodeList->getDomainIP().toString().toStdString().c_str());
@ -112,7 +101,7 @@ void childClient() {
// reset our NodeList by switching back to unassigned and clearing the list
nodeList->setOwnerType(NODE_TYPE_UNASSIGNED);
nodeList->clear();
nodeList->reset();
// reset the logging target to the the CHILD_TARGET_NAME
Logging::setTargetName(CHILD_TARGET_NAME);
@ -196,12 +185,19 @@ int main(int argc, const char* argv[]) {
// grab the overriden assignment-server hostname from argv, if it exists
const char* customAssignmentServerHostname = getCmdOption(argc, argv, CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION);
const char* customAssignmentServerPortString = getCmdOption(argc, argv, CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION);
if (customAssignmentServerHostname) {
const char* customAssignmentServerPortString = getCmdOption(argc, argv, CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION);
if (customAssignmentServerHostname || customAssignmentServerPortString) {
// set the custom port or default if it wasn't passed
unsigned short assignmentServerPort = customAssignmentServerPortString
? atoi(customAssignmentServerPortString) : DEFAULT_DOMAIN_SERVER_PORT;
// set the custom hostname or default if it wasn't passed
if (!customAssignmentServerHostname) {
customAssignmentServerHostname = LOCAL_ASSIGNMENT_SERVER_HOSTNAME;
}
::customAssignmentSocket = socketForHostnameAndHostOrderPort(customAssignmentServerHostname, assignmentServerPort);
}

View file

@ -185,9 +185,6 @@ int main(int argc, const char* argv[]) {
// Start the web server.
ctx = mg_start(&callbacks, NULL, options);
// wait to check on voxel-servers till we've given our NodeList a chance to get a good list
int checkForVoxelServerAttempt = 0;
while (true) {
::assignmentQueueMutex.lock();
@ -196,33 +193,36 @@ int main(int argc, const char* argv[]) {
if (!nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER) &&
std::find(::assignmentQueue.begin(), assignmentQueue.end(), &avatarMixerAssignment) == ::assignmentQueue.end()) {
qDebug("Missing an avatar mixer and assignment not in queue. Adding.\n");
// reset the UUID so it is new
avatarMixerAssignment.resetUUID();
::assignmentQueue.push_front(&avatarMixerAssignment);
}
if (!nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER) &&
std::find(::assignmentQueue.begin(), ::assignmentQueue.end(), &audioMixerAssignment) == ::assignmentQueue.end()) {
qDebug("Missing an audio mixer and assignment not in queue. Adding.\n");
// reset the UUID so it is new
audioMixerAssignment.resetUUID();
::assignmentQueue.push_front(&audioMixerAssignment);
}
// Now handle voxel servers. Couple of things are special about voxel servers.
// 1) They can run standalone, and so we want to wait to ask for an assignment until we've given them sufficient
// time to check in with us. So we will look for them, but we want actually add assignments unless we haven't
// seen one after a few tries.
// 2) They aren't soloNodeOfType() so we have to count them.
// Now handle voxel servers. Since Voxel Servers aren't soloNodeOfType() we will count them and add an assignment if
// there is not at least one of them in the domain.
int voxelServerCount = 0;
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
voxelServerCount++;
}
}
const int MIN_VOXEL_SERVER_CHECKS = 10;
if (checkForVoxelServerAttempt > MIN_VOXEL_SERVER_CHECKS && voxelServerCount == 0 &&
if (voxelServerCount == 0 &&
std::find(::assignmentQueue.begin(), ::assignmentQueue.end(), &voxelServerAssignment) == ::assignmentQueue.end()) {
qDebug("Missing a voxel server and assignment not in queue. Adding.\n");
::assignmentQueue.push_front(&voxelServerAssignment);
}
checkForVoxelServerAttempt++;
::assignmentQueueMutex.unlock();
@ -273,7 +273,6 @@ int main(int argc, const char* argv[]) {
Assignment::Type matchType = nodeType == NODE_TYPE_AUDIO_MIXER
? Assignment::AudioMixerType : Assignment::AvatarMixerType;
// enumerate the assignments and see if there is a type and UUID match
while (assignment != ::assignmentQueue.end()) {
@ -367,8 +366,6 @@ int main(int argc, const char* argv[]) {
if (requestAssignment.getType() == Assignment::AllTypes ||
(*assignment)->getType() == requestAssignment.getType()) {
// attach our local socket to the assignment
(*assignment)->setAttachedLocalSocket((sockaddr*) &localSocket);
// give this assignment out, either the type matches or the requestor said they will take any
int numHeaderBytes = populateTypeAndVersion(broadcastPacket, PACKET_TYPE_CREATE_ASSIGNMENT);
@ -388,14 +385,16 @@ int main(int argc, const char* argv[]) {
delete *assignment;
}
} else {
Assignment *sentAssignment = *assignment;
// remove the assignment from the queue
::assignmentQueue.erase(assignment);
if ((*assignment)->getType() != Assignment::VoxelServerType) {
if (sentAssignment->getType() != Assignment::VoxelServerType) {
// keep audio-mixer and avatar-mixer assignments in the queue
// until we get a check-in from that GUID
// but stick it at the back so the others have a chance to go out
::assignmentQueue.push_back(*assignment);
::assignmentQueue.push_back(sentAssignment);
}
}

View file

@ -321,7 +321,7 @@ void Application::initializeGL() {
Menu::getInstance()->checkForUpdates();
#endif
InfoView::showFirstTime();
InfoView::showFirstTime(Menu::getInstance());
}
void Application::paintGL() {

View file

@ -17,7 +17,8 @@
#define SETTINGS_VERSION_KEY "info-version"
#define MAX_DIALOG_HEIGHT_RATIO 0.9
InfoView::InfoView(bool forced) :
InfoView::InfoView(bool forced, QWidget* parent) :
QWebView(parent),
_forced(forced) {
switchToResourcesParentIfRequired();
@ -28,12 +29,12 @@ InfoView::InfoView(bool forced) :
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loaded(bool)));
}
void InfoView::showFirstTime() {
new InfoView(false);
void InfoView::showFirstTime(QWidget* parent) {
new InfoView(false, parent);
}
void InfoView::forcedShow() {
new InfoView(true);
void InfoView::forcedShow(QWidget* parent) {
new InfoView(true, parent);
}
bool InfoView::shouldShow() {
@ -45,18 +46,15 @@ bool InfoView::shouldShow() {
QString lastVersion = settings->value(SETTINGS_VERSION_KEY).toString();
QWebFrame* mainFrame = page()->mainFrame();
QWebElement versionTag = mainFrame->findFirstElement("#version");
QWebElement versionTag = page()->mainFrame()->findFirstElement("#version");
QString version = versionTag.attribute("value");
if (lastVersion == QString::null || version == QString::null || lastVersion != version) {
if (version != QString::null) {
settings->setValue(SETTINGS_VERSION_KEY, version);
}
if (version != QString::null && (lastVersion == QString::null || lastVersion != version)) {
settings->setValue(SETTINGS_VERSION_KEY, version);
return true;
}
return false;
} else {
return false;
}
}
void InfoView::loaded(bool ok) {

View file

@ -14,11 +14,11 @@
class InfoView : public QWebView {
Q_OBJECT
public:
static void showFirstTime();
static void forcedShow();
static void showFirstTime(QWidget* parent);
static void forcedShow(QWidget* parent);
private:
InfoView(bool forced);
InfoView(bool forced, QWidget* parent);
bool _forced;
bool shouldShow();

View file

@ -685,7 +685,7 @@ bool Menu::isVoxelModeActionChecked() {
}
void Menu::aboutApp() {
InfoView::forcedShow();
InfoView::forcedShow(this);
}
void updateDSHostname(const QString& domainServerHostname) {

View file

@ -18,8 +18,6 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, Assig
_command(command),
_type(type),
_location(location),
_attachedPublicSocket(NULL),
_attachedLocalSocket(NULL),
_numberOfInstances(1),
_payload(NULL),
_numPayloadBytes(0)
@ -35,8 +33,6 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, Assig
Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
_location(GlobalLocation),
_attachedPublicSocket(NULL),
_attachedLocalSocket(NULL),
_numberOfInstances(1),
_payload(NULL),
_numPayloadBytes(0)
@ -59,32 +55,11 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
memcpy(&_type, dataBuffer + numBytesRead, sizeof(Assignment::Type));
numBytesRead += sizeof(Assignment::Type);
if (dataBuffer[0] != PACKET_TYPE_REQUEST_ASSIGNMENT) {
if (_command != Assignment::RequestCommand) {
// read the GUID for this assignment
_uuid = QUuid::fromRfc4122(QByteArray((const char*) dataBuffer + numBytesRead, NUM_BYTES_RFC4122_UUID));
numBytesRead += NUM_BYTES_RFC4122_UUID;
}
if (_command != Assignment::RequestCommand) {
sockaddr* newSocket = NULL;
if (dataBuffer[numBytesRead++] == IPv4_ADDRESS_DESIGNATOR) {
// IPv4 address
newSocket = (sockaddr*) new sockaddr_in;
numBytesRead += unpackSocket(dataBuffer + numBytesRead, newSocket);
if (_command == Assignment::CreateCommand) {
delete _attachedLocalSocket;
_attachedLocalSocket = newSocket;
} else {
delete _attachedPublicSocket;
_attachedPublicSocket = newSocket;
}
} else {
// IPv6 address, or bad designator
qDebug("Received a socket that cannot be unpacked!\n");
}
}
if (numBytes > numBytesRead) {
_numPayloadBytes = numBytes - numBytesRead;
@ -94,8 +69,6 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
}
Assignment::~Assignment() {
delete _attachedPublicSocket;
delete _attachedLocalSocket;
delete[] _payload;
_numPayloadBytes = 0;
}
@ -123,30 +96,6 @@ QString Assignment::getUUIDStringWithoutCurlyBraces() const {
return _uuid.toString().mid(1, _uuid.toString().length() - 2);
}
void Assignment::setAttachedPublicSocket(const sockaddr* attachedPublicSocket) {
if (_attachedPublicSocket) {
// delete the old socket if it exists
delete _attachedPublicSocket;
_attachedPublicSocket = NULL;
}
if (attachedPublicSocket) {
copySocketToEmptySocketPointer(&_attachedPublicSocket, attachedPublicSocket);
}
}
void Assignment::setAttachedLocalSocket(const sockaddr* attachedLocalSocket) {
if (_attachedLocalSocket) {
// delete the old socket if it exists
delete _attachedLocalSocket;
_attachedLocalSocket = NULL;
}
if (attachedLocalSocket) {
copySocketToEmptySocketPointer(&_attachedLocalSocket, attachedLocalSocket);
}
}
int Assignment::packToBuffer(unsigned char* buffer) {
int numPackedBytes = 0;
@ -159,19 +108,11 @@ int Assignment::packToBuffer(unsigned char* buffer) {
numPackedBytes += NUM_BYTES_RFC4122_UUID;
}
if (_attachedPublicSocket || _attachedLocalSocket) {
sockaddr* socketToPack = (_attachedPublicSocket) ? _attachedPublicSocket : _attachedLocalSocket;
// we have a socket to pack, add the designator
buffer[numPackedBytes++] = (socketToPack->sa_family == AF_INET)
? IPv4_ADDRESS_DESIGNATOR : IPv6_ADDRESS_DESIGNATOR;
numPackedBytes += packSocket(buffer + numPackedBytes, socketToPack);
}
if (_numPayloadBytes) {
memcpy(buffer + numPackedBytes, _payload, _numPayloadBytes);
numPackedBytes += _numPayloadBytes;
}
return numPackedBytes;
}

View file

@ -43,7 +43,7 @@ public:
Assignment(Assignment::Command command,
Assignment::Type type,
Assignment::Location location = Assignment::GlobalLocation);
Assignment::Location location = Assignment::LocalLocation);
/// Constructs an Assignment from the data in the buffer
/// \param dataBuffer the source buffer to un-pack the assignment from
@ -54,6 +54,8 @@ public:
const QUuid& getUUID() const { return _uuid; }
QString getUUIDStringWithoutCurlyBraces() const;
void resetUUID() { _uuid = QUuid::createUuid(); }
Assignment::Command getCommand() const { return _command; }
Assignment::Type getType() const { return _type; }
Assignment::Location getLocation() const { return _location; }
@ -66,12 +68,6 @@ public:
int getNumberOfInstances() const { return _numberOfInstances; }
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
void decrementNumberOfInstances() { --_numberOfInstances; }
const sockaddr* getAttachedPublicSocket() { return _attachedPublicSocket; }
void setAttachedPublicSocket(const sockaddr* attachedPublicSocket);
const sockaddr* getAttachedLocalSocket() { return _attachedLocalSocket; }
void setAttachedLocalSocket(const sockaddr* attachedLocalSocket);
/// Packs the assignment to the passed buffer
/// \param buffer the buffer in which to pack the assignment
@ -89,8 +85,6 @@ private:
Assignment::Command _command; /// the command for this assignment (Create, Deploy, Request)
Assignment::Type _type; /// the type of the assignment, defines what the assignee will do
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
sockaddr* _attachedPublicSocket; /// pointer to a public socket that relates to assignment, depends on direction
sockaddr* _attachedLocalSocket; /// pointer to a local socket that relates to assignment, depends on direction
timeval _time; /// time the assignment was created (set in constructor)
int _numberOfInstances; /// the number of instances of this assignment
uchar *_payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed

View file

@ -70,7 +70,9 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
_ownerID(UNKNOWN_NODE_ID),
_lastNodeID(UNKNOWN_NODE_ID + 1),
_numNoReplyDomainCheckIns(0),
_assignmentServerSocket(NULL)
_assignmentServerSocket(NULL),
_checkInPacket(NULL),
_numBytesCheckInPacket(0)
{
}
@ -263,7 +265,16 @@ void NodeList::clear() {
}
_numNodes = 0;
}
void NodeList::reset() {
clear();
_numNoReplyDomainCheckIns = 0;
delete[] _checkInPacket;
_checkInPacket = NULL;
_numBytesCheckInPacket = 0;
}
void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest) {
@ -304,11 +315,8 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
printedDomainServerIP = true;
}
static unsigned char* checkInPacket = NULL;
static int checkInPacketSize = 0;
// construct the DS check in packet if we need to
if (!checkInPacket) {
if (!_checkInPacket) {
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
const int IP_ADDRESS_BYTES = 4;
@ -317,8 +325,8 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) +
NUM_BYTES_RFC4122_UUID + sizeof(uint16_t) + IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
checkInPacket = new unsigned char[numPacketBytes];
unsigned char* packetPosition = checkInPacket;
_checkInPacket = new unsigned char[numPacketBytes];
unsigned char* packetPosition = _checkInPacket;
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
@ -335,7 +343,7 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
packetPosition += NUM_BYTES_RFC4122_UUID;
}
packetPosition += packSocket(checkInPacket + (packetPosition - checkInPacket),
packetPosition += packSocket(_checkInPacket + (packetPosition - _checkInPacket),
getLocalAddress(),
htons(_nodeSocket.getListeningPort()));
@ -350,10 +358,10 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
packetPosition += numBytesNodesOfInterest;
}
checkInPacketSize = packetPosition - checkInPacket;
_numBytesCheckInPacket = packetPosition - _checkInPacket;
}
_nodeSocket.send(_domainIP.toString().toStdString().c_str(), _domainPort, checkInPacket, checkInPacketSize);
_nodeSocket.send(_domainIP.toString().toStdString().c_str(), _domainPort, _checkInPacket, _numBytesCheckInPacket);
// increment the count of un-replied check-ins
_numNoReplyDomainCheckIns++;
@ -398,7 +406,6 @@ int NodeList::processDomainServerList(unsigned char* packetData, size_t dataByte
return readNodes;
}
const char LOCAL_ASSIGNMENT_SERVER_HOSTNAME[] = "localhost";
const sockaddr_in DEFAULT_LOCAL_ASSIGNMENT_SOCKET = socketForHostnameAndHostOrderPort(LOCAL_ASSIGNMENT_SERVER_HOSTNAME,
DEFAULT_DOMAIN_SERVER_PORT);
void NodeList::sendAssignment(Assignment& assignment) {

View file

@ -40,6 +40,8 @@ const int MAX_HOSTNAME_BYTES = 256;
extern const QString DEFAULT_DOMAIN_HOSTNAME;
extern const unsigned short DEFAULT_DOMAIN_SERVER_PORT;
const char LOCAL_ASSIGNMENT_SERVER_HOSTNAME[] = "localhost";
const int UNKNOWN_NODE_ID = 0;
const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5;
@ -96,6 +98,7 @@ public:
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
void clear();
void reset();
void setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNodeTypesOfInterest);
@ -157,6 +160,8 @@ private:
pthread_t checkInWithDomainServerThread;
int _numNoReplyDomainCheckIns;
sockaddr* _assignmentServerSocket;
uchar* _checkInPacket;
int _numBytesCheckInPacket;
void handlePingReply(sockaddr *nodeAddress);
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);