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

This commit is contained in:
ZappoMan 2014-03-12 01:21:33 -07:00
commit 7ce741762e
21 changed files with 3822 additions and 16 deletions

View file

@ -0,0 +1,114 @@
#=============================================================================
# Copyright 2005-2011 Kitware, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * 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.
#
# * Neither the name of Kitware, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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 COPYRIGHT
# HOLDER 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.
#=============================================================================
function(QT5_CREATE_TRANSLATION_CUSTOM _qm_files)
set(options)
set(oneValueArgs)
set(multiValueArgs OPTIONS)
cmake_parse_arguments(_LUPDATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(_lupdate_files ${_LUPDATE_UNPARSED_ARGUMENTS})
set(_lupdate_options ${_LUPDATE_OPTIONS})
set(_my_sources)
set(_my_tsfiles)
foreach(_file ${_lupdate_files})
get_filename_component(_ext ${_file} EXT)
get_filename_component(_abs_FILE ${_file} ABSOLUTE)
if(_ext MATCHES "ts")
list(APPEND _my_tsfiles ${_abs_FILE})
else()
list(APPEND _my_sources ${_abs_FILE})
endif()
endforeach()
set(_my_temptsfiles)
foreach(_ts_file ${_my_tsfiles})
if(_my_sources)
# make a list file to call lupdate on, so we don't make our commands too
# long for some systems
get_filename_component(_ts_name ${_ts_file} NAME_WE)
set(_ts_lst_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lst_file")
set(_lst_file_srcs)
foreach(_lst_file_src ${_my_sources})
set(_lst_file_srcs "${_lst_file_src}\n${_lst_file_srcs}")
endforeach()
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
foreach(_pro_include ${_inc_DIRS})
get_filename_component(_abs_include "${_pro_include}" ABSOLUTE)
set(_lst_file_srcs "-I${_pro_include}\n${_lst_file_srcs}")
endforeach()
file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
endif()
get_filename_component(_ts_nm ${_ts_file} NAME)
set(_tmpts_file "${CMAKE_CURRENT_BINARY_DIR}/${_ts_nm}")
list(APPEND _my_temptsfiles ${_tmpts_file})
get_source_file_property(_qm_output_location ${_ts_file} OUTPUT_LOCATION)
add_custom_command(
OUTPUT ${_tmpts_file}
COMMAND ${Qt5_LUPDATE_EXECUTABLE}
ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
COMMAND ${CMAKE_COMMAND} -E copy ${_ts_file} ${_tmpts_file}
DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM)
if( _qm_output_location )
set_property(SOURCE ${_tmpts_file} PROPERTY OUTPUT_LOCATION ${_qm_output_location})
endif()
endforeach()
qt5_add_translation(${_qm_files} ${_my_temptsfiles})
set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
endfunction()
function(QT5_ADD_TRANSLATION _qm_files)
foreach(_current_FILE ${ARGN})
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
get_filename_component(qm ${_abs_FILE} NAME_WE)
get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION)
if(output_location)
file(MAKE_DIRECTORY "${output_location}")
set(qm "${output_location}/${qm}.qm")
else()
set(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
endif()
add_custom_command(OUTPUT ${qm}
COMMAND ${Qt5_LRELEASE_EXECUTABLE}
ARGS ${_abs_FILE} -qm ${qm}
DEPENDS ${_abs_FILE} VERBATIM
)
list(APPEND ${_qm_files} ${qm})
endforeach()
set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
endfunction()

View file

@ -0,0 +1,38 @@
# Try to find the qxmpp library
#
# You can provide a QXMPP_ROOT_DIR which contains lib and include directories
#
# Once done this will define
#
# QXMPP_FOUND - system found qxmpp
# QXMPP_INCLUDE_DIRS - the qxmpp include directory
# QXMPP_LIBRARIES - Link this to use qxmpp
#
# Created on 3/10/2014 by Stephen Birarda
# Copyright (c) 2014 High Fidelity
#
if (QXMPP_LIBRARIES AND QXMPP_INCLUDE_DIRS)
# in cache already
set(QXMPP_FOUND TRUE)
else ()
set(QXMPP_SEARCH_DIRS "${QXMPP_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/qxmpp")
find_path(QXMPP_INCLUDE_DIR QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS})
find_library(QXMPP_LIBRARY NAMES qxmpp qxmpp0 qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIR QXMPP_LIBRARY)
if (QXMPP_FOUND)
if (NOT QXMPP_FIND_QUIETLY)
message(STATUS "Found qxmpp: ${QXMPP_LIBRARY}")
endif ()
else ()
if (QXMPP_FIND_REQUIRED)
message(FATAL_ERROR "Could not find qxmpp")
endif ()
endif ()
endif ()

View file

@ -17,6 +17,9 @@ set(LIBOVR_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/oculus")
set(SIXENSE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/Sixense")
set(VISAGE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/visage")
find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5LinguistToolsMacros)
if (DEFINED ENV{JOB_ID})
set(BUILD_SEQ $ENV{JOB_ID})
else ()
@ -73,6 +76,10 @@ qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}")
# add them to the interface source files
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}")
set(QM ${TARGET_NAME}_en.qm)
set(TS ${TARGET_NAME}_en.ts)
qt5_create_translation_custom(${QM} ${INTERFACE_SRCS} ${QT_UI_FILES} ${TS})
if (APPLE)
# configure CMake to use a custom Info.plist
SET_TARGET_PROPERTIES( ${this_target} PROPERTIES MACOSX_BUNDLE_INFO_PLIST MacOSXBundleInfo.plist.in )
@ -101,7 +108,7 @@ if (APPLE)
endif()
# create the executable, make it a bundle on OS X
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS})
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM})
# link in the hifi shared library
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
@ -122,6 +129,7 @@ find_package(LibOVR)
find_package(Sixense)
find_package(Visage)
find_package(ZLIB)
find_package(Qxmpp)
# include the Sixense library for Razer Hydra if available
if (SIXENSE_FOUND AND NOT DISABLE_SIXENSE)
@ -139,7 +147,8 @@ if (VISAGE_FOUND AND NOT DISABLE_VISAGE)
include_directories(SYSTEM "${VISAGE_INCLUDE_DIRS}")
if (APPLE)
add_definitions(-DMAC_OS_X)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem ${VISAGE_INCLUDE_DIRS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment")
include_directories(SYSTEM "${VISAGE_INCLUDE_DIRS}")
find_library(AVFoundation AVFoundation)
find_library(CoreMedia CoreMedia)
find_library(NEW_STD_LIBRARY libc++.dylib /usr/lib/)
@ -160,6 +169,14 @@ if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
target_link_libraries(${TARGET_NAME} "${LIBOVR_LIBRARIES}")
endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
# and with qxmpp for chat
if (QXMPP_FOUND AND NOT DISABLE_QXMPP)
add_definitions(-DHAVE_QXMPP -DQXMPP_STATIC)
include_directories(SYSTEM ${QXMPP_INCLUDE_DIR})
target_link_libraries(${TARGET_NAME} "${QXMPP_LIBRARY}")
endif (QXMPP_FOUND AND NOT DISABLE_QXMPP)
# include headers for interface and InterfaceConfig.
include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes")

161
interface/interface_en.ts Normal file
View file

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>Application</name>
<message>
<location filename="src/Application.cpp" line="1375"/>
<source>Export Voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="1376"/>
<source>Sparse Voxel Octree Files (*.svo)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3562"/>
<source>Open Script</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3563"/>
<source>JavaScript Files (*.js)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatWindow</name>
<message>
<location filename="ui/chatWindow.ui" line="14"/>
<location filename="../build/interface/ui_chatWindow.h" line="111"/>
<source>Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/chatWindow.ui" line="41"/>
<location filename="../build/interface/ui_chatWindow.h" line="112"/>
<source>Connecting to XMPP...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/chatWindow.ui" line="60"/>
<location filename="../build/interface/ui_chatWindow.h" line="113"/>
<source> online now:</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="110"/>
<source>day</source>
<translation>
<numerusform>%n day</numerusform>
<numerusform>%n days</numerusform>
</translation>
</message>
<message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="110"/>
<source>hour</source>
<translation>
<numerusform>%n hour</numerusform>
<numerusform>%n hours</numerusform>
</translation>
</message>
<message numerus="yes">
<location filename="src/ui/ChatWindow.cpp" line="110"/>
<source>minute</source>
<translation>
<numerusform>%n minute</numerusform>
<numerusform>%n minutes</numerusform>
</translation>
</message>
<message numerus="yes">
<source>second</source>
<translation type="vanished">
<numerusform>%n second</numerusform>
<numerusform>%n seconds</numerusform>
</translation>
</message>
<message>
<location filename="src/ui/ChatWindow.cpp" line="163"/>
<source>%1 online now:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Dialog</name>
<message>
<location filename="ui/updateDialog.ui" line="20"/>
<location filename="ui/updateDialog.ui" line="73"/>
<location filename="../build/interface/ui_updateDialog.h" line="137"/>
<location filename="../build/interface/ui_updateDialog.h" line="138"/>
<source>Update Required</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/updateDialog.ui" line="129"/>
<location filename="../build/interface/ui_updateDialog.h" line="140"/>
<source>Download</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/updateDialog.ui" line="151"/>
<location filename="../build/interface/ui_updateDialog.h" line="141"/>
<source>Skip Version</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/updateDialog.ui" line="173"/>
<location filename="../build/interface/ui_updateDialog.h" line="142"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Menu</name>
<message>
<location filename="src/Menu.cpp" line="418"/>
<source>Open .ini config file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="420"/>
<location filename="src/Menu.cpp" line="432"/>
<source>Text files (*.ini)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="430"/>
<source>Save .ini config file</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="src/ImportDialog.cpp" line="22"/>
<location filename="src/ImportDialog.cpp" line="23"/>
<source>Import Voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/ImportDialog.cpp" line="24"/>
<source>Loading ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/ImportDialog.cpp" line="25"/>
<source>Place voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/ImportDialog.cpp" line="26"/>
<source>&lt;b&gt;Import&lt;/b&gt; %1 as voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/ImportDialog.cpp" line="27"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -26,6 +26,7 @@
#include <QWindow>
#include <AccountManager.h>
#include <XmppClient.h>
#include <UUID.h>
#include "Application.h"
@ -162,6 +163,15 @@ Menu::Menu() :
addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor()));
addActionToQMenuAndActionHash(toolsMenu, MenuOption::FstUploader, 0, Application::getInstance(), SLOT(uploadFST()));
_chatAction = addActionToQMenuAndActionHash(toolsMenu, MenuOption::Chat, 0, this, SLOT(showChat()));
#ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
toggleChat();
connect(&xmppClient, SIGNAL(connected()), this, SLOT(toggleChat()));
connect(&xmppClient, SIGNAL(disconnected()), this, SLOT(toggleChat()));
#else
_chatAction->setEnabled(false);
#endif
QMenu* viewMenu = addMenu("View");
@ -1021,6 +1031,33 @@ void Menu::showMetavoxelEditor() {
_MetavoxelEditor->raise();
}
void Menu::showChat() {
if (!_chatWindow) {
_chatWindow = new ChatWindow();
QMainWindow* mainWindow = Application::getInstance()->getWindow();
// the height of the title bar is given by frameGeometry().height() - geometry().height()
// however, frameGeometry() is initialised after showing (Qt queries the OS windowing system)
// on the other hand, moving a window after showing it flickers; so just use some reasonable value
int titleBarHeight = 16;
_chatWindow->setGeometry(mainWindow->width() - _chatWindow->width(),
mainWindow->geometry().y() + titleBarHeight,
_chatWindow->width(),
mainWindow->height() - titleBarHeight);
_chatWindow->show();
}
_chatWindow->raise();
}
void Menu::toggleChat() {
#ifdef HAVE_QXMPP
_chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected());
if (!_chatAction->isEnabled() && _chatWindow) {
_chatWindow->close();
}
#endif
}
void Menu::audioMuteToggled() {
QAction *muteAction = _actionHash.value(MenuOption::MuteAudio);
muteAction->setChecked(Application::getInstance()->getAudio()->getMuted());

View file

@ -18,6 +18,8 @@
#include <MenuItemProperties.h>
#include <OctreeConstants.h>
#include <ui/ChatWindow.h>
const float ADJUST_LOD_DOWN_FPS = 40.0;
const float ADJUST_LOD_UP_FPS = 55.0;
@ -53,6 +55,7 @@ class QSettings;
class BandwidthDialog;
class LodToolsDialog;
class MetavoxelEditor;
class ChatWindow;
class OctreeStatsDialog;
class MenuItemProperties;
@ -140,6 +143,8 @@ private slots:
void cycleFrustumRenderMode();
void runTests();
void showMetavoxelEditor();
void showChat();
void toggleChat();
void audioMuteToggled();
private:
@ -187,6 +192,7 @@ private:
FrustumDrawMode _frustumDrawMode;
ViewFrustumOffset _viewFrustumOffset;
QPointer<MetavoxelEditor> _MetavoxelEditor;
QPointer<ChatWindow> _chatWindow;
OctreeStatsDialog* _octreeStatsDialog;
LodToolsDialog* _lodToolsDialog;
int _maxVoxels;
@ -199,6 +205,7 @@ private:
quint64 _lastAdjust;
SimpleMovingAverage _fpsAverage;
QAction* _loginAction;
QAction* _chatAction;
};
namespace MenuOption {
@ -252,6 +259,7 @@ namespace MenuOption {
const QString Logout = "Logout";
const QString LookAtVectors = "Look-at Vectors";
const QString MetavoxelEditor = "Metavoxel Editor...";
const QString Chat = "Chat...";
const QString Metavoxels = "Metavoxels";
const QString Mirror = "Mirror";
const QString MoveWithLean = "Move with Lean";

View file

@ -0,0 +1,69 @@
//
// XmppClient.cpp
// interface
//
// Created by Dimitar Dobrev on 10/3/14
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifdef HAVE_QXMPP
#include <AccountManager.h>
#include "XmppClient.h"
const QString DEFAULT_XMPP_SERVER = "chat.highfidelity.io";
const QString DEFAULT_CHAT_ROOM = "public@public-chat.highfidelity.io";
XmppClient::XmppClient() :
_xmppClient(),
_xmppMUCManager()
{
AccountManager& accountManager = AccountManager::getInstance();
connect(&accountManager, SIGNAL(accessTokenChanged()), this, SLOT(connectToServer()));
connect(&accountManager, SIGNAL(logoutComplete()), this, SLOT(disconnectFromServer()));
}
XmppClient& XmppClient::getInstance() {
static XmppClient sharedInstance;
return sharedInstance;
}
void XmppClient::xmppConnected() {
_publicChatRoom = _xmppMUCManager.addRoom(DEFAULT_CHAT_ROOM);
_publicChatRoom->setNickName(AccountManager::getInstance().getUsername());
_publicChatRoom->join();
}
void XmppClient::xmppError(QXmppClient::Error error) {
qDebug() << "Error connnecting to XMPP for user " << AccountManager::getInstance().getUsername() << ": " << error;
}
void XmppClient::connectToServer() {
disconnectFromServer();
if (_xmppClient.addExtension(&_xmppMUCManager)) {
connect(&_xmppClient, SIGNAL(connected()), this, SLOT(xmppConnected()));
connect(&_xmppClient, SIGNAL(error(QXmppClient::Error)), this, SLOT(xmppError(QXmppClient::Error)));
}
AccountManager& accountManager = AccountManager::getInstance();
QString user = accountManager.getUsername();
const QString& password = accountManager.getXMPPPassword();
_xmppClient.connectToServer(user + "@" + DEFAULT_XMPP_SERVER, password);
}
void XmppClient::disconnectFromServer() {
if (_xmppClient.isConnected()) {
_xmppClient.disconnectFromServer();
}
}
XmppClient::XmppClient(const XmppClient& other) {
Q_UNUSED(other);
}
void XmppClient::operator =(XmppClient const& other) {
Q_UNUSED(other);
}
#endif

View file

@ -0,0 +1,47 @@
//
// XmppClient.h
// interface
//
// Created by Dimitar Dobrev on 10/3/14
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifdef HAVE_QXMPP
#ifndef __interface__XmppClient__
#define __interface__XmppClient__
#include <QObject>
#include <QXmppClient.h>
#include <QXmppMucManager.h>
/// Generalized threaded processor for handling received inbound packets.
class XmppClient : public QObject {
Q_OBJECT
public:
static XmppClient& getInstance();
QXmppClient& getXMPPClient() { return _xmppClient; }
const QXmppMucRoom* getPublicChatRoom() const { return _publicChatRoom; }
private slots:
void xmppConnected();
void xmppError(QXmppClient::Error error);
void connectToServer();
void disconnectFromServer();
private:
XmppClient();
XmppClient(XmppClient const& other); // not implemented
void operator=(XmppClient const& other); // not implemented
QXmppClient _xmppClient;
QXmppMucManager _xmppMUCManager;
QXmppMucRoom* _publicChatRoom;
};
#endif // __interface__XmppClient__
#endif

View file

@ -10,13 +10,15 @@
#include <SharedUtil.h>
#include "Application.h"
#include "Visage.h"
#include "renderer/FBXReader.h"
// this has to go after our normal includes, because its definition of HANDLE conflicts with Qt's
#ifdef HAVE_VISAGE
#include <VisageTracker2.h>
#endif
#include "Visage.h"
#include "renderer/FBXReader.h"
namespace VisageSDK {
#ifdef WIN32
void __declspec(dllimport) initializeLicenseManager(char* licenseKeyFileName);
@ -36,9 +38,9 @@ Visage::Visage() :
_estimatedEyeYaw(0.0f) {
#ifdef HAVE_VISAGE
QByteArray licensePath = Application::resourcesPath() + "visage/license.vlc";
QByteArray licensePath = Application::resourcesPath().toLatin1() + "visage/license.vlc";
initializeLicenseManager(licensePath.data());
_tracker = new VisageTracker2(Application::resourcesPath() + "visage/tracker.cfg");
_tracker = new VisageTracker2(Application::resourcesPath().toLatin1() + "visage/tracker.cfg");
if (_tracker->trackFromCam()) {
_data = new FaceData();

View file

@ -19,6 +19,7 @@
#include <QDebug>
#include <QDir>
#include <QTranslator>
#include <SharedUtil.h>
int main(int argc, const char * argv[]) {
@ -40,6 +41,10 @@ int main(int argc, const char * argv[]) {
{
QSettings::setDefaultFormat(QSettings::IniFormat);
Application app(argc, const_cast<char**>(argv), startup_time);
QTranslator translator;
translator.load("interface_en");
app.installTranslator(&translator);
qDebug( "Created QT Application.");
exitCode = app.exec();

View file

@ -0,0 +1,212 @@
//
// ChatWindow.cpp
// interface
//
// Created by Dimitar Dobrev on 3/6/14.
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
//
#include <QFormLayout>
#include <QFrame>
#include <QLayoutItem>
#include <QPalette>
#include <QScrollBar>
#include <QSizePolicy>
#include <QTextDocument>
#include <QTimer>
#include "Application.h"
#include "FlowLayout.h"
#include "qtimespan.h"
#include "ui_chatWindow.h"
#include "XmppClient.h"
#include "ChatWindow.h"
const int NUM_MESSAGES_TO_TIME_STAMP = 20;
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)");
ChatWindow::ChatWindow() :
QDialog(Application::getInstance()->getGLWidget(), Qt::Tool),
ui(new Ui::ChatWindow),
numMessagesAfterLastTimeStamp(0)
{
ui->setupUi(this);
FlowLayout* flowLayout = new FlowLayout(0, 4, 4);
ui->usersWidget->setLayout(flowLayout);
ui->messagePlainTextEdit->installEventFilter(this);
setAttribute(Qt::WA_DeleteOnClose);
#ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
if (xmppClient.isConnected()) {
participantsChanged();
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
connect(publicChatRoom, SIGNAL(participantsChanged()), this, SLOT(participantsChanged()));
ui->connectingToXMPPLabel->hide();
startTimerForTimeStamps();
} else {
ui->numOnlineLabel->hide();
ui->usersWidget->hide();
ui->messagesScrollArea->hide();
ui->messagePlainTextEdit->hide();
connect(&xmppClient, SIGNAL(connected()), this, SLOT(connected()));
}
connect(&xmppClient, SIGNAL(messageReceived(QXmppMessage)), this, SLOT(messageReceived(QXmppMessage)));
#endif
}
ChatWindow::~ChatWindow() {
#ifdef HAVE_QXMPP
const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient();
disconnect(&xmppClient, SIGNAL(connected()), this, SLOT(connected()));
disconnect(&xmppClient, SIGNAL(messageReceived(QXmppMessage)), this, SLOT(messageReceived(QXmppMessage)));
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
disconnect(publicChatRoom, SIGNAL(participantsChanged()), this, SLOT(participantsChanged()));
#endif
delete ui;
}
bool ChatWindow::eventFilter(QObject* sender, QEvent* event) {
Q_UNUSED(sender);
if (event->type() != QEvent::KeyPress) {
return false;
}
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) &&
(keyEvent->modifiers() & Qt::ShiftModifier) == 0) {
QString messageText = ui->messagePlainTextEdit->document()->toPlainText().trimmed();
if (!messageText.isEmpty()) {
#ifdef HAVE_QXMPP
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
QXmppMessage message;
message.setTo(publicChatRoom->jid());
message.setType(QXmppMessage::GroupChat);
message.setBody(messageText);
XmppClient::getInstance().getXMPPClient().sendPacket(message);
#endif
ui->messagePlainTextEdit->document()->clear();
}
return true;
}
return false;
}
#ifdef HAVE_QXMPP
QString ChatWindow::getParticipantName(const QString& participant) {
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
return participant.right(participant.count() - 1 - publicChatRoom->jid().count());
}
#endif
void ChatWindow::addTimeStamp() {
QTimeSpan timePassed = QDateTime::currentDateTime() - lastMessageStamp;
int times[] = { timePassed.daysPart(), timePassed.hoursPart(), timePassed.minutesPart() };
QString strings[] = { tr("day", 0, times[0]), tr("hour", 0, times[1]), tr("minute", 0, times[2]) };
QString timeString = "";
for (int i = 0; i < 3; i++) {
if (times[i] > 0) {
timeString += strings[i] + " ";
}
}
timeString.chop(1);
if (!timeString.isEmpty()) {
QLabel* timeLabel = new QLabel(timeString);
timeLabel->setStyleSheet("color: palette(shadow);"
"background-color: palette(highlight);"
"padding: 4px;");
timeLabel->setAlignment(Qt::AlignHCenter);
ui->messagesFormLayout->addRow(timeLabel);
numMessagesAfterLastTimeStamp = 0;
}
}
void ChatWindow::startTimerForTimeStamps() {
QTimer* timer = new QTimer(this);
timer->setInterval(10 * 60 * 1000);
connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
timer->start();
}
void ChatWindow::connected() {
ui->connectingToXMPPLabel->hide();
ui->numOnlineLabel->show();
ui->usersWidget->show();
ui->messagesScrollArea->show();
ui->messagePlainTextEdit->show();
#ifdef HAVE_QXMPP
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
connect(publicChatRoom, SIGNAL(participantsChanged()), this, SLOT(participantsChanged()));
#endif
startTimerForTimeStamps();
}
void ChatWindow::timeout() {
if (numMessagesAfterLastTimeStamp >= NUM_MESSAGES_TO_TIME_STAMP) {
addTimeStamp();
}
}
#ifdef HAVE_QXMPP
void ChatWindow::error(QXmppClient::Error error) {
ui->connectingToXMPPLabel->setText(QString::number(error));
}
void ChatWindow::participantsChanged() {
QStringList participants = XmppClient::getInstance().getPublicChatRoom()->participants();
ui->numOnlineLabel->setText(tr("%1 online now:").arg(participants.count()));
while (QLayoutItem* item = ui->usersWidget->layout()->takeAt(0)) {
delete item->widget();
delete item;
}
foreach (const QString& participant, participants) {
QLabel* userLabel = new QLabel(getParticipantName(participant));
userLabel->setStyleSheet("background-color: palette(light);"
"border-radius: 5px;"
"color: #267077;"
"padding: 2px;"
"border: 1px solid palette(shadow);"
"font-weight: bold");
ui->usersWidget->layout()->addWidget(userLabel);
}
}
void ChatWindow::messageReceived(const QXmppMessage& message) {
QLabel* userLabel = new QLabel(getParticipantName(message.from()));
QFont font = userLabel->font();
font.setBold(true);
userLabel->setFont(font);
userLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
userLabel->setStyleSheet("padding: 2px;");
userLabel->setAlignment(Qt::AlignTop);
QLabel* messageLabel = new QLabel(message.body().replace(regexLinks, "<a href=\"\\1\">\\1</a>"));
messageLabel->setWordWrap(true);
messageLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
messageLabel->setOpenExternalLinks(true);
messageLabel->setStyleSheet("padding: 2px;");
messageLabel->setAlignment(Qt::AlignTop);
ui->messagesFormLayout->addRow(userLabel, messageLabel);
ui->messagesFormLayout->parentWidget()->updateGeometry();
Application::processEvents();
QScrollBar* verticalScrollBar = ui->messagesScrollArea->verticalScrollBar();
verticalScrollBar->setSliderPosition(verticalScrollBar->maximum());
messageLabel->updateGeometry();
++numMessagesAfterLastTimeStamp;
if (message.stamp().isValid()) {
lastMessageStamp = message.stamp().toLocalTime();
} else {
lastMessageStamp = QDateTime::currentDateTime();
}
}
#endif

View file

@ -0,0 +1,60 @@
//
// ChatWindow.h
// interface
//
// Created by Dimitar Dobrev on 3/6/14.
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__ChatWindow__
#define __interface__ChatWindow__
#include <QDialog>
#include <QDateTime>
#include <QTimer>
#include <Application.h>
#ifdef HAVE_QXMPP
#include <QXmppClient.h>
#include <QXmppMessage.h>
#endif
namespace Ui {
class ChatWindow;
}
class ChatWindow : public QDialog {
Q_OBJECT
public:
ChatWindow();
~ChatWindow();
protected:
bool eventFilter(QObject* sender, QEvent* event);
private:
#ifdef HAVE_QXMPP
QString getParticipantName(const QString& participant);
#endif
void startTimerForTimeStamps();
void addTimeStamp();
Ui::ChatWindow* ui;
int numMessagesAfterLastTimeStamp;
QDateTime lastMessageStamp;
private slots:
void connected();
void timeout();
#ifdef HAVE_QXMPP
void error(QXmppClient::Error error);
void participantsChanged();
void messageReceived(const QXmppMessage& message);
#endif
};
#endif /* defined(__interface__ChatWindow__) */

View file

@ -0,0 +1,213 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * 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.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "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 COPYRIGHT
** OWNER 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."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets>
#include "FlowLayout.h"
//! [1]
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
: m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
//! [1]
//! [2]
FlowLayout::~FlowLayout()
{
QLayoutItem *item;
while ((item = takeAt(0)))
delete item;
}
//! [2]
//! [3]
void FlowLayout::addItem(QLayoutItem *item)
{
itemList.append(item);
}
//! [3]
//! [4]
int FlowLayout::horizontalSpacing() const
{
if (m_hSpace >= 0) {
return m_hSpace;
} else {
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
}
}
int FlowLayout::verticalSpacing() const
{
if (m_vSpace >= 0) {
return m_vSpace;
} else {
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
}
//! [4]
//! [5]
int FlowLayout::count() const
{
return itemList.size();
}
QLayoutItem *FlowLayout::itemAt(int index) const
{
return itemList.value(index);
}
QLayoutItem *FlowLayout::takeAt(int index)
{
if (index >= 0 && index < itemList.size())
return itemList.takeAt(index);
else
return 0;
}
//! [5]
//! [6]
Qt::Orientations FlowLayout::expandingDirections() const
{
return 0;
}
//! [6]
//! [7]
bool FlowLayout::hasHeightForWidth() const
{
return true;
}
int FlowLayout::heightForWidth(int width) const
{
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}
//! [7]
//! [8]
void FlowLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
doLayout(rect, false);
}
QSize FlowLayout::sizeHint() const
{
return minimumSize();
}
QSize FlowLayout::minimumSize() const
{
QSize size;
QLayoutItem *item;
foreach (item, itemList)
size = size.expandedTo(item->minimumSize());
size += QSize(2*margin(), 2*margin());
return size;
}
//! [8]
//! [9]
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;
//! [9]
//! [10]
QLayoutItem *item;
foreach (item, itemList) {
QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)
spaceX = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
int spaceY = verticalSpacing();
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
//! [10]
//! [11]
int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
y = y + lineHeight + spaceY;
nextX = x + item->sizeHint().width() + spaceX;
lineHeight = 0;
}
if (!testOnly)
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
x = nextX;
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
return y + lineHeight - rect.y() + bottom;
}
//! [11]
//! [12]
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
QObject *parent = this->parent();
if (!parent) {
return -1;
} else if (parent->isWidgetType()) {
QWidget *pw = static_cast<QWidget *>(parent);
return pw->style()->pixelMetric(pm, 0, pw);
} else {
return static_cast<QLayout *>(parent)->spacing();
}
}
//! [12]

View file

@ -0,0 +1,78 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * 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.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "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 COPYRIGHT
** OWNER 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."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef FLOWLAYOUT_H
#define FLOWLAYOUT_H
#include <QLayout>
#include <QRect>
#include <QStyle>
//! [0]
class FlowLayout : public QLayout
{
public:
explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
~FlowLayout();
void addItem(QLayoutItem *item);
int horizontalSpacing() const;
int verticalSpacing() const;
Qt::Orientations expandingDirections() const;
bool hasHeightForWidth() const;
int heightForWidth(int) const;
int count() const;
QLayoutItem *itemAt(int index) const;
QSize minimumSize() const;
void setGeometry(const QRect &rect);
QSize sizeHint() const;
QLayoutItem *takeAt(int index);
private:
int doLayout(const QRect &rect, bool testOnly) const;
int smartSpacing(QStyle::PixelMetric pm) const;
QList<QLayoutItem *> itemList;
int m_hSpace;
int m_vSpace;
};
//! [0]
#endif // FLOWLAYOUT_H

137
interface/ui/chatWindow.ui Normal file
View file

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChatWindow</class>
<widget class="QDialog" name="ChatWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>608</height>
</rect>
</property>
<property name="windowTitle">
<string>Chat</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="connectingToXMPPLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Connecting to XMPP...</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="numOnlineLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font-weight: bold; color: palette(shadow); margin-bottom: 4px;</string>
</property>
<property name="text">
<string> online now:</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="usersWidget" native="true"/>
</item>
<item>
<widget class="QScrollArea" name="messagesScrollArea">
<property name="styleSheet">
<string notr="true">margin-top: 12px;</string>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>358</width>
<height>328</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">margin-top: 0px;</string>
</property>
<layout class="QFormLayout" name="messagesFormLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="messagePlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>messagePlainTextEdit</tabstop>
<tabstop>messagesScrollArea</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View file

@ -10,7 +10,7 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
set(TARGET_NAME shared)
project(${TARGET_NAME})
find_package(Qt5 COMPONENTS Network Widgets)
find_package(Qt5 COMPONENTS Network Widgets Xml)
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
setup_hifi_library(${TARGET_NAME})
@ -19,7 +19,6 @@ setup_hifi_library(${TARGET_NAME})
include(${MACRO_DIR}/IncludeGLM.cmake)
include_glm(${TARGET_NAME} "${ROOT_DIR}")
set(EXTERNAL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external")
if (WIN32)
@ -33,4 +32,4 @@ if (UNIX AND NOT APPLE)
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
endif (UNIX AND NOT APPLE)
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets)
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets)

View file

@ -52,6 +52,8 @@ public:
void requestAccessToken(const QString& login, const QString& password);
QString getUsername() const { return _accountInfo.getUsername(); }
const QString& getXMPPPassword() const { return _accountInfo.getXMPPPassword(); }
void destroy() { delete _networkAccessManager; }

View file

@ -12,21 +12,26 @@
DataServerAccountInfo::DataServerAccountInfo() :
_accessToken(),
_username()
_username(),
_xmppPassword()
{
}
DataServerAccountInfo::DataServerAccountInfo(const QJsonObject& jsonObject) :
_accessToken(jsonObject),
_username()
_username(),
_xmppPassword()
{
setUsername(jsonObject["user"].toObject()["username"].toString());
QJsonObject userJSONObject = jsonObject["user"].toObject();
setUsername(userJSONObject["username"].toString());
setXMPPPassword(userJSONObject["xmpp_password"].toString());
}
DataServerAccountInfo::DataServerAccountInfo(const DataServerAccountInfo& otherInfo) {
_accessToken = otherInfo._accessToken;
_username = otherInfo._username;
_xmppPassword = otherInfo._xmppPassword;
}
DataServerAccountInfo& DataServerAccountInfo::operator=(const DataServerAccountInfo& otherInfo) {
@ -40,6 +45,7 @@ void DataServerAccountInfo::swap(DataServerAccountInfo& otherInfo) {
swap(_accessToken, otherInfo._accessToken);
swap(_username, otherInfo._username);
swap(_xmppPassword, otherInfo._xmppPassword);
}
void DataServerAccountInfo::setUsername(const QString& username) {
@ -50,12 +56,18 @@ void DataServerAccountInfo::setUsername(const QString& username) {
}
}
void DataServerAccountInfo::setXMPPPassword(const QString& xmppPassword) {
if (_xmppPassword != xmppPassword) {
_xmppPassword = xmppPassword;
}
}
QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info) {
out << info._accessToken << info._username;
out << info._accessToken << info._username << info._xmppPassword;
return out;
}
QDataStream& operator>>(QDataStream &in, DataServerAccountInfo& info) {
in >> info._accessToken >> info._username;
in >> info._accessToken >> info._username >> info._xmppPassword;
return in;
}
}

View file

@ -25,6 +25,9 @@ public:
const QString& getUsername() const { return _username; }
void setUsername(const QString& username);
const QString& getXMPPPassword() const { return _xmppPassword; }
void setXMPPPassword(const QString& xmppPassword);
friend QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info);
friend QDataStream& operator>>(QDataStream &in, DataServerAccountInfo& info);
@ -33,6 +36,7 @@ private:
OAuthAccessToken _accessToken;
QString _username;
QString _xmppPassword;
};
#endif /* defined(__hifi__DataServerAccountInfo__) */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,301 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTIMESPAN_H
#define QTIMESPAN_H
#include <QtCore/qdatetime.h>
#include <QtCore/qstring.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qmetatype.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Core)
//Move this to qnamespace.h when integrating
namespace Qt
{
enum TimeSpanUnit {
Milliseconds = 0x0001,
Seconds = 0x0002,
Minutes = 0x0004,
Hours = 0x0008,
Days = 0x0010,
Weeks = 0x0020,
Months = 0x0040,
Years = 0x0080,
DaysAndTime = Days | Hours | Minutes | Seconds,
AllUnits = Milliseconds | DaysAndTime | Months | Years,
NoUnit = 0
};
Q_DECLARE_FLAGS(TimeSpanFormat, TimeSpanUnit)
}
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TimeSpanFormat)
//end of section to move
class QTimeSpanPrivate;
class QTimeSpan
{
public:
QTimeSpan();
explicit QTimeSpan(qint64 msecs);
explicit QTimeSpan(const QDateTime& reference, qint64 msecs = 0);
explicit QTimeSpan(const QDate& reference, quint64 msecs = 0);
explicit QTimeSpan(const QTime& reference, quint64 msecs = 0);
explicit QTimeSpan(const QDateTime& reference, const QTimeSpan& other);
explicit QTimeSpan(const QDate& reference, const QTimeSpan& other);
explicit QTimeSpan(const QTime& reference, const QTimeSpan& other);
QTimeSpan(const QTimeSpan& other);
~QTimeSpan();
// constant time units
static const QTimeSpan Second;
static const QTimeSpan Minute;
static const QTimeSpan Hour;
static const QTimeSpan Day;
static const QTimeSpan Week;
// status/validity of the time span
bool isEmpty() const;
bool isNull() const;
// This set of functions operates on a single component of the time span.
inline int msecsPart(Qt::TimeSpanFormat format = Qt::DaysAndTime | Qt::Milliseconds) const {return part(Qt::Milliseconds, format);}
inline int secsPart(Qt::TimeSpanFormat format = Qt::DaysAndTime) const {return part(Qt::Seconds, format);}
inline int minutesPart(Qt::TimeSpanFormat format = Qt::DaysAndTime) const {return part(Qt::Minutes, format);}
inline int hoursPart(Qt::TimeSpanFormat format = Qt::DaysAndTime) const {return part(Qt::Hours, format);}
inline int daysPart(Qt::TimeSpanFormat format = Qt::DaysAndTime) const {return part(Qt::Days, format);}
inline int weeksPart(Qt::TimeSpanFormat format = Qt::DaysAndTime) const {return part(Qt::Weeks, format);}
//int monthsPart(Qt::TimeSpanFormat format) const;
//int yearsPart(Qt::TimeSpanFormat format) const;
int part(Qt::TimeSpanUnit unit, Qt::TimeSpanFormat format = Qt::DaysAndTime) const;
bool parts(int *msecondsPtr,
int *secondsPtr = 0,
int *minutesPtr = 0,
int *hoursPtr = 0,
int *daysPtr = 0,
int *weeksPtr = 0,
int *monthsPtr = 0,
int *yearsPtr = 0,
qreal *fractionalSmallestUnit = 0) const;
Qt::TimeSpanUnit magnitude();
inline void setMSecsPart(int msecs, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Milliseconds, msecs, format);}
inline void setSecsPart(int seconds, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Seconds, seconds, format);}
inline void setMinutesPart(int minutes, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Minutes, minutes, format);}
inline void setHoursPart(int hours, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Hours, hours, format);}
inline void setDaysPart(int days, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Days, days, format);}
inline void setWeeksPart(int weeks, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Weeks, weeks, format);}
inline void setMonthsPart(int months, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Months, months, format);}
inline void setYearsPart(int years, Qt::TimeSpanFormat format = Qt::DaysAndTime) {setPart(Qt::Years, years, format);}
void setPart(Qt::TimeSpanUnit unit, int interval, Qt::TimeSpanFormat format = Qt::DaysAndTime);
// This set of functions operator on the entire timespan and not
// just a single component of it.
qint64 toMSecs() const;
inline qreal toSecs() const {return toTimeUnit(Qt::Seconds);}
inline qreal toMinutes() const {return toTimeUnit(Qt::Minutes);}
inline qreal toHours() const {return toTimeUnit(Qt::Hours);}
inline qreal toDays() const {return toTimeUnit(Qt::Days);}
inline qreal toWeeks() const {return toTimeUnit(Qt::Weeks);}
inline qreal toMonths() const {return toTimeUnit(Qt::Seconds);}
inline qreal toYears() const {return toTimeUnit(Qt::Seconds);}
qreal toTimeUnit(Qt::TimeSpanUnit unit) const;
void setFromMSecs(qint64 msecs);
inline void setFromSecs(qreal secs) {setFromTimeUnit(Qt::Seconds, secs);}
inline void setFromMinutes(qreal minutes) {setFromTimeUnit(Qt::Minutes, minutes);}
inline void setFromHours(qreal hours) {setFromTimeUnit(Qt::Hours, hours);}
inline void setFromDays(qreal days) {setFromTimeUnit(Qt::Days, days);}
inline void setFromWeeks(qreal weeks) {setFromTimeUnit(Qt::Weeks, weeks);}
void setFromMonths(qreal months);
void setFromYears(qreal years);
void setFromTimeUnit(Qt::TimeSpanUnit unit, qreal interval);
// Reference date
bool hasValidReference() const;
QDateTime referenceDate() const;
void setReferenceDate(const QDateTime &referenceDate);
void moveReferenceDate(const QDateTime &referenceDate);
void setReferencedDate(const QDateTime &referencedDate);
void moveReferencedDate(const QDateTime &referencedDate);
// Referenced date - referenceDate() + *this
QDateTime referencedDate() const;
// Pretty printing
#ifndef QT_NO_DATESTRING
QString toString(const QString &format) const;
QString toApproximateString(int suppresSecondUnitLimit = 3,
Qt::TimeSpanFormat format = Qt::Seconds | Qt::Minutes | Qt::Hours | Qt::Days | Qt::Weeks);
#endif
// Assignment operator
QTimeSpan &operator=(const QTimeSpan& other);
// Comparison operators
bool operator==(const QTimeSpan &other) const;
inline bool operator!=(const QTimeSpan &other) const {return !(operator==(other));}
bool operator<(const QTimeSpan &other) const;
bool operator<=(const QTimeSpan &other) const;
inline bool operator>(const QTimeSpan &other) const {return !(operator<=(other));}
inline bool operator>=(const QTimeSpan &other) const {return !(operator<(other));}
bool matchesLength(const QTimeSpan &other, bool normalize = false) const;
// Arithmetic operators. Operators that don't change *this are declared as non-members.
QTimeSpan &operator+=(const QTimeSpan &other);
QTimeSpan &operator+=(qint64 msecs);
QTimeSpan &operator-=(const QTimeSpan &other);
QTimeSpan &operator-=(qint64 msecs);
QTimeSpan &operator*=(qreal factor);
QTimeSpan &operator*=(int factor);
QTimeSpan &operator/=(qreal factor);
QTimeSpan &operator/=(int factor);
QTimeSpan &operator|=(const QTimeSpan &other); // Union
QTimeSpan &operator&=(const QTimeSpan &other); // Intersection
// Ensure the reference date is before the referenced date
QTimeSpan normalized() const;
void normalize();
QTimeSpan abs() const;
bool isNegative() const;
bool isNormal() const {return !isNegative();}
// Naturally ordered dates
QDateTime startDate() const;
QDateTime endDate() const;
// Containment
bool contains(const QDateTime &dateTime) const;
bool contains(const QDate &date) const;
bool contains(const QTime &time) const;
bool contains(const QTimeSpan &other) const;
bool overlaps(const QTimeSpan &other) const;
QTimeSpan overlapped(const QTimeSpan &other) const;
QTimeSpan united(const QTimeSpan &other) const;
// Static construction methods
#ifndef QT_NO_DATESTRING
static QTimeSpan fromString(const QString &string, const QString &format, const QDateTime& reference = QDateTime());
static QTimeSpan fromString(const QString &string, const QRegExp &pattern, const QDateTime& reference,
Qt::TimeSpanUnit unit1,
Qt::TimeSpanUnit unit2 = Qt::NoUnit, Qt::TimeSpanUnit unit3 = Qt::NoUnit,
Qt::TimeSpanUnit unit4 = Qt::NoUnit, Qt::TimeSpanUnit unit5 = Qt::NoUnit,
Qt::TimeSpanUnit unit6 = Qt::NoUnit, Qt::TimeSpanUnit unit7 = Qt::NoUnit,
Qt::TimeSpanUnit unit8 = Qt::NoUnit);
#endif
//static QTimeSpan fromString(const QString &string, Qt::TimeSpanFormat format);
static QTimeSpan fromTimeUnit(Qt::TimeSpanUnit unit, qreal interval, const QDateTime& reference = QDateTime());
/*
static QTimeSpan fromMSecs(qint64 msecs);
static QTimeSpan fromSecs(qreal secs) {return QTimeSpan::Second * secs;}
static QTimeSpan fromMinutes(qreal minutes) {return QTimeSpan::Minute * minutes;}
static QTimeSpan fromHours(qreal hours) {return QTimeSpan::Hour * hours;}
static QTimeSpan fromDays(qreal days) {return QTimeSpan::Day * days;}
static QTimeSpan fromWeeks(qreal weeks) {return QTimeSpan::Week * weeks;}
*/
private:
#ifndef QT_NO_DATASTREAM
friend QDataStream &operator<<(QDataStream &, const QTimeSpan &);
friend QDataStream &operator>>(QDataStream &, QTimeSpan &);
#endif
QSharedDataPointer<QTimeSpanPrivate> d;
};
Q_DECLARE_TYPEINFO(QTimeSpan, Q_MOVABLE_TYPE);
Q_DECLARE_METATYPE(QTimeSpan);
Q_DECLARE_METATYPE(Qt::TimeSpanUnit);
//non-member operators
QTimeSpan operator+(const QTimeSpan &left, const QTimeSpan &right);
QTimeSpan operator-(const QTimeSpan &left, const QTimeSpan &right);
QTimeSpan operator*(const QTimeSpan &left, qreal right);//no problem
QTimeSpan operator*(const QTimeSpan &left, int right);//no problem
inline QTimeSpan operator*(qreal left, const QTimeSpan &right) {return right * left;} // works
inline QTimeSpan operator*(int left, const QTimeSpan &right) {return right * left;} // works
//QTimeSpan operator*(qreal left, const QTimeSpan &right) {return right * left;} //does not work
//QTimeSpan operator*(int left, const QTimeSpan &right) {return right * left;} //does not work
QTimeSpan operator/(const QTimeSpan &left, qreal right);
QTimeSpan operator/(const QTimeSpan &left, int right);
qreal operator/(const QTimeSpan &left, const QTimeSpan &right);
QTimeSpan operator-(const QTimeSpan &right); // Unary negation
QTimeSpan operator|(const QTimeSpan &left, const QTimeSpan &right); // Union
QTimeSpan operator&(const QTimeSpan &left, const QTimeSpan &right); // Intersection
// Operators that use QTimeSpan and other date/time classes
QTimeSpan operator-(const QDateTime &left, const QDateTime &right);
QTimeSpan operator-(const QDate &left, const QDate &right);
QTimeSpan operator-(const QTime &left, const QTime &right);
QDate operator+(const QDate &left, const QTimeSpan &right);
QDate operator-(const QDate &left, const QTimeSpan &right);
QTime operator+(const QTime &left, const QTimeSpan &right);
QTime operator-(const QTime &left, const QTimeSpan &right);
QDateTime operator+(const QDateTime &left, const QTimeSpan &right);
QDateTime operator-(const QDateTime &left, const QTimeSpan &right);
#ifndef QT_NO_DATASTREAM
QDataStream &operator<<(QDataStream &, const QTimeSpan &);
QDataStream &operator>>(QDataStream &, QTimeSpan &);
#endif // QT_NO_DATASTREAM
#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
QDebug operator<<(QDebug, const QTimeSpan &);
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif // QTIMESPAN_H