diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 2559c00207..dd4e1dca18 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -67,10 +67,6 @@ endforeach(EXTERNAL_SOURCE_SUBDIR) find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) -find_package(Qxmpp REQUIRED) -add_definitions(-DQXMPP_STATIC) -include_directories(SYSTEM ${QXMPP_INCLUDE_DIR}) - # grab the ui files in resources/ui file (GLOB_RECURSE QT_UI_FILES ui/*.ui) # have qt5 wrap them and generate the appropriate header files @@ -132,6 +128,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) @@ -171,6 +168,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") @@ -182,7 +187,6 @@ target_link_libraries( ${TARGET_NAME} "${FACESHIFT_LIBRARIES}" "${ZLIB_LIBRARIES}" - "${QXMPP_LIBRARY}" Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools ) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 2331a1bceb..5f6c541bc5 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -164,10 +164,14 @@ Menu::Menu() : 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"); @@ -1046,10 +1050,12 @@ void Menu::showChat() { } void Menu::toggleChat() { +#ifdef HAVE_QXMPP _chatAction->setEnabled(XmppClient::getInstance().getXMPPClient().isConnected()); if (!_chatAction->isEnabled() && _chatWindow) { _chatWindow->close(); } +#endif } void Menu::audioMuteToggled() { diff --git a/interface/src/XmppClient.cpp b/interface/src/XmppClient.cpp index de0a47c28a..df8cf34874 100644 --- a/interface/src/XmppClient.cpp +++ b/interface/src/XmppClient.cpp @@ -6,6 +6,8 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // +#ifdef HAVE_QXMPP + #include #include "XmppClient.h" @@ -63,3 +65,5 @@ XmppClient::XmppClient(const XmppClient& other) { void XmppClient::operator =(XmppClient const& other) { Q_UNUSED(other); } + +#endif diff --git a/interface/src/XmppClient.h b/interface/src/XmppClient.h index 1ebe868424..905d6e64fb 100644 --- a/interface/src/XmppClient.h +++ b/interface/src/XmppClient.h @@ -6,6 +6,8 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // +#ifdef HAVE_QXMPP + #ifndef __interface__XmppClient__ #define __interface__XmppClient__ @@ -41,3 +43,5 @@ private: }; #endif // __interface__XmppClient__ + +#endif diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 09b50ebf46..e7b78a897a 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -40,7 +40,7 @@ ChatWindow::ChatWindow() : ui->messagePlainTextEdit->installEventFilter(this); setAttribute(Qt::WA_DeleteOnClose); - +#ifdef HAVE_QXMPP const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); if (xmppClient.isConnected()) { participantsChanged(); @@ -56,16 +56,18 @@ ChatWindow::ChatWindow() : 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; } @@ -80,12 +82,14 @@ bool ChatWindow::eventFilter(QObject* sender, QEvent* event) { (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; @@ -93,10 +97,12 @@ bool ChatWindow::eventFilter(QObject* sender, QEvent* event) { 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; @@ -133,10 +139,10 @@ void ChatWindow::connected() { 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(); } @@ -146,6 +152,8 @@ void ChatWindow::timeout() { } } +#ifdef HAVE_QXMPP + void ChatWindow::error(QXmppClient::Error error) { ui->connectingToXMPPLabel->setText(QString::number(error)); } @@ -200,3 +208,5 @@ void ChatWindow::messageReceived(const QXmppMessage& message) { lastMessageStamp = QDateTime::currentDateTime(); } } + +#endif diff --git a/interface/src/ui/ChatWindow.h b/interface/src/ui/ChatWindow.h index 16f8928d7e..9250da8933 100644 --- a/interface/src/ui/ChatWindow.h +++ b/interface/src/ui/ChatWindow.h @@ -15,9 +15,13 @@ #include +#ifdef HAVE_QXMPP + #include #include +#endif + namespace Ui { class ChatWindow; } @@ -33,7 +37,9 @@ protected: bool eventFilter(QObject* sender, QEvent* event); private: +#ifdef HAVE_QXMPP QString getParticipantName(const QString& participant); +#endif void startTimerForTimeStamps(); void addTimeStamp(); @@ -44,9 +50,11 @@ private: 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__) */