diff options
| author | Niels Ole Salscheider <niels_ole@salscheider-online.de> | 2018-06-23 17:20:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-23 17:20:47 +0200 |
| commit | ed6b199dff15ddb4c6bd72d1565501e9f1a2bf87 (patch) | |
| tree | 7bbb53c40ecf53fe9464b53b7966dd7726eeac5e | |
| parent | ea83c77a5a4524cc9778336b10eff60979582980 (diff) | |
| parent | 31f0a42073b68823e85835ec3e25114d79705a04 (diff) | |
| download | qxmpp-ed6b199dff15ddb4c6bd72d1565501e9f1a2bf87.tar.gz | |
Merge pull request #131 from olesalscheider/cmake
Add CMake build system, drop Qt4 support
165 files changed, 577 insertions, 9653 deletions
@@ -12,3 +12,7 @@ Ian Reinhart Geiser <geiseri@kde.org> Georg Rudoy <0xd34df00d@gmail.com> * Author of receipts manager, extended stanza addressing. + +Niels Ole Salscheider <niels_ole@salscheider-online.de> + * Build system, cleanups. + @@ -3,6 +3,8 @@ QXmpp 0.9.4 (UNRELEASED) - Do not ignore SSL errors by default (issue 113), if you need to deal with broken SSL configurations, set QXmppConfiguration::ignoreSslErrors to true. + - Drop Qt4 support + - CMake based build system QXmpp 0.9.3 (Dec 3, 2015) ------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..db0dbfe0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +project(qxmpp) + +cmake_minimum_required(VERSION 3.2) + +set(VERSION_MAJOR 0) +set(VERSION_MINOR 9) +set(VERSION_PATCH 4) +set(SO_VERSION 0) +set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) +mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_STRING) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules") + +find_package(Qt5 REQUIRED COMPONENTS Core Network Xml) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +include(GNUInstallDirs) + +option(BUILD_TESTS "Build tests." ON) +option(BUILD_DOCUMENTATION "Build API documentation." OFF) +option(BUILD_EXAMPLES "Build API documentation." OFF) + +add_subdirectory(src) + +if(BUILD_TESTS) + enable_testing() + add_subdirectory(tests) +endif() + +if(BUILD_DOCUMENTATION) + add_subdirectory(doc) +endif() + +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + +install( + FILES QXmppConfig.cmake + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/qxmpp" + COMPONENT Devel +) + +# Generate qxmpp.pc +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/qxmpp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/qxmpp.pc @ONLY) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/qxmpp.pc + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + COMPONENT Devel +) + diff --git a/QXmppConfig.cmake b/QXmppConfig.cmake new file mode 100644 index 00000000..0a171d4b --- /dev/null +++ b/QXmppConfig.cmake @@ -0,0 +1,3 @@ +find_package(Qt5 REQUIRED COMPONENTS Core Network Xml) + +include("${CMAKE_CURRENT_LIST_DIR}/QXmpp.cmake") @@ -23,37 +23,25 @@ version 2.1 or later. BUILDING QXMPP ============== -QXmpp requires Qt 4.5 or higher (including Qt 5.x) with SSL enabled and it uses -the standard qmake build system of Qt. +QXmpp requires Qt 5.0 or higher with SSL enabled. +It uses CMake as build system. Build from command line: - cd <where qxmpp.pro is located> - qmake <arguments> + mkdir build + cd build + cmake .. <respective-make-cmd = gmake, make, mingw32-make, nmake> -You can pass the following arguments to qmake: +You can pass the following arguments to CMake: - PREFIX=<prefix> to change the install prefix - default: - unix: /usr/local on unix - other: $$[QT_INSTALL_PREFIX] - QXMPP_AUTOTEST_INTERNAL=1 to enabled internal autotests - QXMPP_LIBRARY_TYPE=staticlib to build a static version of QXmpp - QXMPP_USE_DOXYGEN=1 to build the HTML documentation - QXMPP_USE_OPUS=1 to enable opus audio codec - QXMPP_USE_SPEEX=1 to enable speex audio codec - QXMPP_USE_THEORA=1 to enable theora video codec - QXMPP_USE_VPX=1 to enable vpx video codec - -Note: by default QXmpp is built as a shared library. If you decide to build -a static library instead, you will need to pass -DQXMPP_STATIC when building -your programs against QXmpp. - -Build using Qt Creator: - -Open the qxmpp.pro file in Qt Creator and hit "Build All" to build all -the examples and library. + BUILD_DOCUMENTATION to build the documentation + BUILD_EXAMPLES to build the examples + BUILD_TESTS to build the unit tests + WITH_OPUS to enable opus audio codec + WITH_SPEEX to enable speex audio codec + WITH_THEORA to enable theora video codec + WITH_VPX to enable vpx video codec INSTALLING QXMPP ================ @@ -65,15 +53,6 @@ Install from command line: <respective-make-cmd = gmake, make, mingw32-make, nmake> install -Path of installations: - - Headers: PREFIX/include/qxmpp - Library: PREFIX/lib - API Documentation: PREFIX/share/doc/qxmpp - -To link against the shared version of QXmpp, you need to add -DQXMPP_SHARED -to your C++ flags. - EXAMPLES ======== diff --git a/cmake/modules/FindOpus.cmake b/cmake/modules/FindOpus.cmake new file mode 100644 index 00000000..fc13497b --- /dev/null +++ b/cmake/modules/FindOpus.cmake @@ -0,0 +1,25 @@ +# Try to find Opus +# Once done this will define +# Opus_FOUND - System has Opus +# Opus_INCLUDE_DIRS - The Opus include directories +# Opus_LIBRARIES - The libraries needed to use Opus + +find_package(PkgConfig) +pkg_check_modules(PC_Opus QUIET libopus) + +find_path(Opus_INCLUDE_DIR opus/opus.h + HINTS ${PC_Opus_INCLUDEDIR} ${PC_Opus_INCLUDE_DIRS} +) + +find_library(Opus_LIBRARY NAMES opus + HINTS ${PC_Opus_LIBDIR} ${PC_Opus_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Opus DEFAULT_MSG Opus_LIBRARY Opus_INCLUDE_DIR) + +mark_as_advanced(Opus_INCLUDE_DIR Opus_LIBRARY) + +set(Opus_LIBRARIES ${Opus_LIBRARY}) +set(Opus_INCLUDE_DIRS ${Opus_INCLUDE_DIR}) + diff --git a/cmake/modules/FindSpeex.cmake b/cmake/modules/FindSpeex.cmake new file mode 100644 index 00000000..3929b2ec --- /dev/null +++ b/cmake/modules/FindSpeex.cmake @@ -0,0 +1,25 @@ +# Try to find Speex +# Once done this will define +# Speex_FOUND - System has Speex +# Speex_INCLUDE_DIRS - The Speex include directories +# Speex_LIBRARIES - The libraries needed to use Speex + +find_package(PkgConfig) +pkg_check_modules(PC_Speex QUIET libspeex) + +find_path(Speex_INCLUDE_DIR speex/speex.h + HINTS ${PC_Speex_INCLUDEDIR} ${PC_Speex_INCLUDE_DIRS} +) + +find_library(Speex_LIBRARY NAMES speex + HINTS ${PC_Speex_LIBDIR} ${PC_Speex_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Speex DEFAULT_MSG Speex_LIBRARY Speex_INCLUDE_DIR) + +mark_as_advanced(Speex_INCLUDE_DIR Speex_LIBRARY) + +set(Speex_LIBRARIES ${Speex_LIBRARY}) +set(Speex_INCLUDE_DIRS ${Speex_INCLUDE_DIR}) + diff --git a/cmake/modules/FindTheora.cmake b/cmake/modules/FindTheora.cmake new file mode 100644 index 00000000..24462794 --- /dev/null +++ b/cmake/modules/FindTheora.cmake @@ -0,0 +1,33 @@ +# Try to find Theora +# Once done this will define +# Theora_FOUND - System has Theora +# Theora_INCLUDE_DIRS - The Theora include directories +# Theora_LIBRARIES - The libraries needed to use Theora + +find_package(PkgConfig) +pkg_check_modules(PC_Theora QUIET libtheora) + +find_path(Theora_INCLUDE_DIR theora/theora.h + HINTS ${PC_Theora_INCLUDEDIR} ${PC_Theora_INCLUDE_DIRS} +) + +find_library(Theora_LIBRARY NAMES theora + HINTS ${PC_Theora_LIBDIR} ${PC_Theora_LIBRARY_DIRS} +) + +find_library(Theora_enc_LIBRARY NAMES theoraenc + HINTS ${PC_Theora_LIBDIR} ${PC_Theora_LIBRARY_DIRS} +) + +find_library(Theora_dec_LIBRARY NAMES theoradec + HINTS ${PC_Theora_LIBDIR} ${PC_Theora_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Theora DEFAULT_MSG Theora_LIBRARY Theora_enc_LIBRARY Theora_dec_LIBRARY Theora_INCLUDE_DIR) + +mark_as_advanced(Theora_INCLUDE_DIR Theora_LIBRARY Theora_enc_LIBRARY Theora_dec_LIBRARY) + +set(Theora_LIBRARIES ${Theora_LIBRARY} ${Theora_enc_LIBRARY} ${Theora_dec_LIBRARY}) +set(Theora_INCLUDE_DIRS ${Theora_INCLUDE_DIR}) + diff --git a/cmake/modules/FindVPX.cmake b/cmake/modules/FindVPX.cmake new file mode 100644 index 00000000..8c60a555 --- /dev/null +++ b/cmake/modules/FindVPX.cmake @@ -0,0 +1,25 @@ +# Try to find VPX +# Once done this will define +# VPX_FOUND - System has VPX +# VPX_INCLUDE_DIRS - The VPX include directories +# VPX_LIBRARIES - The libraries needed to use VPX + +find_package(PkgConfig) +pkg_check_modules(PC_VPX QUIET libvpx) + +find_path(VPX_INCLUDE_DIR vpx/vp8.h + HINTS ${PC_VPX_INCLUDEDIR} ${PC_VPX_INCLUDE_DIRS} +) + +find_library(VPX_LIBRARY NAMES vpx + HINTS ${PC_VPX_LIBDIR} ${PC_VPX_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VPX DEFAULT_MSG VPX_LIBRARY VPX_INCLUDE_DIR) + +mark_as_advanced(VPX_INCLUDE_DIR VPX_LIBRARY) + +set(VPX_LIBRARIES ${VPX_LIBRARY}) +set(VPX_INCLUDE_DIRS ${VPX_INCLUDE_DIR}) + diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..2fb54f3c --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,20 @@ +find_package(Doxygen REQUIRED) + +set(DOXYGEN_INPUT + ${CMAKE_CURRENT_SOURCE_DIR}/index.doc + ${CMAKE_CURRENT_SOURCE_DIR}/using.doc + ${CMAKE_CURRENT_SOURCE_DIR}/xep.doc + ${PROJECT_SOURCE_DIR}/src +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) + +add_custom_target( + doc ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generate API documentation with Doxygen" +) + +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR}) + diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in new file mode 100644 index 00000000..162406b5 --- /dev/null +++ b/doc/Doxyfile.in @@ -0,0 +1,13 @@ +PROJECT_NAME = "@CMAKE_PROJECT_NAME@" +PROJECT_NUMBER = @VERSION_STRING@ +INPUT = @DOXYGEN_INPUT@ + +ALPHABETICAL_INDEX = NO +EXCLUDE_PATTERNS = */moc_* */mod_* */*_p.h */QXmppCodec.cpp */QXmppSasl.cpp +FULL_PATH_NAMES = NO +HIDE_UNDOC_CLASSES = YES +GENERATE_LATEX = NO +HTML_TIMESTAMP = NO +QUIET = YES +RECURSIVE = YES + diff --git a/doc/doc.pro b/doc/doc.pro deleted file mode 100644 index 3a3a46ce..00000000 --- a/doc/doc.pro +++ /dev/null @@ -1,24 +0,0 @@ -include(../qxmpp.pri) - -TEMPLATE = app -CONFIG += console -CONFIG -= app_bundle -QT -= gui - -INCLUDEPATH += $$QXMPP_INCLUDEPATH -TARGET = doxyfilter -SOURCES += doxyfilter.cpp - -windows { - DOXYFILTER = $${TARGET}.exe -} else { - DOXYFILTER = ./$${TARGET} -} - -# Build rules -docs.commands = $${DOXYFILTER} -g $${PWD} && $${DOXYFILTER} -docs.depends = $${TARGET} - -QMAKE_CLEAN += Doxyfile doxygen_sqlite3.db -unix:QMAKE_DISTCLEAN += -r html -QMAKE_EXTRA_TARGETS += docs diff --git a/doc/doxyfilter.cpp b/doc/doxyfilter.cpp deleted file mode 100644 index e54fceb6..00000000 --- a/doc/doxyfilter.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Jeremy Lainé - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - -#include <cstdlib> -#include <iostream> - -#include <QCoreApplication> -#include <QFile> -#include <QProcess> -#include <QRegExp> -#include <QTextStream> - -#include "QXmppGlobal.h" - -static void setField(QString &code, const QString &name, const QString &value) -{ - code.replace( - QRegExp(QString("(%1\\s*=)[^\\r\\n]*").arg(name)), - QString("\\1 %1").arg(value)); -} - -static void usage() { - QTextStream output(stderr); - output << "Usage:" << endl; - output << " doxyfilter Generate documentation" << endl; - output << " doxyfilter -g Generate Doxyfile" << endl; - output << " doxyfilter <sourcefile> Filter the given file's code" << endl; -} - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - - if (argc == 1) - return QProcess::execute("doxygen"); - else if (argc < 2) { - usage(); - return 1; - } - - if (!strcmp(argv[1], "-g")) { - // generate default Doxyfile - QProcess process; - process.start("doxygen", QStringList() << "-g" << "-"); - if (!process.waitForFinished()) { - qWarning("Could not run doxygen"); - return 1; - } - QString code = QString::fromUtf8(process.readAll()); - - QString docDir = (argc > 2) ? (QString::fromLocal8Bit(argv[2]) + "/") : ""; - QStringList docFiles = QStringList() << "index.doc" << "using.doc" << "xep.doc" << "../src"; - for (int i = 0; i < docFiles.size(); ++i) { - docFiles[i] = docDir + docFiles[i]; - } - - // adjust Doxyfile - setField(code, "ALPHABETICAL_INDEX", "NO"); - setField(code, "EXCLUDE_PATTERNS", "*/moc_* */mod_* */qdnslookup* */*_p.h */QXmppCodec.cpp */QXmppSasl.cpp"); - setField(code, "FULL_PATH_NAMES", "NO"); - setField(code, "HIDE_UNDOC_CLASSES", "YES"); - setField(code, "GENERATE_LATEX", "NO"); - setField(code, "HTML_TIMESTAMP", "NO"); - setField(code, "INPUT", docFiles.join(" ")); - setField(code, "INPUT_FILTER", QString::fromLocal8Bit(argv[0])); - setField(code, "PROJECT_NAME", "QXmpp"); - setField(code, "PROJECT_NUMBER", QString("Version: %1.%2.%3").arg( - QString::number((QXMPP_VERSION >> 16) & 0xff), - QString::number((QXMPP_VERSION >> 8) & 0xff), - QString::number(QXMPP_VERSION & 0xff))); - setField(code, "QUIET", "YES"); - setField(code, "RECURSIVE", "YES"); - - // write doxyfile - QFile output("Doxyfile"); - if (!output.open(QIODevice::WriteOnly)) { - qWarning("Could not write to %s", qPrintable(output.fileName())); - return 1; - } - output.write(code.toUtf8()); - output.close(); - - } else if (!strcmp(argv[1], "-h")) { - usage(); - return 0; - } else { - // read source code - QFile source(QString::fromLocal8Bit(argv[1])); - if (!source.open(QIODevice::ReadOnly)) { - qWarning("Could not open %s", qPrintable(source.fileName())); - return 1; - } - QString code = QString::fromUtf8(source.readAll()); - source.close(); - - // add links for RFCs - QRegExp rfcRegexp("(RFC ([0-9]{4})(: [^\\s.]+( [A-Z][^\\s.]*)*)?)"); - code.replace(rfcRegexp, "<a href=\"http://www.rfc-editor.org/rfc/rfc\\2.txt\">\\1</a>"); - - // add links for XEPs - QRegExp regexp("(XEP-([0-9]{4})(: [^\\s.]+( [A-Z][^\\s.]*)*)?)"); - code.replace(regexp, "<a href=\"http://xmpp.org/extensions/xep-\\2.html\">\\1</a>"); - - QTextStream output(stdout); - output << code; - } - - return 0; -} - diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..564745c6 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,21 @@ +macro(add_simple_example EXAMPLE_NAME) + add_executable(${EXAMPLE_NAME} example_${EXAMPLE_NAME}/example_${EXAMPLE_NAME}.cpp) + target_link_libraries(${EXAMPLE_NAME} qxmpp) +endmacro() + +include_directories(${PROJECT_SOURCE_DIR}/src/base) +include_directories(${PROJECT_SOURCE_DIR}/src/client) +include_directories(${PROJECT_SOURCE_DIR}/src/server) +include_directories(${PROJECT_BINARY_DIR}/src/base) + +add_simple_example(0_connected) +add_simple_example(1_echoClient) +add_simple_example(2_rosterHandling) +add_simple_example(3_transferHandling) +add_simple_example(7_archiveHandling) +add_simple_example(8_server) + +add_subdirectory(example_5_rpcInterface) +add_subdirectory(example_6_rpcClient) +add_subdirectory(example_9_vCard) + diff --git a/examples/GuiClient/GuiClient.pro b/examples/GuiClient/GuiClient.pro deleted file mode 100644 index 60306171..00000000 --- a/examples/GuiClient/GuiClient.pro +++ /dev/null @@ -1,64 +0,0 @@ -include(../examples.pri) - -TARGET = GuiClient -TEMPLATE = app - -SOURCES += main.cpp \ - chatMsgGraphicsItem.cpp \ - chatGraphicsScene.cpp \ - chatGraphicsView.cpp \ - chatDialog.cpp \ - mainDialog.cpp \ - rosterItemModel.cpp \ - rosterItem.cpp \ - rosterItemSortFilterProxyModel.cpp \ - utils.cpp \ - rosterListView.cpp \ - searchLineEdit.cpp \ - statusWidget.cpp \ - signInStatusLabel.cpp \ - statusAvatarWidget.cpp \ - statusTextWidget.cpp \ - statusToolButton.cpp \ - vCardCache.cpp \ - profileDialog.cpp \ - capabilitiesCache.cpp \ - accountsCache.cpp \ - xmlConsoleDialog.cpp \ - aboutDialog.cpp - -HEADERS += chatMsgGraphicsItem.h \ - chatGraphicsScene.h \ - chatGraphicsView.h \ - chatDialog.h \ - mainDialog.h \ - rosterItemModel.h \ - rosterItem.h \ - rosterItemSortFilterProxyModel.h \ - utils.h \ - rosterListView.h \ - searchLineEdit.h \ - statusWidget.h \ - signInStatusLabel.h \ - statusAvatarWidget.h \ - statusTextWidget.h \ - statusToolButton.h \ - vCardCache.h \ - profileDialog.h \ - capabilitiesCache.h \ - accountsCache.h \ - xmlConsoleDialog.h \ - aboutDialog.h - -FORMS += mainDialog.ui \ - chatDialog.ui \ - statusWidget.ui \ - profileDialog.ui \ - xmlConsoleDialog.ui \ - aboutDialog.ui - -QT += network \ - xml \ - widgets - -RESOURCES += resources.qrc diff --git a/examples/GuiClient/aboutDialog.cpp b/examples/GuiClient/aboutDialog.cpp deleted file mode 100644 index 65805a53..00000000 --- a/examples/GuiClient/aboutDialog.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "aboutDialog.h" -#include "ui_aboutDialog.h" - -#include "QXmppGlobal.h" - -#include <QtGlobal> - -aboutDialog::aboutDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::aboutDialog) -{ - ui->setupUi(this); - - setWindowTitle(QString("About %1").arg(qApp->applicationName())); - - ui->textEdit->append(QString("Copyright (C) 2008-2014 The QXmpp developers\n")); - ui->textEdit->append(qApp->applicationName() + " " + qApp->applicationVersion()); - ui->textEdit->append(QString("\nBased on:")); - ui->textEdit->append(QString("QXmpp %1").arg(QXmppVersion())); - ui->textEdit->append(QString("Qt %1 [built-with]").arg(qVersion())); - ui->textEdit->append(QString("Qt %1 [running-with]").arg(QT_VERSION_STR)); -} - -aboutDialog::~aboutDialog() -{ - delete ui; -} diff --git a/examples/GuiClient/aboutDialog.h b/examples/GuiClient/aboutDialog.h deleted file mode 100644 index 22c765c7..00000000 --- a/examples/GuiClient/aboutDialog.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef ABOUTDIALOG_H -#define ABOUTDIALOG_H - -#include <QDialog> - -namespace Ui { - class aboutDialog; -} - -class aboutDialog : public QDialog -{ - Q_OBJECT - -public: - explicit aboutDialog(QWidget *parent = 0); - ~aboutDialog(); - -private: - Ui::aboutDialog *ui; -}; - -#endif // ABOUTDIALOG_H diff --git a/examples/GuiClient/aboutDialog.ui b/examples/GuiClient/aboutDialog.ui deleted file mode 100644 index 01240819..00000000 --- a/examples/GuiClient/aboutDialog.ui +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>aboutDialog</class> - <widget class="QDialog" name="aboutDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>309</width> - <height>218</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTextEdit" name="textEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>aboutDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>aboutDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/examples/GuiClient/accountsCache.cpp b/examples/GuiClient/accountsCache.cpp deleted file mode 100644 index d13bded5..00000000 --- a/examples/GuiClient/accountsCache.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "accountsCache.h" -#include "utils.h" - -#include <QDir> -#include <QTextStream> -#include <QStringList> - -accountsCache::accountsCache(QObject *parent) : - QObject(parent) -{ -} - -QStringList accountsCache::getBareJids() -{ - QStringList list; - QDomElement element = m_accountsDocument.documentElement().firstChildElement("account"); - while(!element.isNull()) - { - list << element.firstChildElement("bareJid").text(); - element = element.nextSiblingElement("account"); - } - - return list; -} - -QString accountsCache::getPassword(const QString& bareJid) -{ - QDomElement element = m_accountsDocument.documentElement().firstChildElement("account"); - while(!element.isNull()) - { - if(element.firstChildElement("bareJid").text() == bareJid) - { - QByteArray passwdEncryptedBa = QByteArray::fromBase64( - element.firstChildElement("password").text().toUtf8()); - QString passwd = calculateXor(passwdEncryptedBa, bareJid.toUtf8()); - return passwd; - } - element = element.nextSiblingElement("account"); - } - - return ""; -} - -void accountsCache::addAccount(const QString& bareJid, const QString& passwd) -{ - if(m_accountsDocument.documentElement().isNull()) - { - m_accountsDocument.appendChild(m_accountsDocument.createElement("accounts")); - } - - QDomElement element = m_accountsDocument.documentElement().firstChildElement("account"); - while(!element.isNull()) - { - if(element.firstChildElement("bareJid").text() == bareJid) - { - m_accountsDocument.documentElement().removeChild(element); - break; - } - element = element.nextSiblingElement("account"); - } - - QDomElement newElement = m_accountsDocument.createElement("account"); - - QDomElement newElementBareJid = m_accountsDocument.createElement("bareJid"); - newElementBareJid.appendChild(m_accountsDocument.createTextNode(bareJid)); - newElement.appendChild(newElementBareJid); - - QDomElement newElementPasswd = m_accountsDocument.createElement("password"); - newElementPasswd.appendChild(m_accountsDocument.createTextNode( - calculateXor(passwd.toUtf8(), bareJid.toUtf8()).toBase64())); - newElement.appendChild(newElementPasswd); - - m_accountsDocument.documentElement().appendChild(newElement); - - saveToFile(); -} - -void accountsCache::loadFromFile() -{ - QDir dirSettings(getSettingsDir()); - if(dirSettings.exists()) - { - QFile file(getSettingsDir()+ "accounts.xml"); - if(file.open(QIODevice::ReadOnly)) - { - m_accountsDocument.setContent(&file, true); - } - } -} - -void accountsCache::saveToFile() -{ - QDir dir; - if(!dir.exists(getSettingsDir())) - dir.mkpath(getSettingsDir()); - - QString fileAccounts = getSettingsDir() + "accounts.xml"; - QFile file(fileAccounts); - if(file.open(QIODevice::ReadWrite)) - { - QTextStream tstream(&file); - m_accountsDocument.save(tstream, 2); - file.close(); - } -} diff --git a/examples/GuiClient/accountsCache.h b/examples/GuiClient/accountsCache.h deleted file mode 100644 index f3cb1a52..00000000 --- a/examples/GuiClient/accountsCache.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef ACCOUNTSCACHE_H -#define ACCOUNTSCACHE_H - -#include <QObject> -#include <QDomElement> - -class QStringList; - -class accountsCache : public QObject -{ - Q_OBJECT - -public: - explicit accountsCache(QObject *parent); - QStringList getBareJids(); - QString getPassword(const QString& bareJid); - - void addAccount(const QString& bareJid, const QString& passwd); - -public: - void loadFromFile(); - -private: - void saveToFile(); - - QDomDocument m_accountsDocument; -}; - -#endif // ACCOUNTSCACHE_H diff --git a/examples/GuiClient/capabilitiesCache.cpp b/examples/GuiClient/capabilitiesCache.cpp deleted file mode 100644 index dd86fca5..00000000 --- a/examples/GuiClient/capabilitiesCache.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "capabilitiesCache.h" -#include "utils.h" - -#include "QXmppClient.h" -#include "QXmppDiscoveryManager.h" - -#include <QCoreApplication> -#include <QXmlStreamWriter> -#include <QDir> - -capabilitiesCache::capabilitiesCache(QXmppClient* client) : - QObject(client), m_client(client) -{ - QXmppDiscoveryManager* ext = m_client->findExtension<QXmppDiscoveryManager>(); - if(ext) - { - bool check = connect(ext, SIGNAL(infoReceived(QXmppDiscoveryIq)), - SLOT(infoReceived(QXmppDiscoveryIq))); - Q_ASSERT(check); - Q_UNUSED(check); - } -} - -bool capabilitiesCache::isCapabilityAvailable(const QString& nodeVer) -{ - return m_mapCapabilities.contains(nodeVer); -} - -void capabilitiesCache::requestInfo(const QString& jid, const QString& node) -{ - QXmppDiscoveryManager* ext = m_client->findExtension<QXmppDiscoveryManager>(); - if(ext) - { - bool alreadyRequested = false; - foreach(QString key, m_mapIdNodeVer.keys()) - { - if(m_mapIdNodeVer[key] == node) - { - alreadyRequested = true; - break; - } - } - - if(!alreadyRequested) - { - QString id = ext->requestInfo(jid, node); - m_mapIdNodeVer[id] = node; - } - } -} - -void capabilitiesCache::infoReceived(const QXmppDiscoveryIq& discoIqRcv) -{ - QXmppDiscoveryIq discoIq = discoIqRcv; - if(discoIq.queryType() == QXmppDiscoveryIq::InfoQuery && - discoIq.type() == QXmppIq::Result) - { - if(discoIq.queryNode().isEmpty()) - { - discoIq.setQueryNode(m_mapIdNodeVer[discoIq.id()]); - m_mapIdNodeVer.remove(discoIq.id()); - } - - discoIq.setTo(""); - discoIq.setFrom(""); - discoIq.setId(""); - m_mapCapabilities[discoIq.queryNode()] = discoIq; - saveToFile(discoIq.queryNode()); - } -} - -void capabilitiesCache::loadFromFile() -{ - m_mapCapabilities.clear(); - - QDir dirCaps(getSettingsDir(m_client->configuration().jidBare())+ "capabilities/"); - if(dirCaps.exists()) - { - QStringList list = dirCaps.entryList(QStringList("*.xml")); - foreach(QString fileName, list) - { - QFile file(getSettingsDir(m_client->configuration().jidBare())+ "capabilities/" + fileName); - if(file.open(QIODevice::ReadOnly)) - { - QDomDocument doc; - if(doc.setContent(&file, true)) - { - QXmppDiscoveryIq discoIq; - discoIq.parse(doc.documentElement()); - m_mapCapabilities[discoIq.queryNode()] = discoIq; - QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - } - } - } - } -} - -void capabilitiesCache::saveToFile(const QString& nodeVer) -{ - if(!m_mapCapabilities.contains(nodeVer)) - return; - - QString fileName = getSha1HashAsHex(nodeVer.toUtf8()); - QDir dir; - if(!dir.exists(getSettingsDir(m_client->configuration().jidBare()))) - dir.mkpath(getSettingsDir(m_client->configuration().jidBare())); - - QDir dir2; - if(!dir2.exists(getSettingsDir(m_client->configuration().jidBare())+ "capabilities/")) - dir2.mkpath(getSettingsDir(m_client->configuration().jidBare())+ "capabilities/"); - - QString fileCapability = getSettingsDir(m_client->configuration().jidBare()) + "capabilities/" + fileName + ".xml"; - QFile file(fileCapability); - - if(file.open(QIODevice::ReadWrite)) - { - QXmlStreamWriter stream(&file); - stream.setAutoFormatting(true); - stream.setAutoFormattingIndent(2); - m_mapCapabilities[nodeVer].toXml(&stream); - file.close(); - } -} - -QStringList capabilitiesCache::getFeatures(const QString& nodeVer) -{ - if(!m_mapCapabilities.contains(nodeVer)) - return QStringList(); - - return m_mapCapabilities[nodeVer].features(); -} - -QStringList capabilitiesCache::getIdentities(const QString& nodeVer) -{ - if(!m_mapCapabilities.contains(nodeVer)) - return QStringList(); - - QStringList idList; - QList<QXmppDiscoveryIq::Identity> list = m_mapCapabilities[nodeVer].identities(); - foreach(QXmppDiscoveryIq::Identity identity, list) - { - QStringList tmpList; - if(!identity.name().isEmpty()) - tmpList << identity.name(); - if(!identity.category().isEmpty()) - tmpList << identity.category(); - if(!identity.type().isEmpty()) - tmpList << identity.type(); - if(!identity.language().isEmpty()) - tmpList << identity.language(); - idList << tmpList.join(" | "); - } - return idList; -} - diff --git a/examples/GuiClient/capabilitiesCache.h b/examples/GuiClient/capabilitiesCache.h deleted file mode 100644 index 2e6eccac..00000000 --- a/examples/GuiClient/capabilitiesCache.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef CAPABILITIESCACHE_H -#define CAPABILITIESCACHE_H - -#include <QObject> -#include <QDomElement> -#include <QMap> - -class QXmppClient; - -#include "QXmppDiscoveryIq.h" - -class capabilitiesCache : public QObject -{ - Q_OBJECT - -public: - capabilitiesCache(QXmppClient* client); - bool isCapabilityAvailable(const QString& nodeVer); - void requestInfo(const QString& jid, const QString& nodeVer); - - void loadFromFile(); - - QStringList getFeatures(const QString& nodeVer); - QStringList getIdentities(const QString& nodeVer); - -signals: - -private slots: - void infoReceived(const QXmppDiscoveryIq&); - -private: - void saveToFile(const QString& nodeVer); - - QXmppClient* m_client; - - QMap<QString, QXmppDiscoveryIq> m_mapCapabilities; - QMap<QString, QString> m_mapIdNodeVer; -}; - -#endif // CAPABILITIESCACHE_H diff --git a/examples/GuiClient/chatDialog.cpp b/examples/GuiClient/chatDialog.cpp deleted file mode 100644 index 60282802..00000000 --- a/examples/GuiClient/chatDialog.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "chatDialog.h" -#include "ui_chatDialog.h" - -#include "chatGraphicsView.h" -#include "chatGraphicsScene.h" -#include "QXmppClient.h" -#include <QPainter> -#include <QPushButton> - -chatDialog::chatDialog(QWidget *parent): QDialog(parent, Qt::Window), - ui(new Ui::chatDialogClass), m_view(0), m_scene(0), m_pushButtonSend(0), m_client(0) -{ - ui->setupUi(this); - m_view = new chatGraphicsView(this); - m_scene = new chatGraphicsScene(this); - m_view->setChatGraphicsScene(m_scene); - m_pushButtonSend = new QPushButton("Send", this); -// m_pushButtonSend->setFixedHeight(); -// m_pushButtonSend->setFixedWidth(); - QRect rect = ui->lineEdit->geometry(); - rect.setLeft(rect.right()); - rect.setWidth(60); - m_pushButtonSend->setGeometry(rect); - ui->lineEdit->setFocus(); - ui->verticalLayout->insertWidget(0, m_view); - bool check = connect(m_pushButtonSend, SIGNAL(clicked(bool)), SLOT(sendMessage())); - Q_ASSERT(check); - Q_UNUSED(check); - updateSendButtonGeomerty(); -} - -void chatDialog::show() -{ - QDialog::show(); -} - -QString chatDialog::getBareJid() const -{ - return m_bareJid; -} - -QString chatDialog::getDisplayName() const -{ - return m_displayName; -} - -void chatDialog::setBareJid(const QString& str) -{ - m_bareJid = str; -} - -void chatDialog::setDisplayName(const QString& str) -{ - m_displayName = str; - setWindowTitle(QString("Chat with %1").arg(m_bareJid)); - - QFont font; - font.setBold(true); - QFontMetrics fontMetrics(font); - QRect rect = fontMetrics.boundingRect(m_displayName); - int width = rect.width(); - - if(m_scene) - m_scene->setBoxStartLength(width); -// ui->horizontalSpacer_2->changeSize(width+20, 10); - ui->lineEdit->setFixedWidth(350 - width - 25); - updateSendButtonGeomerty(); -} - -void chatDialog::setQXmppClient(QXmppClient* client) -{ - m_client = client; -} - -void chatDialog::sendMessage() -{ - if(m_client) - m_client->sendMessage(getBareJid(), ui->lineEdit->text()); - - m_view->addMessage("Me", ui->lineEdit->text()); - ui->lineEdit->clear(); -} - -void chatDialog::messageReceived(const QString& msg) -{ - m_view->addMessage(getDisplayName(), msg); -} - -void chatDialog::keyPressEvent(QKeyEvent* event1) -{ - ui->lineEdit->setFocus(); - ui->lineEdit->event(event1); - - if(event1->key() == Qt::Key_Return) - { - m_pushButtonSend->click(); - } - else if(event1->key() == Qt::Key_Escape) - { - hide(); - } -} - -void chatDialog::paintEvent(QPaintEvent* event) -{ - QDialog::paintEvent(event); - QPainter p(this); - p.setPen(Qt::gray); - p.drawRect(rect().adjusted(5, 5, -6, -6)); -} - -void chatDialog::resizeEvent(QResizeEvent *) -{ - updateSendButtonGeomerty(); -} - -void chatDialog::moveEvent(QMoveEvent *) -{ - updateSendButtonGeomerty(); -} - -void chatDialog::updateSendButtonGeomerty() -{ - QRect rect = ui->lineEdit->geometry(); - rect.setLeft(rect.right() + 6); - rect.setWidth(60); - QRect rect2 = rect; - rect2.setHeight(25); - rect2.moveCenter(rect.center()); - m_pushButtonSend->setGeometry(rect2); -} diff --git a/examples/GuiClient/chatDialog.h b/examples/GuiClient/chatDialog.h deleted file mode 100644 index ec008ebf..00000000 --- a/examples/GuiClient/chatDialog.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef CHATDIALOG_H -#define CHATDIALOG_H - -#include <QDialog> -#include <QKeyEvent> - -namespace Ui -{ - class chatDialogClass; -} - -class chatGraphicsView; -class chatGraphicsScene; -class QXmppClient; -class QPushButton; - -class chatDialog : public QDialog -{ - Q_OBJECT - -public: - chatDialog(QWidget *parent = 0); - void show(); - - QString getBareJid() const; - QString getDisplayName() const; - void setBareJid(const QString&); - void setDisplayName(const QString&); - void setQXmppClient(QXmppClient* client); - void messageReceived(const QString& msg); - -private slots: - void sendMessage(); - -protected: - void keyPressEvent(QKeyEvent*); - void paintEvent(QPaintEvent* event); - virtual void resizeEvent(QResizeEvent*); - virtual void moveEvent(QMoveEvent*); - -private: - void updateSendButtonGeomerty(); - - Ui::chatDialogClass *ui; - chatGraphicsView* m_view; - chatGraphicsScene* m_scene; - QPushButton* m_pushButtonSend; - - // holds a reference to the the connected client - QXmppClient* m_client; - - QString m_bareJid; - QString m_displayName; -}; - -#endif // CHATDIALOG_H diff --git a/examples/GuiClient/chatDialog.ui b/examples/GuiClient/chatDialog.ui deleted file mode 100644 index 2cdb8fcc..00000000 --- a/examples/GuiClient/chatDialog.ui +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>chatDialogClass</class> - <widget class="QDialog" name="chatDialogClass"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>445</width> - <height>291</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>445</width> - <height>0</height> - </size> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <property name="styleSheet"> - <string>alternate-background-color: rgb(255, 255, 255);</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <property name="margin"> - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="QWidget" name="widget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="styleSheet"> - <string>background-color: rgb(255, 255, 255);</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>50</height> - </size> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="widget_2" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="styleSheet"> - <string>background-color: rgb(255, 255, 255);</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/examples/GuiClient/chatGraphicsScene.cpp b/examples/GuiClient/chatGraphicsScene.cpp deleted file mode 100644 index d032a87b..00000000 --- a/examples/GuiClient/chatGraphicsScene.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "chatGraphicsScene.h" -#include "chatMsgGraphicsItem.h" -#include "chatGraphicsView.h" - -chatGraphicsScene::chatGraphicsScene(QObject* parent) : QGraphicsScene(parent), - m_verticalPosForNewMessage(0), m_verticalSpacing(5) -{ -} - -void chatGraphicsScene::addMessage(const QString& user, const QString& message) -{ - chatMsgGraphicsItem* item = new chatMsgGraphicsItem(); - m_items.append(item); - item->setName(user); - item->setBoxStartLength(m_boxStartLength); - item->setText(message); - item->setViewWidth(350); -// item->setViewWidth(views().at(0)->size().width()); - item->setPos(0, m_verticalPosForNewMessage); - int height = item->boundingRect().height(); - m_verticalPosForNewMessage = m_verticalPosForNewMessage + height + m_verticalSpacing; - addItem(item); - - QRectF rect = sceneRect(); - rect.setHeight(m_verticalPosForNewMessage); - setSceneRect(rect); -} - -void chatGraphicsScene::setWidthResize(int newWidth, int oldWidth) -{ - Q_UNUSED(newWidth); - Q_UNUSED(oldWidth); -// verticalReposition(); -} - -void chatGraphicsScene::verticalReposition() -{ - m_verticalPosForNewMessage = 0; - - chatMsgGraphicsItem* item = 0; - for(int i = 0; i < m_items.size(); ++i) - { - item = m_items.at(i); - item->setViewWidth(views().at(0)->size().width()); - item->setPos(0, m_verticalPosForNewMessage); - int height = item->boundingRect().height(); - m_verticalPosForNewMessage = m_verticalPosForNewMessage + height + m_verticalSpacing; - } - - QRectF rect = sceneRect(); - if(item) - { - rect.setHeight(m_verticalPosForNewMessage); - rect.setWidth(item->getMaxWidth() + item->getBoxStartLength() - 4); - setSceneRect(rect); - } -} - -void chatGraphicsScene::setBoxStartLength(int length) -{ - m_boxStartLength = length; -} - diff --git a/examples/GuiClient/chatGraphicsScene.h b/examples/GuiClient/chatGraphicsScene.h deleted file mode 100644 index f9a8fc30..00000000 --- a/examples/GuiClient/chatGraphicsScene.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef CHATGRAPHICSSCENE_H -#define CHATGRAPHICSSCENE_H - -#include <QGraphicsScene> -#include <QList> - -class chatMsgGraphicsItem; - -class chatGraphicsScene : public QGraphicsScene -{ -public: - chatGraphicsScene(QObject* parent = 0); - void addMessage(const QString& user, const QString& message); - void setWidthResize(int newWidth, int oldWidth); - void verticalReposition(); - void setBoxStartLength(int length); - -private: - int m_verticalPosForNewMessage; - int m_verticalSpacing; - int m_boxStartLength; - QList <chatMsgGraphicsItem*> m_items; -}; - -#endif // CHATGRAPHICSSCENE_H diff --git a/examples/GuiClient/chatGraphicsView.cpp b/examples/GuiClient/chatGraphicsView.cpp deleted file mode 100644 index b39a876d..00000000 --- a/examples/GuiClient/chatGraphicsView.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "chatGraphicsView.h" -#include "chatGraphicsScene.h" -#include <QResizeEvent> - -chatGraphicsView::chatGraphicsView(QWidget* parent) : QGraphicsView(parent) -{ - setAlignment(Qt::AlignHCenter|Qt::AlignTop); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setFrameStyle(QFrame::NoFrame); -} - -void chatGraphicsView::setChatGraphicsScene(chatGraphicsScene* scene) -{ - m_scene = scene; - setScene(m_scene); -} - -void chatGraphicsView::addMessage(const QString& user, const QString& message) -{ - if(m_scene) - m_scene->addMessage(user, message); - - QRectF rect = scene()->sceneRect(); - rect.adjust(-4, -4, 4, 4); - setSceneRect(rect); - - rect = sceneRect(); - rect.setTop(sceneRect().height() - 20); - rect.setWidth(20); - ensureVisible(rect, 50, 50); -} - -void chatGraphicsView::resizeEvent(QResizeEvent *event) -{ -// pass this to scene - m_scene->setWidthResize(event->size().width(), event->oldSize().width()); - QGraphicsView::resizeEvent(event); - - QRectF rect = scene()->sceneRect(); - rect.adjust(-4, -4, 4, 4); - setSceneRect(rect); -} diff --git a/examples/GuiClient/chatGraphicsView.h b/examples/GuiClient/chatGraphicsView.h deleted file mode 100644 index 5bb857a6..00000000 --- a/examples/GuiClient/chatGraphicsView.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef CHATGRAPHICSVIEW_H -#define CHATGRAPHICSVIEW_H - -#include <QGraphicsView> -class chatGraphicsScene; - -class chatGraphicsView : public QGraphicsView -{ -public: - chatGraphicsView(QWidget* parent = 0); - void setChatGraphicsScene(chatGraphicsScene* scene); - void addMessage(const QString& user, const QString& message); - -private: - void resizeEvent(QResizeEvent *event); - - chatGraphicsScene* m_scene; -}; - -#endif // CHATGRAPHICSVIEW_H diff --git a/examples/GuiClient/chatMsgGraphicsItem.cpp b/examples/GuiClient/chatMsgGraphicsItem.cpp deleted file mode 100644 index 428c0387..00000000 --- a/examples/GuiClient/chatMsgGraphicsItem.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "chatMsgGraphicsItem.h" - -#include <QPainter> -#include <QTextDocument> -#include <QTime> - -QLinearGradient getGradient(const QColor &col, const QRectF &rect) -{ - QLinearGradient g(rect.topLeft(), rect.bottomLeft()); - - qreal hue = col.hueF(); - qreal value = col.valueF(); - qreal saturation = col.saturationF(); - - QColor c = col; - c.setHsvF(hue, 0.42 * saturation, 0.98 * value); - g.setColorAt(0, c); - c.setHsvF(hue, 0.58 * saturation, 0.95 * value); - g.setColorAt(0.25, c); - c.setHsvF(hue, 0.70 * saturation, 0.93 * value); - g.setColorAt(0.5, c); - - c.setHsvF(hue, 0.95 * saturation, 0.9 * value); - g.setColorAt(0.501, c); - c.setHsvF(hue * 0.95, 0.95 * saturation, 0.95 * value); - g.setColorAt(0.75, c); - c.setHsvF(hue * 0.90, 0.95 * saturation, 1 * value); - g.setColorAt(1.0, c); - - return g; -} - -QLinearGradient darken(const QLinearGradient &gradient) -{ - QGradientStops stops = gradient.stops(); - for (int i = 0; i < stops.size(); ++i) { - QColor color = stops.at(i).second; - stops[i].second = color.darker(160); - } - - QLinearGradient g = gradient; - g.setStops(stops); - return g; -} - -static void drawPath(QPainter *p, const QPainterPath &path, const QColor &col, bool dark = false) -{ - const QRectF pathRect = path.boundingRect(); - - const QLinearGradient baseGradient = getGradient(col, pathRect); - const QLinearGradient darkGradient = darken(baseGradient); - - p->save(); - - // p->setOpacity(0.25); - - //glow -// if (dark) -// p->strokePath(path, QPen(darkGradient, 6)); -// else -// p->strokePath(path, QPen(baseGradient, 6)); - - p->setOpacity(1.0); - - //fill - if (dark) - p->fillPath(path, darkGradient); - else - p->fillPath(path, baseGradient); - - QLinearGradient g(pathRect.topLeft(), pathRect.topRight()); - g.setCoordinateMode(QGradient::ObjectBoundingMode); - - p->setOpacity(0.2); - p->fillPath(path, g); - - p->setOpacity(0.5); - - // highlight -// if (dark) -// p->strokePath(path, QPen(col.lighter(160).darker(160), 2)); -// else -// p->strokePath(path, QPen(col.lighter(160), 2)); - - p->setOpacity(1.0); - - p->restore(); -} - -chatMsgGraphicsItem::chatMsgGraphicsItem(QGraphicsItem * parent):QGraphicsPathItem(parent), - m_spikeWidth(9), - m_spikeHeight(6), - m_cornerRadius(10), - m_textSpacing(4), m_color(Qt::yellow) -{ - setPath(createPath()); -// setFlags(QGraphicsItem::ItemIsMovable); - - QFont font; - QFontMetrics fm(font); - m_timeStampWidth = fm.width(getTime()) + 4; -} - -void chatMsgGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - - painter->setRenderHint(QPainter::Antialiasing); - drawPath(painter, path(), m_color); - -// int spike_x = m_spikeWidth; -// int spike_y = m_spikeHeight; -// int corner = m_cornerRadius; -// int length = m_width - spike_x; -// int offset = spike_x; - QFont font; - font.setBold(true); - QTextDocument textDoc(getText()); - QTextOption textOp; - textOp.setWrapMode(QTextOption::WrapAnywhere); - textOp.setAlignment(Qt::AlignLeft); - textDoc.setDefaultTextOption(textOp); - textDoc.setTextWidth(getTextWidth()); - textDoc.setDefaultFont(font); - - painter->setPen(Qt::white); - painter->setFont(font); - int height = (int) textDoc.size().height(); - painter->drawText(m_spikeWidth + m_cornerRadius, 4, getTextWidth(), height, - Qt::AlignLeft|Qt::TextWrapAnywhere, getText()); - -// painter->setPen(Qt::gray); - painter->setPen(Qt::black); - -// font.setBold(false); - painter->setFont(font); - painter->drawText(-m_boxStartLength, 0, m_boxStartLength, m_height, - Qt::AlignRight|Qt::AlignBottom, getName()); - - font.setBold(false); - painter->setPen(Qt::gray); - painter->setFont(font); - - int timeWidth; - if(m_timeStampWidth > m_boxStartLength) - timeWidth = m_timeStampWidth; - else - timeWidth = m_boxStartLength; - - painter->drawText(getMaxWidth() + 6, 0, timeWidth - 6, m_height, - Qt::AlignBottom|Qt::AlignLeft, getTime()); -} - -void chatMsgGraphicsItem::setText(const QString& text) -{ - m_text = text; - calculateWidth(); - setPath(createPath()); -} - -void chatMsgGraphicsItem::setMaxWidth(int width) -{ - m_maxWidth = width; - setPath(createPath()); -} - -void chatMsgGraphicsItem::setViewWidth(int width) -{ - //25 for scrollbar - setMaxWidth(width - getBoxStartLength() - 25); -} - -int chatMsgGraphicsItem::getMaxWidth() const -{ - return m_maxWidth; -} - -void chatMsgGraphicsItem::setAlignment(Alignment align) -{ - m_alignment = align; - setPath(createPath()); -} - -QPainterPath chatMsgGraphicsItem::createPath() -{ - calculateWidth(); - int spike_x = m_spikeWidth; - int spike_y = m_spikeHeight; - int corner = m_cornerRadius; - int length = m_width - spike_x; - int offset = spike_x; - - QPainterPath messageBoxPath; - messageBoxPath.moveTo(0 + offset, m_height - corner); - QRectF rect(offset - 2*spike_x, m_height - corner - spike_y, 2*spike_x, 2*spike_y); - messageBoxPath.arcMoveTo(rect, -90.0); - messageBoxPath.arcTo(rect, 270, 90.0); - messageBoxPath.lineTo(0 + offset, corner); - messageBoxPath.arcTo(0 + offset, 0, 2*corner, 2*corner, 180, -90.0); - messageBoxPath.lineTo(length - corner, 0); - messageBoxPath.arcTo(length + offset - corner*2, 0, 2*corner, 2*corner, 90, -90.0); - messageBoxPath.lineTo(length + offset, m_height - corner); - messageBoxPath.arcTo(length + offset - corner*2, m_height - 2*corner, 2*corner, 2*corner, 0, -90.0); - messageBoxPath.lineTo(offset + corner, m_height); - messageBoxPath.arcTo(offset, m_height - 2*corner, 2*corner, 2*corner, 270, -45.0); - messageBoxPath.closeSubpath(); - - return messageBoxPath; -} - -QString chatMsgGraphicsItem::getText() const -{ - return m_text; -} - -int chatMsgGraphicsItem::getTextWidth() const -{ - return getMaxWidth() - m_spikeWidth - m_cornerRadius*2; -} - -void chatMsgGraphicsItem::calculateWidth() -{ - QFont font; - font.setBold(true); - QTextDocument textDoc(m_text); - textDoc.setDefaultFont(font); - int idealWidth = (int)textDoc.size().width(); - textDoc.setTextWidth(getTextWidth()); - m_height = (int)textDoc.size().height(); - - if(idealWidth < getTextWidth()) - { - m_width = idealWidth + m_spikeWidth + m_cornerRadius; - } - else - m_width = getMaxWidth(); -} - -void chatMsgGraphicsItem::setName(const QString& name) -{ - m_name = name; - if(name != "Me") - m_color = QColor(0, 210, 250); - else - m_color = QColor(250, 188, 239); -} - -QString chatMsgGraphicsItem::getName() const -{ - return m_name; -} - -QString chatMsgGraphicsItem::getTime() const -{ - return QTime::currentTime().toString("hh:mm"); -} - -void chatMsgGraphicsItem::setBoxStartLength(int length) -{ - m_boxStartLength = length; -} - -int chatMsgGraphicsItem::getBoxStartLength() const -{ - return m_boxStartLength; -} - -void chatMsgGraphicsItem::setColor(const QColor& color) -{ - m_color = color; -} - -QRectF chatMsgGraphicsItem::boundingRect() const -{ - QRectF rect = QGraphicsPathItem::boundingRect(); - rect.setLeft(-getBoxStartLength()); - - int timeWidth; - if(m_timeStampWidth > m_boxStartLength) - timeWidth = m_timeStampWidth; - else - timeWidth = m_boxStartLength; - rect.setRight(getMaxWidth() + timeWidth); - return rect; -} diff --git a/examples/GuiClient/chatMsgGraphicsItem.h b/examples/GuiClient/chatMsgGraphicsItem.h deleted file mode 100644 index 653675fd..00000000 --- a/examples/GuiClient/chatMsgGraphicsItem.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef CHATMSGGRAPHICSITEM_H -#define CHATMSGGRAPHICSITEM_H - -#include <QGraphicsPathItem> - -class chatMsgGraphicsItem : public QGraphicsPathItem -{ -public: - enum Alignment - { - LEFT = 0, - RIGHT - }; - - chatMsgGraphicsItem(QGraphicsItem * parent = 0); - void setText(const QString& text); - void setName(const QString& name); - QString getName() const; - QString getText() const; - - void setMaxWidth(int width); - int getMaxWidth() const; - void setViewWidth(int viewWidth); - - void setAlignment(Alignment align); - - void setBoxStartLength(int length); - int getBoxStartLength() const; - - void setColor(const QColor&); - - virtual QRectF boundingRect() const; - -private: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - QPainterPath createPath(); - int getTextWidth() const; - void calculateWidth(); - QString getTime() const; - - // max width of bubble including the spike - int m_maxWidth; - - // actual width - int m_width; - - // height of bubble - int m_height; - int m_spikeWidth; - int m_spikeHeight; - int m_cornerRadius; - int m_textSpacing; - int m_boxStartLength; - int m_timeStampWidth; - QColor m_color; - - QString m_text; - QString m_name; - int m_length; - Alignment m_alignment; -}; - -#endif // CHATMSGGRAPHICSITEM_H diff --git a/examples/GuiClient/main.cpp b/examples/GuiClient/main.cpp deleted file mode 100644 index a87eb6bb..00000000 --- a/examples/GuiClient/main.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include <QApplication> -#include <QDir> - -#include "mainDialog.h" -#include "utils.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - QApplication::setOrganizationName("QXmpp"); - QApplication::setApplicationName("GuiClient"); - - QDir dir; - if(!dir.exists(getSettingsDir())) - dir.mkpath(getSettingsDir()); - - mainDialog cw; - cw.show(); - cw.raise(); - return a.exec(); -} diff --git a/examples/GuiClient/mainDialog.cpp b/examples/GuiClient/mainDialog.cpp deleted file mode 100644 index fa655cd0..00000000 --- a/examples/GuiClient/mainDialog.cpp +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "mainDialog.h" -#include "ui_mainDialog.h" - -#include "utils.h" -#include "profileDialog.h" -#include "aboutDialog.h" -#include "chatDialog.h" - -#include "QXmppPresence.h" -#include "QXmppMessage.h" -#include "QXmppUtils.h" -#include "QXmppVCardManager.h" - -#include <QMovie> -#include <QCompleter> -#include <QInputDialog> -#include <QMessageBox> -#include <QKeyEvent> - - -mainDialog::mainDialog(QWidget *parent): QDialog(parent, Qt::Window), - ui(new Ui::mainDialogClass), m_rosterItemModel(this), - m_rosterItemSortFilterModel(this), m_vCardCache(&m_xmppClient), - m_capabilitiesCache(&m_xmppClient), m_accountsCache(this), - -#ifndef QT_NO_SYSTEMTRAYICON - m_trayIcon(this), m_trayIconMenu(this), -#endif - - m_quitAction("Quit", this), - m_signOutAction("Sign out", this), - m_settingsMenu(0) -{ - bool check; - Q_UNUSED(check); - - ui->setupUi(this); - createTrayIconAndMenu(); - createSettingsMenu(); - - ui->pushButton_cancel->setDisabled(true); - ui->label_throbber->setMovie(new QMovie(":/icons/resource/ajax-loader.gif")); - ui->label_throbber->movie()->start(); - showSignInPage(); - loadAccounts(); - - check = connect(ui->lineEdit_userName->completer(), - SIGNAL(activated(QString)), - this, SLOT(userNameCompleter_activated(QString))); - Q_ASSERT(check); - - check = connect(&m_xmppClient.rosterManager(), - SIGNAL(rosterReceived()), - this, SLOT(rosterReceived())); - Q_ASSERT(check); - - check = connect(&m_xmppClient.rosterManager(), - SIGNAL(itemChanged(QString)), - this, SLOT(rosterChanged(QString))); - Q_ASSERT(check); - - check = connect(&m_xmppClient, - SIGNAL(error(QXmppClient::Error)), - this, SLOT(errorClient(QXmppClient::Error))); - Q_ASSERT(check); - - check = connect(&m_xmppClient, - SIGNAL(presenceReceived(QXmppPresence)), - this, SLOT(presenceReceived(QXmppPresence))); - Q_ASSERT(check); - - QXmppLogger::getLogger()->setLoggingType(QXmppLogger::SignalLogging); - - - check = connect(&m_xmppClient.rosterManager(), - SIGNAL(presenceChanged(QString,QString)), - this, SLOT(presenceChanged(QString,QString))); - Q_ASSERT(check); - - check = connect(ui->lineEdit_filter, SIGNAL(textChanged(QString)), - this, SLOT(filterChanged(QString))); - Q_ASSERT(check); - - check = connect(ui->listView, SIGNAL(showChatDialog(QString)), - this, SLOT(showChatDialog(QString))); - Q_ASSERT(check); - - check = connect(ui->listView, SIGNAL(showProfile(QString)), - this, SLOT(showProfile(QString))); - Q_ASSERT(check); - - check = connect(ui->listView, SIGNAL(removeContact(QString)), - this, SLOT(action_removeContact(QString))); - Q_ASSERT(check); - - check = connect(&m_xmppClient, SIGNAL(messageReceived(QXmppMessage)), - SLOT(messageReceived(QXmppMessage))); - Q_ASSERT(check); - - check = connect(ui->pushButton_signIn, SIGNAL(clicked(bool)), SLOT(signIn())); - Q_ASSERT(check); - - check = connect(ui->pushButton_cancel, SIGNAL(clicked(bool)), - SLOT(cancelSignIn())); - Q_ASSERT(check); - - m_rosterItemSortFilterModel.setSourceModel(&m_rosterItemModel); - ui->listView->setModel(&m_rosterItemSortFilterModel); - m_rosterItemSortFilterModel.sort(0); - - rosterItemDelegate *delegate = new rosterItemDelegate(); - ui->listView->setItemDelegate(delegate); - ui->listView->setFocus(); - ui->verticalLayout_3->insertWidget(0, &m_statusWidget); - - check = connect(&m_statusWidget, SIGNAL(statusTextChanged(QString)), - SLOT(statusTextChanged(QString))); - Q_ASSERT(check); - check = connect(&m_statusWidget, SIGNAL(presenceTypeChanged(QXmppPresence::Type)), - SLOT(presenceTypeChanged(QXmppPresence::Type))); - Q_ASSERT(check); - check = connect(&m_statusWidget, - SIGNAL(presenceStatusTypeChanged(QXmppPresence::AvailableStatusType)), - SLOT(presenceStatusTypeChanged(QXmppPresence::AvailableStatusType))); - Q_ASSERT(check); - check = connect(&m_statusWidget, - SIGNAL(avatarChanged(QImage)), - SLOT(avatarChanged(QImage))); - Q_ASSERT(check); - - check = connect(&m_xmppClient, SIGNAL(connected()), SLOT(updateStatusWidget())); - Q_ASSERT(check); - - check = connect(&m_xmppClient, SIGNAL(connected()), SLOT(showRosterPage())); - Q_ASSERT(check); - - check = connect(&m_xmppClient, SIGNAL(connected()), SLOT(addAccountToCache())); - Q_ASSERT(check); - - check = connect(&m_xmppClient, SIGNAL(disconnected()), SLOT(showSignInPageAfterUserDisconnection())); - Q_ASSERT(check); - - check = connect(&m_xmppClient.vCardManager(), - SIGNAL(vCardReceived(QXmppVCardIq)), &m_vCardCache, - SLOT(vCardReceived(QXmppVCardIq))); - Q_ASSERT(check); - - check = connect(&m_vCardCache, - SIGNAL(vCardReadyToUse(QString)), - SLOT(updateVCard(QString))); - Q_ASSERT(check); - - check = connect(ui->pushButton_addContact, SIGNAL(clicked()), SLOT(action_addContact())); - Q_ASSERT(check); - - check = connect(QXmppLogger::getLogger(), - SIGNAL(message(QXmppLogger::MessageType,QString)), - &m_consoleDlg, - SLOT(message(QXmppLogger::MessageType,QString))); - Q_ASSERT(check); - - check = connect(ui->pushButton_settings, - SIGNAL(pressed()), - SLOT(action_settingsPressed())); - Q_ASSERT(check); -} - -void mainDialog::rosterChanged(const QString& bareJid) -{ - m_rosterItemModel.updateRosterEntry(bareJid, m_xmppClient.rosterManager(). - getRosterEntry(bareJid)); - - // if available in cache, update it else based on presence it will request if not available - if(m_vCardCache.isVCardAvailable(bareJid)) - updateVCard(bareJid); -} - -void mainDialog::rosterReceived() -{ - QStringList list = m_xmppClient.rosterManager().getRosterBareJids(); - QString bareJid; - foreach(bareJid, list) - rosterChanged(bareJid); -} - -void mainDialog::presenceChanged(const QString& bareJid, const QString& resource) -{ - if(bareJid == m_xmppClient.configuration().jidBare()) - return; - - if(!m_rosterItemModel.getRosterItemFromBareJid(bareJid)) - return; - - QString jid = bareJid + "/" + resource; - QMap<QString, QXmppPresence> presences = m_xmppClient.rosterManager(). - getAllPresencesForBareJid(bareJid); - m_rosterItemModel.updatePresence(bareJid, presences); - - QXmppPresence& pre = presences[resource]; - - if(pre.type() == QXmppPresence::Available) - { - QString node = pre.capabilityNode(); - QString ver = pre.capabilityVer().toBase64(); - QStringList exts = pre.capabilityExt(); - - QString nodeVer = node + "#" + ver; - if(!m_capabilitiesCache.isCapabilityAvailable(nodeVer)) - m_capabilitiesCache.requestInfo(jid, nodeVer); - - foreach(QString ext, exts) - { - nodeVer = node + "#" + ext; - if(!m_capabilitiesCache.isCapabilityAvailable(nodeVer)) - m_capabilitiesCache.requestInfo(jid, nodeVer); - } - - switch(pre.vCardUpdateType()) - { - case QXmppPresence::VCardUpdateNone: - if(!m_vCardCache.isVCardAvailable(bareJid)) - m_vCardCache.requestVCard(bareJid); - case QXmppPresence::VCardUpdateNotReady: - break; - case QXmppPresence::VCardUpdateNoPhoto: - case QXmppPresence::VCardUpdateValidPhoto: - if(m_vCardCache.getPhotoHash(bareJid) != pre.photoHash()) - m_vCardCache.requestVCard(bareJid); - break; - } - } - -// QXmppPresence::Type presenceType = presences.begin().value().getType(); - -// if(!m_vCardCache.isVCardAvailable(bareJid) && -// presenceType == QXmppPresence::Available) -// { -// m_rosterItemModel.updateAvatar(bareJid, -// m_vCardCache.getVCard(bareJid).image); -// } -} - -void mainDialog::filterChanged(const QString& filter) -{ - m_rosterItemSortFilterModel.setFilterRegExp(filter); - - // follow statement selects the first row - ui->listView->selectionModel()->select(ui->listView->model()->index(0, 0), - QItemSelectionModel::ClearAndSelect); -} - -void mainDialog::keyPressEvent(QKeyEvent* event1) -{ - if(ui->stackedWidget->currentIndex() == 0) // roster page - { - if(event1->matches(QKeySequence::Find) ||( - event1->key() <= Qt::Key_9 && event1->key() >= Qt::Key_1) || - (event1->key() <= Qt::Key_Z && event1->key() >= Qt::Key_At) || - event1->key() == Qt::Key_Backspace) - { - ui->lineEdit_filter->setFocus(); - ui->lineEdit_filter->event(event1); - } - else if(event1->key() == Qt::Key_Escape) - { - ui->lineEdit_filter->clear(); - ui->listView->setFocus(); - } - else if(event1->key() == Qt::Key_Up || - event1->key() == Qt::Key_Down || - event1->key() == Qt::Key_PageUp || - event1->key() == Qt::Key_PageDown) - { - ui->listView->setFocus(); - ui->listView->event(event1); - } - else if(event1->key() == Qt::Key_Return && ui->listView->hasFocus()) - { - ui->listView->event(event1); - } - } - -// don't close on escape - if(event1->key() == Qt::Key_Escape) - { - event1->ignore(); - return; - } -// FIXME: I'm not sure what this is supposed to do, but it does not compile. -#if 0 - else if(minimize && e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) - { - event1->ignore(); - return; - } -#endif -// don't close on escape - - if(ui->stackedWidget->currentIndex() == 1) // sign in page - { - QDialog::keyPressEvent(event1); - return; - } -} - -chatDialog* mainDialog::getChatDialog(const QString& bareJid) -{ - if(!m_chatDlgsList.contains(bareJid)) - { - m_chatDlgsList[bareJid] = new chatDialog(); - m_chatDlgsList[bareJid]->setBareJid(bareJid); - - if(!m_rosterItemModel.getRosterItemFromBareJid(bareJid)) - return 0; - - if(!m_rosterItemModel.getRosterItemFromBareJid(bareJid)-> - getName().isEmpty()) - m_chatDlgsList[bareJid]->setDisplayName(m_rosterItemModel. - getRosterItemFromBareJid(bareJid)->getName()); - else - m_chatDlgsList[bareJid]->setDisplayName(QXmppUtils::jidToUser(bareJid)); - - m_chatDlgsList[bareJid]->setQXmppClient(&m_xmppClient); - } - - return m_chatDlgsList[bareJid]; -} - -void mainDialog::showChatDialog(const QString& bareJid) -{ - if(!bareJid.isEmpty()) - getChatDialog(bareJid)->show(); -} - -void mainDialog::messageReceived(const QXmppMessage& msg) -{ - if (msg.body().isEmpty()) - return; - - chatDialog *dialog = getChatDialog(QXmppUtils::jidToBareJid(msg.from())); - if (dialog) { - dialog->show(); - dialog->messageReceived(msg.body()); - } -} - -void mainDialog::statusTextChanged(const QString& status) -{ - QXmppPresence presence = m_xmppClient.clientPresence(); - presence.setStatusText(status); - addPhotoHash(presence); - m_xmppClient.setClientPresence(presence); -} - -void mainDialog::presenceTypeChanged(QXmppPresence::Type presenceType) -{ - if(presenceType == QXmppPresence::Unavailable) - { - m_xmppClient.disconnectFromServer(); - } - else if(presenceType == QXmppPresence::Available) - { - QXmppPresence newPresence = m_xmppClient.clientPresence(); - newPresence.setType(presenceType); - newPresence.setAvailableStatusType(QXmppPresence::Online); - addPhotoHash(newPresence); - m_xmppClient.setClientPresence(newPresence); - } - m_statusWidget.setStatusText( - presenceToStatusText(m_xmppClient.clientPresence())); -} - -void mainDialog::presenceStatusTypeChanged(QXmppPresence::AvailableStatusType statusType) -{ - QXmppPresence presence = m_xmppClient.clientPresence(); - presence.setType(QXmppPresence::Available); - presence.setAvailableStatusType(statusType); - addPhotoHash(presence); - m_xmppClient.setClientPresence(presence); - m_statusWidget.setStatusText( - presenceToStatusText(m_xmppClient.clientPresence())); -} - -void mainDialog::avatarChanged(const QImage& image) -{ - QXmppVCardIq vcard; - vcard.setType(QXmppIq::Set); - - QByteArray ba; - QBuffer buffer(&ba); - if(buffer.open(QIODevice::WriteOnly)) - { - if(image.save(&buffer, "PNG")) - { - vcard.setPhoto(ba); - m_xmppClient.sendPacket(vcard); - m_statusWidget.setAvatar(image); - - m_vCardCache.getVCard(m_xmppClient.configuration().jidBare()) = vcard; - // update photo hash - QXmppPresence presence = m_xmppClient.clientPresence(); - addPhotoHash(presence); - m_xmppClient.setClientPresence(presence); - } - } -} - -void mainDialog::updateStatusWidget() -{ - const QString bareJid = m_xmppClient.configuration().jidBare(); - - // initialise status widget - updateVCard(bareJid); - m_statusWidget.setStatusText(presenceToStatusText(m_xmppClient.clientPresence())); - m_statusWidget.setPresenceAndStatusType(m_xmppClient.clientPresence().type(), - m_xmppClient.clientPresence().availableStatusType()); - - // fetch own vCard - m_vCardCache.requestVCard(bareJid); -} - -void mainDialog::signIn() -{ - ui->label_throbber->show(); - ui->pushButton_signIn->setDisabled(true); - ui->pushButton_cancel->setDisabled(false); - ui->lineEdit_userName->setDisabled(true); - ui->lineEdit_password->setDisabled(true); - ui->checkBox_rememberPasswd->setDisabled(true); - showLoginStatusWithProgress("Connecting"); - - QString bareJid = ui->lineEdit_userName->text(); - QString passwd = ui->lineEdit_password->text(); - - m_xmppClient.configuration().setJid(bareJid); - m_xmppClient.configuration().setPassword(passwd); - - m_rosterItemModel.clear(); - - m_vCardCache.loadFromFile(); - m_capabilitiesCache.loadFromFile(); - - startConnection(); -} - -void mainDialog::cancelSignIn() -{ - if(!ui->checkBox_rememberPasswd->isChecked()) - ui->lineEdit_password->setText(""); - - ui->label_throbber->hide(); - m_xmppClient.disconnectFromServer(); - showSignInPage(); - showLoginStatus("Sign in cancelled"); - addAccountToCache(); -} - -void mainDialog::showSignInPage() -{ - ui->label_throbber->hide(); - ui->pushButton_signIn->setDisabled(false); - ui->pushButton_cancel->setDisabled(true); - ui->lineEdit_userName->setDisabled(false); - ui->lineEdit_password->setDisabled(false); - ui->checkBox_rememberPasswd->setDisabled(false); - ui->stackedWidget->setCurrentIndex(1); -} - -void mainDialog::showSignInPageAfterUserDisconnection() -{ - if(!ui->checkBox_rememberPasswd->isChecked()) - ui->lineEdit_password->setText(""); - - ui->label_throbber->hide(); - - showLoginStatus("Disconnected"); - showSignInPage(); -} - -void mainDialog::showRosterPage() -{ - ui->stackedWidget->setCurrentIndex(0); -} - -void mainDialog::startConnection() -{ -// m_xmppClient.setClientPresence(QXmppPresence()); - m_xmppClient.connectToServer(m_xmppClient.configuration()); -} - -void mainDialog::showLoginStatus(const QString& msg) -{ - ui->label_status->setCustomText(msg, signInStatusLabel::None); -} - -void mainDialog::showLoginStatusWithProgress(const QString& msg) -{ - ui->label_status->setCustomText(msg, signInStatusLabel::WithProgressEllipsis); -} - -void mainDialog::showLoginStatusWithCounter(const QString& msg, int time) -{ - ui->label_status->setCustomText(msg, signInStatusLabel::CountDown, time); -} - -void mainDialog::updateVCard(const QString& bareJid) -{ - // determine full name - const QXmppVCardIq vCard = m_vCardCache.getVCard(bareJid); - QString fullName = vCard.fullName(); - if (fullName.isEmpty()) - fullName = bareJid; - - // determine avatar - QImage avatar = m_vCardCache.getAvatar(bareJid); - if (avatar.isNull()) - avatar = QImage(":/icons/resource/avatar.png"); - - if (bareJid == m_xmppClient.configuration().jidBare()) { - // update our own information - m_statusWidget.setAvatar(avatar); - m_statusWidget.setDisplayName(fullName); - } else { - // update roster information - m_rosterItemModel.updateAvatar(bareJid, avatar); - m_rosterItemModel.updateName(bareJid, fullName); - } -} - -void mainDialog::showProfile(const QString& bareJid) -{ - if(bareJid.isEmpty()) - return; - - profileDialog dlg(this, bareJid, m_xmppClient, m_capabilitiesCache); - dlg.setBareJid(bareJid); - // TODO use original image - if(!m_vCardCache.getAvatar(bareJid).isNull()) - dlg.setAvatar(m_vCardCache.getAvatar(bareJid)); - QStringList resources = m_xmppClient.rosterManager().getResources(bareJid); - - dlg.setFullName(m_vCardCache.getVCard(bareJid).fullName()); - - if(m_vCardCache.getVCard(bareJid).fullName().isEmpty()) - dlg.setFullName(m_xmppClient.rosterManager().getRosterEntry(bareJid).name()); - - dlg.exec(); -} - -void mainDialog::loadAccounts() -{ - m_accountsCache.loadFromFile(); - QStringList list = m_accountsCache.getBareJids(); - QCompleter *completer = new QCompleter(list, this); - completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion); - completer->setCaseSensitivity(Qt::CaseInsensitive); - ui->lineEdit_userName->setCompleter(completer); - - if(!list.isEmpty()) - { - ui->lineEdit_userName->setText(list.last()); - QString passwd = m_accountsCache.getPassword(list.last()); - ui->lineEdit_password->setText(passwd); - if(!passwd.isEmpty()) - ui->checkBox_rememberPasswd->setChecked(true); - } -} - -void mainDialog::userNameCompleter_activated(const QString& user) -{ - QString passwd = m_accountsCache.getPassword(user); - ui->lineEdit_password->setText(passwd); - if(!passwd.isEmpty()) - ui->checkBox_rememberPasswd->setChecked(true); -} - -void mainDialog::addAccountToCache() -{ - QString bareJid = ui->lineEdit_userName->text(); - QString passwd = ui->lineEdit_password->text(); - if(!ui->checkBox_rememberPasswd->isChecked()) - passwd = ""; - m_accountsCache.addAccount(bareJid, passwd); -} - -void mainDialog::action_signOut() -{ - m_xmppClient.disconnectFromServer(); - - // update widget - m_statusWidget.setStatusText( - presenceToStatusText(m_xmppClient.clientPresence())); -} - -void mainDialog::action_quit() -{ - m_xmppClient.disconnectFromServer(); - QApplication::quit(); -} - -void mainDialog::createTrayIconAndMenu() -{ - bool check; - Q_UNUSED(check); - - check = connect(&m_quitAction, SIGNAL(triggered()), SLOT(action_quit())); - Q_ASSERT(check); - - check = connect(&m_signOutAction, SIGNAL(triggered()), SLOT(action_signOut())); - Q_ASSERT(check); - -#ifndef QT_NO_SYSTEMTRAYICON - m_trayIcon.setIcon(QIcon(":/icons/resource/icon.png")); - - check = connect(&m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - SLOT(action_trayIconActivated(QSystemTrayIcon::ActivationReason))); - Q_ASSERT(check); - - m_trayIconMenu.addAction(&m_signOutAction); - m_trayIconMenu.addSeparator(); - m_trayIconMenu.addAction(&m_quitAction); - - m_trayIcon.setContextMenu(&m_trayIconMenu); - m_trayIcon.show(); -#endif -} - -void mainDialog::createSettingsMenu() -{ - m_settingsMenu = new QMenu(ui->pushButton_settings); -// ui->pushButton_settings->setMenu(m_settingsMenu); - - QAction* aboutDlg = new QAction("About", ui->pushButton_settings); - connect(aboutDlg, SIGNAL(triggered()), SLOT(action_aboutDlg())); - m_settingsMenu->addAction(aboutDlg); - - m_settingsMenu->addSeparator(); - - QAction* showXml = new QAction("Show XML Console...", ui->pushButton_settings); - connect(showXml, SIGNAL(triggered()), SLOT(action_showXml())); - m_settingsMenu->addAction(showXml); - - QMenu* viewMenu = new QMenu("View", ui->pushButton_settings); - m_settingsMenu->addMenu(viewMenu); - - QAction* showOfflineContacts = new QAction("Show offline contacts", ui->pushButton_settings); - showOfflineContacts->setCheckable(true); - showOfflineContacts->setChecked(true); - connect(showOfflineContacts, SIGNAL(triggered(bool)), - &m_rosterItemSortFilterModel, SLOT(setShowOfflineContacts(bool))); - viewMenu->addAction(showOfflineContacts); - - QAction* sortByName = new QAction("Sort by name", ui->pushButton_settings); - sortByName->setCheckable(true); - sortByName->setChecked(false); - connect(sortByName, SIGNAL(triggered(bool)), - &m_rosterItemSortFilterModel, SLOT(sortByName(bool))); - viewMenu->addAction(sortByName); - - m_settingsMenu->addSeparator(); - m_settingsMenu->addAction(&m_quitAction); -} - -void mainDialog::closeEvent(QCloseEvent *event) -{ - hide(); - event->ignore(); -} - -void mainDialog::action_trayIconActivated(QSystemTrayIcon::ActivationReason reason) -{ - switch(reason) - { - case QSystemTrayIcon::Trigger: - case QSystemTrayIcon::DoubleClick: - show(); - break; - default: - ; - } -} - -void mainDialog::action_addContact() -{ - bool ok; - QString bareJid = QInputDialog::getText(this, "Add a jabber contact", - "Contact ID:", QLineEdit::Normal, "", &ok); - - if(!ok) - return; - - if(!isValidBareJid(bareJid)) - { - QMessageBox::information(this, "Invalid ID", "Specified ID <I>"+bareJid + " </I> is invalid."); - return; - } - - if(ok && !bareJid.isEmpty()) - { - QXmppPresence subscribe; - subscribe.setTo(bareJid); - subscribe.setType(QXmppPresence::Subscribe); - m_xmppClient.sendPacket(subscribe); - } -} - -void mainDialog::presenceReceived(const QXmppPresence& presence) -{ - QString from = presence.from(); - - QString message; - switch(presence.type()) - { - case QXmppPresence::Subscribe: - { - message = "<B>%1</B> wants to subscribe"; - - int retButton = QMessageBox::question( - this, "Contact Subscription", message.arg(from), - QMessageBox::Yes, QMessageBox::No); - - switch(retButton) - { - case QMessageBox::Yes: - { - QXmppPresence subscribed; - subscribed.setTo(from); - subscribed.setType(QXmppPresence::Subscribed); - m_xmppClient.sendPacket(subscribed); - - // reciprocal subscription - QXmppPresence subscribe; - subscribe.setTo(from); - subscribe.setType(QXmppPresence::Subscribe); - m_xmppClient.sendPacket(subscribe); - } - break; - case QMessageBox::No: - { - QXmppPresence unsubscribed; - unsubscribed.setTo(from); - unsubscribed.setType(QXmppPresence::Unsubscribed); - m_xmppClient.sendPacket(unsubscribed); - } - break; - default: - break; - } - - return; - } - break; - case QXmppPresence::Subscribed: - message = "<B>%1</B> accepted your request"; - break; - case QXmppPresence::Unsubscribe: - message = "<B>%1</B> unsubscribe"; - break; - case QXmppPresence::Unsubscribed: - message = "<B>%1</B> unsubscribed"; - break; - default: - return; - break; - } - - if(message.isEmpty()) - return; - - QMessageBox::information(this, "Contact Subscription", message.arg(from), - QMessageBox::Ok); -} - -void mainDialog::action_removeContact(const QString& bareJid) -{ - if(!isValidBareJid(bareJid)) - return; - - int answer = QMessageBox::question(this, "Remove contact", - QString("Do you want to remove the contact <I>%1</I>").arg(bareJid), - QMessageBox::Yes, QMessageBox::No); - if(answer == QMessageBox::Yes) - { - QXmppRosterIq remove; - remove.setType(QXmppIq::Set); - QXmppRosterIq::Item itemRemove; - itemRemove.setSubscriptionType(QXmppRosterIq::Item::Remove); - itemRemove.setBareJid(bareJid); - remove.addItem(itemRemove); - m_xmppClient.sendPacket(remove); - - m_rosterItemModel.removeRosterEntry(bareJid); - } -} - -void mainDialog::errorClient(QXmppClient::Error error) -{ - ui->label_throbber->hide(); - - showSignInPage(); - - switch(error) - { - case QXmppClient::SocketError: - showLoginStatus("Socket error"); - break; - case QXmppClient::KeepAliveError: - showLoginStatus("Keep alive error"); - break; - case QXmppClient::XmppStreamError: - switch(m_xmppClient.xmppStreamError()) - { - case QXmppStanza::Error::NotAuthorized: - showLoginStatus("Invalid password"); - break; - default: - showLoginStatus("Stream error"); - break; - } - break; - default: - break; - } -} - -void mainDialog::action_showXml() -{ - m_consoleDlg.show(); -} - -void mainDialog::addPhotoHash(QXmppPresence& pre) -{ - QString clientBareJid = m_xmppClient.configuration().jidBare(); - - if(m_vCardCache.isVCardAvailable(clientBareJid)) - { - QByteArray hash = m_vCardCache.getPhotoHash(clientBareJid); - if(hash.isEmpty()) - pre.setVCardUpdateType(QXmppPresence::VCardUpdateNoPhoto); - else - pre.setVCardUpdateType(QXmppPresence::VCardUpdateValidPhoto); - pre.setPhotoHash(hash); - } - else - { - pre.setVCardUpdateType(QXmppPresence::VCardUpdateNone); - pre.setPhotoHash(QByteArray()); - } -} - -void mainDialog::action_aboutDlg() -{ - aboutDialog abtDlg(this); - abtDlg.exec(); -} - -void mainDialog::action_settingsPressed() -{ - m_settingsMenu->exec(ui->pushButton_settings->mapToGlobal(QPoint(0, ui->pushButton_settings->height()))); -} diff --git a/examples/GuiClient/mainDialog.h b/examples/GuiClient/mainDialog.h deleted file mode 100644 index 1834074b..00000000 --- a/examples/GuiClient/mainDialog.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef MAINDIALOG_H -#define MAINDIALOG_H - -#include <QDialog> -#include <QMap> -#include <QSystemTrayIcon> -#include <QMenu> - -#include "rosterItemModel.h" -#include "rosterItemSortFilterProxyModel.h" -#include "statusWidget.h" -#include "vCardCache.h" -#include "capabilitiesCache.h" -#include "accountsCache.h" -#include "xmlConsoleDialog.h" - -#include "QXmppClient.h" - -class chatDialog; - -class QKeyEvent; - -namespace Ui -{ - class mainDialogClass; -} - -class mainDialog : public QDialog -{ - Q_OBJECT - -public: - mainDialog(QWidget *parent = 0); - -protected: - void keyPressEvent(QKeyEvent*); - void closeEvent(QCloseEvent* event); - -private slots: - void rosterChanged(const QString& bareJid); - void rosterReceived(); - void presenceChanged(const QString&, const QString&); - void filterChanged(const QString& filter); - void showChatDialog(const QString& bareJid); - void messageReceived(const QXmppMessage& msg); - void statusTextChanged(const QString&); - void presenceTypeChanged(QXmppPresence::Type); - void presenceStatusTypeChanged(QXmppPresence::AvailableStatusType); - void signIn(); - void cancelSignIn(); - void showSignInPage(); - void showSignInPageAfterUserDisconnection(); - void showRosterPage(); - void startConnection(); - void updateStatusWidget(); - void showLoginStatusWithProgress(const QString& msg); - void showLoginStatus(const QString& msg); - void showLoginStatusWithCounter(const QString& msg, int time); - void updateVCard(const QString& bareJid); - void avatarChanged(const QImage&); - void showProfile(const QString& bareJid); - void userNameCompleter_activated(const QString&); - void addAccountToCache(); - void presenceReceived(const QXmppPresence&); - void errorClient(QXmppClient::Error); - - void action_addContact(); - void action_removeContact(const QString& bareJid); - void action_signOut(); - void action_quit(); - void action_trayIconActivated(QSystemTrayIcon::ActivationReason reason); - - void action_showXml(); - void action_aboutDlg(); - void action_settingsPressed(); - -private: - void loadAccounts(); - void createTrayIconAndMenu(); - void createSettingsMenu(); - - void addPhotoHash(QXmppPresence&); - - chatDialog* getChatDialog(const QString& bareJid); - - Ui::mainDialogClass* ui; - QXmppClient m_xmppClient; - rosterItemModel m_rosterItemModel; - rosterItemSortFilterProxyModel m_rosterItemSortFilterModel; - statusWidget m_statusWidget; - vCardCache m_vCardCache; - capabilitiesCache m_capabilitiesCache; - accountsCache m_accountsCache; - - // map of bare jids and respective chatdlg - QMap<QString, chatDialog*> m_chatDlgsList; - -#ifndef QT_NO_SYSTEMTRAYICON - QSystemTrayIcon m_trayIcon; - QMenu m_trayIconMenu; -#endif - - QAction m_quitAction; - QAction m_signOutAction; - - xmlConsoleDialog m_consoleDlg; - - QMenu* m_settingsMenu; -}; - -#endif // MAINDIALOG_H diff --git a/examples/GuiClient/mainDialog.ui b/examples/GuiClient/mainDialog.ui deleted file mode 100644 index 635ca47b..00000000 --- a/examples/GuiClient/mainDialog.ui +++ /dev/null @@ -1,385 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>mainDialogClass</class> - <widget class="QDialog" name="mainDialogClass"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>236</width> - <height>484</height> - </rect> - </property> - <property name="windowTitle"> - <string>QXmpp</string> - </property> - <property name="windowIcon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/icon.png</normaloff>:/icons/resource/icon.png</iconset> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="margin"> - <number>6</number> - </property> - <item> - <widget class="QStackedWidget" name="stackedWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="page"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>4</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="searchLineEdit" name="lineEdit_filter"> - <property name="enabled"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="rosterListView" name="listView"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <property name="verticalScrollMode"> - <enum>QAbstractItemView::ScrollPerPixel</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QPushButton" name="pushButton_addContact"> - <property name="minimumSize"> - <size> - <width>29</width> - <height>29</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>29</width> - <height>29</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/addButton.png</normaloff>:/icons/resource/addButton.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>29</width> - <height>29</height> - </size> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_settings"> - <property name="minimumSize"> - <size> - <width>29</width> - <height>29</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>29</width> - <height>29</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/settingsButton.png</normaloff>:/icons/resource/settingsButton.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>29</width> - <height>29</height> - </size> - </property> - <property name="default"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_2"> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>20</number> - </property> - <property name="rightMargin"> - <number>20</number> - </property> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Login:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_userName"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit_password"> - <property name="text"> - <string/> - </property> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBox_rememberPasswd"> - <property name="text"> - <string>Remember password</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_signIn"> - <property name="text"> - <string>Sign in</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_cancel"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="signInStatusLabel" name="label_status"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <spacer name="horizontalSpacer_6"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_throbber"> - <property name="text"> - <string>movie</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>35</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_7"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>70</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>rosterListView</class> - <extends>QListView</extends> - <header>rosterListView.h</header> - </customwidget> - <customwidget> - <class>searchLineEdit</class> - <extends>QLineEdit</extends> - <header>searchLineEdit.h</header> - </customwidget> - <customwidget> - <class>signInStatusLabel</class> - <extends>QLabel</extends> - <header>signInStatusLabel.h</header> - </customwidget> - </customwidgets> - <resources> - <include location="resources.qrc"/> - </resources> - <connections/> -</ui> diff --git a/examples/GuiClient/profileDialog.cpp b/examples/GuiClient/profileDialog.cpp deleted file mode 100644 index 384d2fa7..00000000 --- a/examples/GuiClient/profileDialog.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "profileDialog.h" -#include "ui_profileDialog.h" -#include "utils.h" - -#include "QXmppClient.h" -#include "QXmppVersionIq.h" -#include "QXmppVersionManager.h" -#include "QXmppRosterManager.h" -#include "QXmppUtils.h" -#include "QXmppEntityTimeManager.h" -#include "QXmppEntityTimeIq.h" -#include "QXmppConstants.h" - -profileDialog::profileDialog(QWidget *parent, const QString& bareJid, QXmppClient& client, capabilitiesCache& caps) : - QDialog(parent, Qt::WindowTitleHint|Qt::WindowSystemMenuHint), - ui(new Ui::profileDialog), m_bareJid(bareJid), m_xmppClient(client), m_caps(caps) -{ - bool check; - Q_UNUSED(check); - - ui->setupUi(this); - - check = connect(&m_xmppClient.versionManager(), SIGNAL(versionReceived(QXmppVersionIq)), - SLOT(versionReceived(QXmppVersionIq))); - Q_ASSERT(check); - - QXmppEntityTimeManager* timeManager = m_xmppClient.findExtension<QXmppEntityTimeManager>(); - - if(timeManager) - { - check = connect(timeManager, SIGNAL(timeReceived(QXmppEntityTimeIq)), - SLOT(timeReceived(QXmppEntityTimeIq))); - Q_ASSERT(check); - } - - QStringList resources = m_xmppClient.rosterManager().getResources(bareJid); - foreach(QString resource, resources) - { - QString jid = bareJid + "/" + resource; - m_xmppClient.versionManager().requestVersion(jid); - if(timeManager) - timeManager->requestTime(jid); - } - updateText(); -} - -profileDialog::~profileDialog() -{ - delete ui; -} - -void profileDialog::setAvatar(const QImage& image) -{ - ui->label_avatar->setPixmap(QPixmap::fromImage(image)); -} - -void profileDialog::setBareJid(const QString& bareJid) -{ - ui->label_jid->setText(bareJid); - setWindowTitle(bareJid); -} - -void profileDialog::setFullName(const QString& fullName) -{ - if(fullName.isEmpty()) - ui->label_fullName->hide(); - else - ui->label_fullName->show(); - - ui->label_fullName->setText(fullName); -} - -void profileDialog::setStatusText(const QString& status) -{ - ui->label_status->setText(status); -} - -void profileDialog::versionReceived(const QXmppVersionIq& ver) -{ - m_versions[QXmppUtils::jidToResource(ver.from())] = ver; - if(ver.type() == QXmppIq::Result) - updateText(); -} - -void profileDialog::timeReceived(const QXmppEntityTimeIq& time) -{ - m_time[QXmppUtils::jidToResource(time.from())] = time; - if(time.type() == QXmppIq::Result) - updateText(); -} - -void profileDialog::updateText() -{ - QStringList resources = m_xmppClient.rosterManager().getResources(m_bareJid); - QString statusText; - for(int i = 0; i < resources.count(); ++i) - { - QString resource = resources.at(i); - statusText += "<B>Resource: </B>" + resource; - statusText += "<BR>"; - QXmppPresence presence = m_xmppClient.rosterManager().getPresence(m_bareJid, resource); - statusText += "<B>Status: </B>" + presenceToStatusText(presence); - statusText += "<BR>"; - if(m_versions.contains(resource)) - { - statusText += "<B>Software: </B>" + QString("%1 %2 %3"). - arg(m_versions[resource].name()). - arg(m_versions[resource].version()). - arg(m_versions[resource].os()); - statusText += "<BR>"; - } - - if(m_time.contains(resource)) - { - statusText += "<B>Time: </B>" + QString("utc=%1 [tzo=%2]"). - arg(m_time[resource].utc().toString()). - arg(QXmppUtils::timezoneOffsetToString(m_time[resource].tzo())); - statusText += "<BR>"; - } - - statusText += getCapability(resource); - - if(i < resources.count() - 1) // skip for the last item - statusText += "<BR>"; - } - setStatusText(statusText); -} - -QString profileDialog::getCapability(const QString& resource) -{ - QMap<QString, QXmppPresence> presences = m_xmppClient.rosterManager(). - getAllPresencesForBareJid(m_bareJid); - QXmppPresence& pre = presences[resource]; - QString nodeVer; - QStringList resultFeatures; - QStringList resultIdentities; - - QString node = pre.capabilityNode(); - QString ver = pre.capabilityVer().toBase64(); - QStringList exts = pre.capabilityExt(); - nodeVer = node + "#" + ver; - if(m_caps.isCapabilityAvailable(nodeVer)) - { - resultFeatures << m_caps.getFeatures(nodeVer); - resultIdentities << m_caps.getIdentities(nodeVer); - } - foreach(QString ext, exts) - { - nodeVer = node + "#" + ext; - if(m_caps.isCapabilityAvailable(nodeVer)) - { - resultFeatures << m_caps.getFeatures(nodeVer); - resultIdentities << m_caps.getIdentities(nodeVer); - } - } - - resultIdentities.removeDuplicates(); - resultFeatures.removeDuplicates(); - - QString result; - result += "<B>Disco Identities:</B><BR>"; - result += resultIdentities.join("<BR>"); - result += "<BR>"; - result += "<B>Disco Features:</B><BR>"; - result += resultFeatures.join("<BR>"); - result += "<BR>"; - return result; -} diff --git a/examples/GuiClient/profileDialog.h b/examples/GuiClient/profileDialog.h deleted file mode 100644 index c1f912bf..00000000 --- a/examples/GuiClient/profileDialog.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef PROFILEDIALOG_H -#define PROFILEDIALOG_H - -#include <QDialog> -#include <QMap> -#include "capabilitiesCache.h" - -namespace Ui { - class profileDialog; -} - -class QXmppClient; -class QXmppVersionIq; -class QXmppEntityTimeIq; - -class profileDialog : public QDialog -{ - Q_OBJECT - -public: - explicit profileDialog(QWidget *parent, const QString& bareJid, QXmppClient& client, capabilitiesCache& caps); - ~profileDialog(); - - void setClientRef(QXmppClient& m_xmppClient); - void setAvatar(const QImage&); - void setBareJid(const QString&); - void setFullName(const QString&); - void setStatusText(const QString&); - -private slots: - void versionReceived(const QXmppVersionIq&); - void timeReceived(const QXmppEntityTimeIq&); - -private: - void updateText(); - QString getCapability(const QString& resource); - -private: - Ui::profileDialog *ui; - QString m_bareJid; - QXmppClient& m_xmppClient; // reference to the active QXmppClient (No ownership) - capabilitiesCache& m_caps; // reference to the active QXmppClient (No ownership) - QMap<QString, QXmppVersionIq> m_versions; - QMap<QString, QXmppEntityTimeIq> m_time; -}; - -#endif // PROFILEDIALOG_H diff --git a/examples/GuiClient/profileDialog.ui b/examples/GuiClient/profileDialog.ui deleted file mode 100644 index 84407c10..00000000 --- a/examples/GuiClient/profileDialog.ui +++ /dev/null @@ -1,205 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>profileDialog</class> - <widget class="QDialog" name="profileDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>309</width> - <height>209</height> - </rect> - </property> - <property name="windowTitle"> - <string>Profile</string> - </property> - <property name="sizeGripEnabled"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="margin"> - <number>6</number> - </property> - <item> - <widget class="QScrollArea" name="scrollArea"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>297</width> - <height>168</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetFixedSize</enum> - </property> - <item> - <widget class="QLabel" name="label_avatar"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>96</width> - <height>96</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>96</width> - <height>96</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="resources.qrc">:/icons/resource/avatar.png</pixmap> - </property> - <property name="scaledContents"> - <bool>true</bool> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label_fullName"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_jid"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_status"> - <property name="text"> - <string>TextLabel</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="resources.qrc"/> - </resources> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>profileDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>343</x> - <y>215</y> - </hint> - <hint type="destinationlabel"> - <x>301</x> - <y>191</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>profileDialog</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel"> - <x>237</x> - <y>216</y> - </hint> - <hint type="destinationlabel"> - <x>230</x> - <y>172</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/examples/GuiClient/resource/addButton.png b/examples/GuiClient/resource/addButton.png Binary files differdeleted file mode 100644 index a1e620e8..00000000 --- a/examples/GuiClient/resource/addButton.png +++ /dev/null diff --git a/examples/GuiClient/resource/ajax-loader.gif b/examples/GuiClient/resource/ajax-loader.gif Binary files differdeleted file mode 100644 index 3288d103..00000000 --- a/examples/GuiClient/resource/ajax-loader.gif +++ /dev/null diff --git a/examples/GuiClient/resource/avatar.png b/examples/GuiClient/resource/avatar.png Binary files differdeleted file mode 100644 index 1a8111c7..00000000 --- a/examples/GuiClient/resource/avatar.png +++ /dev/null diff --git a/examples/GuiClient/resource/downArrow.png b/examples/GuiClient/resource/downArrow.png Binary files differdeleted file mode 100644 index 365684bd..00000000 --- a/examples/GuiClient/resource/downArrow.png +++ /dev/null diff --git a/examples/GuiClient/resource/gray.png b/examples/GuiClient/resource/gray.png Binary files differdeleted file mode 100644 index 152d8e18..00000000 --- a/examples/GuiClient/resource/gray.png +++ /dev/null diff --git a/examples/GuiClient/resource/green.png b/examples/GuiClient/resource/green.png Binary files differdeleted file mode 100644 index aed27a33..00000000 --- a/examples/GuiClient/resource/green.png +++ /dev/null diff --git a/examples/GuiClient/resource/icon.png b/examples/GuiClient/resource/icon.png Binary files differdeleted file mode 100644 index e6b17b18..00000000 --- a/examples/GuiClient/resource/icon.png +++ /dev/null diff --git a/examples/GuiClient/resource/icon.xcf b/examples/GuiClient/resource/icon.xcf Binary files differdeleted file mode 100644 index 8a56c227..00000000 --- a/examples/GuiClient/resource/icon.xcf +++ /dev/null diff --git a/examples/GuiClient/resource/orange.png b/examples/GuiClient/resource/orange.png Binary files differdeleted file mode 100644 index 9f6611c7..00000000 --- a/examples/GuiClient/resource/orange.png +++ /dev/null diff --git a/examples/GuiClient/resource/red.png b/examples/GuiClient/resource/red.png Binary files differdeleted file mode 100644 index 9f356080..00000000 --- a/examples/GuiClient/resource/red.png +++ /dev/null diff --git a/examples/GuiClient/resource/redred.png b/examples/GuiClient/resource/redred.png Binary files differdeleted file mode 100644 index 3cf1bc72..00000000 --- a/examples/GuiClient/resource/redred.png +++ /dev/null diff --git a/examples/GuiClient/resource/searchIcon.png b/examples/GuiClient/resource/searchIcon.png Binary files differdeleted file mode 100644 index d8c1e9bd..00000000 --- a/examples/GuiClient/resource/searchIcon.png +++ /dev/null diff --git a/examples/GuiClient/resource/settingsButton.png b/examples/GuiClient/resource/settingsButton.png Binary files differdeleted file mode 100644 index f569b63e..00000000 --- a/examples/GuiClient/resource/settingsButton.png +++ /dev/null diff --git a/examples/GuiClient/resources.qrc b/examples/GuiClient/resources.qrc deleted file mode 100644 index 67ec1dd8..00000000 --- a/examples/GuiClient/resources.qrc +++ /dev/null @@ -1,15 +0,0 @@ -<RCC> - <qresource prefix="/icons"> - <file>resource/green.png</file> - <file>resource/orange.png</file> - <file>resource/red.png</file> - <file>resource/gray.png</file> - <file>resource/avatar.png</file> - <file>resource/searchIcon.png</file> - <file>resource/downArrow.png</file> - <file>resource/ajax-loader.gif</file> - <file>resource/icon.png</file> - <file>resource/settingsButton.png</file> - <file>resource/addButton.png</file> - </qresource> -</RCC> diff --git a/examples/GuiClient/rosterItem.cpp b/examples/GuiClient/rosterItem.cpp deleted file mode 100644 index 19d2233d..00000000 --- a/examples/GuiClient/rosterItem.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "rosterItem.h" -#include <QImage> - -rosterItem::rosterItem(const QString& bareJid) -{ - setData(bareJid, rosterItem::BareJid); - setData("Offline", rosterItem::StatusText); - setAvatar(QImage(":/icons/resource/avatar.png")); - setIcon(QIcon(":/icons/resource/gray.png")); -} - -void rosterItem::setName(const QString& name) -{ - setText(name); -} - -QString rosterItem::getName() -{ - return text(); -} - -void rosterItem::setPresence(const QXmppPresence &presence) -{ - // determine status text - QString statusText = presence.statusText(); - if (statusText.isEmpty()) { - if(presence.type() == QXmppPresence::Available) - statusText = "Available"; - else if(presence.type() == QXmppPresence::Unavailable) - statusText = "Offline"; - } - - // store data - setData(statusText, rosterItem::StatusText); - setData(static_cast<int>(presence.type()), PresenceType); - setData(static_cast<int>(presence.availableStatusType()), StatusType); - - // update icon - QString icon; - if (presence.type() == QXmppPresence::Available) { - switch (presence.availableStatusType()) - { - case QXmppPresence::Online: - case QXmppPresence::Chat: - icon = "green"; - break; - case QXmppPresence::Away: - case QXmppPresence::XA: - icon = "orange"; - break; - case QXmppPresence::DND: - icon = "red"; - break; - case QXmppPresence::Invisible: - icon = "gray"; - break; - } - } else { - icon = "gray"; - } - if (!icon.isEmpty()) - setIcon(QIcon(":/icons/resource/"+icon+".png")); -} - -void rosterItem::setAvatar(const QImage& image) -{ - setData(QVariant(image), rosterItem::Avatar); -} - -QImage rosterItem::getAvatar() -{ - return qvariant_cast<QImage>(data(rosterItem::Avatar)); -} - -rosterItemDelegate::rosterItemDelegate() -{ -} - -QSize rosterItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex & index) const -{ - Q_UNUSED(option); - Q_UNUSED(index); - return QSize(44, 36); -} - -void rosterItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - painter->save(); - painter->setRenderHint(QPainter::TextAntialiasing); - QVariant value = index.data(Qt::DecorationRole); - - QColor selectedBg(60, 140, 222); - QColor alternateBg(239, 245, 254); - QColor selectedText(Qt::white); - - QColor nameTextColor(Qt::black); - QColor statusTextColor(Qt::darkGray); - - QPixmap pixmap; - if(value.type() == QVariant::Icon) - { - QIcon icon = qvariant_cast<QIcon>(value); - pixmap = icon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On); - } - - QPen penDivision; -// if(index.row() % 2) -// painter->fillRect(option.rect, alternateBg); - - if (option.state & QStyle::State_Selected) - { - painter->fillRect(option.rect, selectedBg); -// painter->fillRect(option.rect, option.palette.highlight()); -// penDivision.setColor(option.palette.highlight().color()); - penDivision.setColor(selectedBg); - nameTextColor = selectedText; - statusTextColor = selectedText; - } - else - { - penDivision.setColor(QColor(244, 244, 244)); - } - - QRect rect = option.rect; - rect.setWidth(pixmap.width()); - rect.setHeight(pixmap.height()); - rect.moveTop(rect.y() + (option.rect.height() - pixmap.height())/2); - rect.moveLeft(rect.left() + 2); - painter->drawPixmap(rect, pixmap); - - rect = option.rect; - rect.setLeft(rect.x() + pixmap.width() + 8); - rect.moveTop(rect.y() + 3); - QFont font; - painter->setFont(font); - painter->setPen(nameTextColor); - if(!index.data(Qt::DisplayRole).toString().isEmpty()) - painter->drawText(rect, index.data(Qt::DisplayRole).toString()); - else - painter->drawText(rect, index.data(rosterItem::BareJid).toString()); - - painter->setPen(statusTextColor); - rect.setTop(rect.y() + rect.height()/2); - rect.moveTop(rect.y() - 3); - QString statusText = index.data(rosterItem::StatusText).toString(); - QFontMetrics fontMetrics(font); - statusText = fontMetrics.elidedText(statusText, Qt::ElideRight, rect.width() - 34); - painter->drawText(rect, statusText); - - penDivision.setWidth(0); - painter->setPen(penDivision); - - rect = option.rect; - QPoint left = rect.bottomLeft(); - left.setX(left.x() + 4); - QPoint right = rect.bottomRight(); - right.setX(right.x() - 4); - painter->drawLine(left, right); - - QImage image; - value = index.data(rosterItem::Avatar); - if(value.type() == QVariant::Image) - { - image = qvariant_cast<QImage>(value); - } - - pixmap = QPixmap(":/icons/resource/avatar.png"); - rect = option.rect; - rect.setWidth(pixmap.width()); - rect.setHeight(pixmap.height()); - rect.moveTop(rect.y() + (option.rect.height() - pixmap.height())/2); - rect.moveLeft(option.rect.x() + option.rect.width() - pixmap.width() - 2); - -// if(image.isNull()) -// painter->drawPixmap(rect, pixmap); -// else - painter->drawImage(rect, image); - - painter->restore(); -} diff --git a/examples/GuiClient/rosterItem.h b/examples/GuiClient/rosterItem.h deleted file mode 100644 index 81ec93dd..00000000 --- a/examples/GuiClient/rosterItem.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef ROSTERITEM_H -#define ROSTERITEM_H - -#include <QStandardItem> -#include <QItemDelegate> -#include <QPainter> -#include "QXmppPresence.h" - -class rosterItem : public QStandardItem -{ -public: - enum userRoles - { - StatusText = Qt::UserRole + 2, - StatusType, - PresenceType, - BareJid, - Avatar - }; - - rosterItem(const QString& bareJid); - - void setAvatar(const QImage& image); - void setPresence(const QXmppPresence &presence); - void setName(const QString& name); - QImage getAvatar(); - QString getName(); -}; - -class rosterItemDelegate : public QItemDelegate -{ -public: - rosterItemDelegate(); - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; -}; - -#endif // ROSTERITEM_H diff --git a/examples/GuiClient/rosterItemModel.cpp b/examples/GuiClient/rosterItemModel.cpp deleted file mode 100644 index ef3a4545..00000000 --- a/examples/GuiClient/rosterItemModel.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "rosterItemModel.h" - -rosterItemModel::rosterItemModel(QObject* parent) : QStandardItemModel(parent) -{ -// addRosterItemIfDontExist("jkhjkhkhkhk"); -// addRosterItemIfDontExist("uuuu"); -// addRosterItemIfDontExist("kkkkkkk"); -// addRosterItemIfDontExist("jjjjjjjj"); -} - -rosterItem* rosterItemModel::getRosterItemFromBareJid(const QString& bareJid) -{ - if(m_jidRosterItemMap.contains(bareJid)) - return m_jidRosterItemMap[bareJid]; - else - return 0; -} - -rosterItem* rosterItemModel::getOrCreateItem(const QString& bareJid) -{ - if(m_jidRosterItemMap.contains(bareJid)) { - return m_jidRosterItemMap[bareJid]; - } else { - rosterItem* item = new rosterItem(bareJid); - m_jidRosterItemMap[bareJid] = item; - appendRow(item); - return item; - } -} - -void rosterItemModel::updatePresence(const QString& bareJid, const QMap<QString, QXmppPresence>& presences) -{ - rosterItem *item = getOrCreateItem(bareJid); - if (!presences.isEmpty()) - item->setPresence(*presences.begin()); - else - item->setPresence(QXmppPresence(QXmppPresence::Unavailable)); -} - -void rosterItemModel::updateRosterEntry(const QString& bareJid, const QXmppRosterIq::Item& rosterEntry) -{ - getOrCreateItem(bareJid)->setName(rosterEntry.name()); -} - -void rosterItemModel::updateAvatar(const QString& bareJid, const QImage& image) -{ - getOrCreateItem(bareJid)->setAvatar(image); -} - -void rosterItemModel::updateName(const QString& bareJid, const QString& name) -{ - if (!name.isEmpty()) - getOrCreateItem(bareJid)->setName(name); -} - -void rosterItemModel::clear() -{ - QStandardItemModel::clear(); - m_jidRosterItemMap.clear(); -} - -void rosterItemModel::removeRosterEntry(const QString& bareJid) -{ - rosterItem* item = getRosterItemFromBareJid(bareJid); - if(item) - { - removeRow(item->row()); - } -} diff --git a/examples/GuiClient/rosterItemModel.h b/examples/GuiClient/rosterItemModel.h deleted file mode 100644 index 7efb91b4..00000000 --- a/examples/GuiClient/rosterItemModel.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef ROSTERITEMMODEL_H -#define ROSTERITEMMODEL_H - -#include <QStandardItemModel> -#include "rosterItem.h" -#include "QXmppRosterManager.h" -#include "QXmppPresence.h" - -class rosterItemModel : public QStandardItemModel -{ -public: - rosterItemModel(QObject* parent); - rosterItem* getRosterItemFromBareJid(const QString& bareJid); - - void updatePresence(const QString& bareJid, const QMap<QString, QXmppPresence>& presences); - void updateRosterEntry(const QString& bareJid, const QXmppRosterIq::Item& rosterEntry); - void updateAvatar(const QString& bareJid, const QImage& image); - void updateName(const QString& bareJid, const QString& name); - - void removeRosterEntry(const QString& bareJid); - - void clear(); - -private: - rosterItem* getOrCreateItem(const QString& bareJid); - QMap<QString, rosterItem*> m_jidRosterItemMap; -}; - -#endif // ROSTERITEMMODEL_H diff --git a/examples/GuiClient/rosterItemSortFilterProxyModel.cpp b/examples/GuiClient/rosterItemSortFilterProxyModel.cpp deleted file mode 100644 index cf47550a..00000000 --- a/examples/GuiClient/rosterItemSortFilterProxyModel.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "rosterItemSortFilterProxyModel.h" -#include "rosterItem.h" -#include "utils.h" - -rosterItemSortFilterProxyModel::rosterItemSortFilterProxyModel(QObject* parent): - QSortFilterProxyModel(parent), - m_showOfflineContacts(true), - m_sortByName(false) -{ - setDynamicSortFilter(true); - setFilterRole(Qt::DisplayRole); - setFilterCaseSensitivity(Qt::CaseInsensitive); -} - -bool rosterItemSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const -{ - if(m_sortByName) - { - int compare = left.data().toString().compare(right.data().toString(), Qt::CaseInsensitive); - if(compare < 0) - return true; - else - return false; - } - else - { - int leftPresenceType = sourceModel()->data(left, rosterItem::PresenceType).toInt(); - int leftStatusType = sourceModel()->data(left, rosterItem::StatusType).toInt(); - int rightPresenceType = sourceModel()->data(right, rosterItem::PresenceType).toInt(); - int rightStatusType = sourceModel()->data(right, rosterItem::StatusType).toInt(); - - if(leftPresenceType == rightPresenceType) - { - if(leftStatusType == rightStatusType) - { - // based on display text - int compare = left.data().toString().compare(right.data().toString(), Qt::CaseInsensitive); - if(compare < 0) - return true; - else - return false; - } - else - { - return comparisonWeightsPresenceStatusType(static_cast<QXmppPresence::AvailableStatusType>(leftStatusType)) < - comparisonWeightsPresenceStatusType(static_cast<QXmppPresence::AvailableStatusType>(rightStatusType)); - } - } - else - return comparisonWeightsPresenceType(static_cast<QXmppPresence::Type>(leftPresenceType)) < - comparisonWeightsPresenceType(static_cast<QXmppPresence::Type>(rightPresenceType)); - } -} - -bool rosterItemSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const -{ - if(!filterRegExp().isEmpty()) - return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); - - if(m_showOfflineContacts) - return true; - - QModelIndex index = sourceModel()->index(source_row, 0, source_parent); - - int presenceType = sourceModel()->data(index, rosterItem::PresenceType).toInt(); - - if(presenceType == QXmppPresence::Available) - return true; - else - return false; -} - -void rosterItemSortFilterProxyModel::setShowOfflineContacts(bool showOfflineContacts) -{ - m_showOfflineContacts = showOfflineContacts; - invalidateFilter(); -} - -void rosterItemSortFilterProxyModel::sortByName(bool sortByName) -{ - m_sortByName = sortByName; - invalidate(); -} - diff --git a/examples/GuiClient/rosterItemSortFilterProxyModel.h b/examples/GuiClient/rosterItemSortFilterProxyModel.h deleted file mode 100644 index e4a413d3..00000000 --- a/examples/GuiClient/rosterItemSortFilterProxyModel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef ROSTERITEMSORTFILTERPROXYMODEL_H -#define ROSTERITEMSORTFILTERPROXYMODEL_H - -#include <QSortFilterProxyModel> - -class rosterItemSortFilterProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - rosterItemSortFilterProxyModel(QObject* parent = 0); - -public slots: - void setShowOfflineContacts(bool); - void sortByName(bool); - -private: - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; - bool filterAcceptsRow(int, const QModelIndex&) const; - - bool m_showOfflineContacts; - bool m_sortByName; -}; - -#endif // ROSTERITEMSORTFILTERPROXYMODEL_H diff --git a/examples/GuiClient/rosterListView.cpp b/examples/GuiClient/rosterListView.cpp deleted file mode 100644 index a832f3e1..00000000 --- a/examples/GuiClient/rosterListView.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "rosterListView.h" -#include "rosterItem.h" -#include <QApplication> -#include <QMenu> -#include <QKeyEvent> - -rosterListView::rosterListView(QWidget* parent) - : QListView(parent) - , m_chat("Chat", this) - , m_profile("View Profile", this) - , m_removeContact("Remove", this) -{ - bool check; - Q_UNUSED(check); - - check = connect(this, SIGNAL(pressed(QModelIndex)), this, - SLOT(mousePressed(QModelIndex))); - Q_ASSERT(check); - check = connect(this, SIGNAL(doubleClicked(QModelIndex)), this, - SLOT(doubleClicked(QModelIndex))); - Q_ASSERT(check); - check = connect(this, SIGNAL(clicked(QModelIndex)), this, - SLOT(clicked(QModelIndex))); - Q_ASSERT(check); - check = connect(&m_chat, SIGNAL(triggered()), this, - SLOT(showChatDialog_helper())); - Q_ASSERT(check); - - check = connect(&m_profile, SIGNAL(triggered()), this, - SLOT(showProfile_helper())); - Q_ASSERT(check); - - check = connect(&m_removeContact, SIGNAL(triggered()), this, - SLOT(removeContact_helper())); - Q_ASSERT(check); -} - -bool rosterListView::event(QEvent* e) -{ - return QListView::event(e); -} - -void rosterListView::mousePressed(const QModelIndex& index) -{ - if(QApplication::mouseButtons() == Qt::RightButton) - { - QString bareJid = index.data().toString(); - QMenu menu(this); - menu.addAction(&m_chat); - menu.setDefaultAction(&m_chat); - menu.addAction(&m_profile); - menu.addAction(&m_removeContact); - menu.exec(QCursor::pos()); - } -} - -void rosterListView::doubleClicked(const QModelIndex& index) -{ - Q_UNUSED(index); - m_chat.trigger(); -} - -void rosterListView::clicked(const QModelIndex& index) -{ - Q_UNUSED(index); -} - -QString rosterListView::selectedBareJid() -{ - if(selectedIndexes().size() > 0) - return selectedIndexes().at(0).data(rosterItem::BareJid).toString(); - else - return ""; -} - -void rosterListView::showChatDialog_helper() -{ - QString bareJid = selectedBareJid(); - if(!bareJid.isEmpty()) - emit showChatDialog(bareJid); -} - -void rosterListView::showProfile_helper() -{ - QString bareJid = selectedBareJid(); - if(!bareJid.isEmpty()) - emit showProfile(bareJid); -} - -void rosterListView::keyPressEvent(QKeyEvent* event1) -{ - if(event1->key() == Qt::Key_Return) - { - showChatDialog_helper(); - } - QListView::keyPressEvent(event1); -} - -void rosterListView::removeContact_helper() -{ - QString bareJid = selectedBareJid(); - if(!bareJid.isEmpty()) - emit removeContact(bareJid); -} diff --git a/examples/GuiClient/rosterListView.h b/examples/GuiClient/rosterListView.h deleted file mode 100644 index 49d1ba04..00000000 --- a/examples/GuiClient/rosterListView.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef ROSTERLISTVIEW_H -#define ROSTERLISTVIEW_H - -#include <QListView> -#include <QAction> - -class rosterListView : public QListView -{ - Q_OBJECT - -public: - rosterListView(QWidget* parent = 0); - bool event(QEvent* e); - -public slots: - void mousePressed(const QModelIndex& index); - void doubleClicked(const QModelIndex& index); - void clicked(const QModelIndex& index); - -private slots: - void showChatDialog_helper(); - void showProfile_helper(); - void removeContact_helper(); - -protected: - void keyPressEvent(QKeyEvent*); - -signals: - void showChatDialog(const QString& bareJid); - void showProfile(const QString& bareJid); - void removeContact(const QString& bareJid); - -private: - QString selectedBareJid(); - -private: - QAction m_chat; - QAction m_profile; - QAction m_removeContact; -}; - -#endif // ROSTERLISTVIEW_H diff --git a/examples/GuiClient/searchLineEdit.cpp b/examples/GuiClient/searchLineEdit.cpp deleted file mode 100644 index b1b97d3d..00000000 --- a/examples/GuiClient/searchLineEdit.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "searchLineEdit.h" - -searchLineEdit::searchLineEdit(QWidget* parent):QLineEdit(parent) -{ - setMinimumSize(QSize(20, 24)); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - - setStyleSheet(":enabled { padding-right: 20px; padding-left: 20px }"); - clearButton = new searchClearButton(this); - clearButton->setVisible(true); - - clearButton->setCursor(Qt::ArrowCursor); - clearButton->setToolTip("Clear"); - connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); -} - -void searchLineEdit::paintEvent(QPaintEvent *e) { - QLineEdit::paintEvent(e); - QPainter painter(this); - - QImage image(":/icons/resource/searchIcon.png"); - - QRectF target(image.rect()); - target.moveCenter(QPointF(target.center().x()+2, target.center().y()+3)); - painter.drawImage(target, image, image.rect()); - - if (text().length() == 0 && (!hasFocus()) ) - { - painter.setPen(Qt::gray); - QRect r = rect(); - painter.drawText(24, r.height()/2+4, "Search Contacts"); - } - - if(text().isEmpty()) - clearButton->setVisible(false); - else - clearButton->setVisible(true); -} - -void searchLineEdit::resizeEvent(QResizeEvent*) -{ - clearButton->setParent(this); - clearButton->setGeometry(QRect(width()-23, - 0, - 24, 24)); -} - -void searchLineEdit::moveEvent(QMoveEvent*) -{ - clearButton->setParent(this); - clearButton->setGeometry(QRect(width()-23, 1, - 24, 24)); -} diff --git a/examples/GuiClient/searchLineEdit.h b/examples/GuiClient/searchLineEdit.h deleted file mode 100644 index b70e8b66..00000000 --- a/examples/GuiClient/searchLineEdit.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef SEARCHLINEEDIT_H -#define SEARCHLINEEDIT_H - -#include <QPushButton> -#include <QLineEdit> -#include <QPainter> - -class searchClearButton : public QPushButton -{ - Q_OBJECT - -public: - searchClearButton(QWidget *w) - : QPushButton(w) - { - setMinimumSize(24, 24); - setFixedSize(24, 24); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - } - void paintEvent(QPaintEvent *event) - { - Q_UNUSED(event); - QPainter painter(this); - int height = parentWidget()->geometry().height(); - int width = height; //parentWidget()->geometry().width(); - - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(Qt::white); - - float penwidth = isDown() ? 1.2 : - underMouse() ? 1.6 : 1.2; - painter.setBrush(Qt::red); - //painter.drawEllipse(4, 4, width - 8, height - 8); - QPen pen; - pen.setWidthF(penwidth); - pen.setColor(Qt::black); - painter.setPen(pen); - int border = 7; - painter.drawLine(border, border, width - border, height - border); - painter.drawLine(border, height - border, width - border, border); - } -}; - -class searchLineEdit : public QLineEdit -{ -public: - searchLineEdit(QWidget* parent = 0); - -protected: - virtual void paintEvent(QPaintEvent* e); - virtual void resizeEvent(QResizeEvent*); - virtual void moveEvent(QMoveEvent*); - -private: - QPushButton *clearButton; -}; - -#endif // SEARCHLINEEDIT_H diff --git a/examples/GuiClient/signInStatusLabel.cpp b/examples/GuiClient/signInStatusLabel.cpp deleted file mode 100644 index 91ea023b..00000000 --- a/examples/GuiClient/signInStatusLabel.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "signInStatusLabel.h" -#include <QFontMetrics> - -signInStatusLabel::signInStatusLabel(QWidget* parent):QLabel(parent), m_timer(this), - m_option(None) -{ - m_timer.setSingleShot(false); - - bool check = connect(&m_timer, SIGNAL(timeout()), SLOT(timeout())); - Q_ASSERT(check); - Q_UNUSED(check); -} - -void signInStatusLabel::setCustomText(const QString& text, signInStatusLabel::Option op, - int countDown) -{ - m_text = text; - m_option = op; - m_countDown = countDown; - switch(op) - { - case None: - m_timer.stop(); - m_postfix = ""; - break; - case WithProgressEllipsis: -// m_timer.start(400); - m_postfix = ""; - break; - case CountDown: - m_timer.start(1000); - m_postfix = ""; - break; - default: - m_timer.stop(); - m_postfix = ""; - break; - } - - if(m_option == CountDown) - setText(m_text.arg(m_countDown) + m_postfix); - else - setText(m_text + m_postfix); - - updateGeometry(); -} - -void signInStatusLabel::timeout() -{ - switch(m_option) - { - case None: - break; - case WithProgressEllipsis: - if(m_postfix == "") - m_postfix = "."; - else if(m_postfix == ".") - m_postfix = ".."; - else if(m_postfix == "..") - m_postfix = "..."; - else if(m_postfix == "...") - m_postfix = ""; - break; - case CountDown: - if(m_countDown == 0) - m_timer.stop(); - --m_countDown; - break; - default: - break; - } - - if(m_option == CountDown) - setText(m_text.arg(m_countDown) + m_postfix); - else - setText(m_text + m_postfix); - updateGeometry(); -} - -//QSize signInStatusLabel::sizeHint() const -//{ -// QFont font; -// QFontMetrics fm(font); -// return QSize(fm.width(m_text) + 15, 20); -//} diff --git a/examples/GuiClient/signInStatusLabel.h b/examples/GuiClient/signInStatusLabel.h deleted file mode 100644 index e11d1287..00000000 --- a/examples/GuiClient/signInStatusLabel.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef SIGNINSTATUSLABEL_H -#define SIGNINSTATUSLABEL_H - -#include <QLabel> -#include <QTimer> - -class signInStatusLabel : public QLabel -{ - Q_OBJECT - -public: - enum Option - { - None = 0, - WithProgressEllipsis, - CountDown - }; - signInStatusLabel(QWidget* parent = 0); - - void setCustomText(const QString& text, signInStatusLabel::Option op = None, - int countDown = 0); - -// QSize sizeHint() const; - -private slots: - void timeout(); - -private: - QTimer m_timer; - signInStatusLabel::Option m_option; - QString m_text; - QString m_postfix; - int m_countDown; -}; - -#endif // SIGNINSTATUSLABEL_H diff --git a/examples/GuiClient/statusAvatarWidget.cpp b/examples/GuiClient/statusAvatarWidget.cpp deleted file mode 100644 index d0d9968c..00000000 --- a/examples/GuiClient/statusAvatarWidget.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "statusAvatarWidget.h" -#include <QtGui/QPainter> - -statusAvatarWidget::statusAvatarWidget(QWidget* parent) - : QPushButton(parent) -{ -} - -void statusAvatarWidget::paintEvent(QPaintEvent* event) -{ - Q_UNUSED(event); - QPainter painter(this); - - QRect r = rect(); - - QPixmap pixmap = icon().pixmap(sizeHint(), QIcon::Normal, QIcon::On); - if(pixmap.isNull()) - pixmap = QPixmap(":/icons/resource/avatar.png"); - QRect pixRect(0, 0, 32, 32); - pixRect.moveCenter(r.center()); - painter.drawPixmap(pixRect, pixmap); - - if(underMouse() && !isDown()) - { - painter.drawRect(pixRect.adjusted(0, 0, -1, -1)); - QColor col(Qt::white); - col.setAlpha(80); - painter.fillRect(pixRect.adjusted(0, 0, -1, -1), col); - } - if(isDown()) - { - QColor col(Qt::white); - col.setAlpha(50); - painter.drawRect(pixRect.adjusted(1, 1, -2, -2)); - } -} - -QSize statusAvatarWidget::sizeHint() const -{ - return QSize(32, 32); -} diff --git a/examples/GuiClient/statusAvatarWidget.h b/examples/GuiClient/statusAvatarWidget.h deleted file mode 100644 index 5dcecdbe..00000000 --- a/examples/GuiClient/statusAvatarWidget.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef STATUSAVATARWIDGET_H -#define STATUSAVATARWIDGET_H - -#include <QPushButton> - -class statusAvatarWidget : public QPushButton -{ -public: - statusAvatarWidget(QWidget* parent = 0); - void paintEvent(QPaintEvent* event); - QSize sizeHint() const; -}; - -#endif // STATUSAVATARWIDGET_H diff --git a/examples/GuiClient/statusTextWidget.cpp b/examples/GuiClient/statusTextWidget.cpp deleted file mode 100644 index fa0a9126..00000000 --- a/examples/GuiClient/statusTextWidget.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "statusTextWidget.h" -#include <QHBoxLayout> -#include <QMenu> - -#include <QStyle> -#include <QStyleOptionFrameV2> - -QSize statusLineEdit::sizeHint() const -{ - QFont font; - QFontMetrics fm(font); - int width = fm.width(text()); - if(width <= (160 - 8)) - return QSize(width+8, 18); - else - return QSize(160, 18); -} - -void statusLineEditButton::paintEvent(QPaintEvent* event) -{ - Q_UNUSED(event); - QPainter painter(this); - - QStyleOptionButton panel; - initStyleOption(&panel); - QRect r = style()->subElementRect(QStyle::SE_PushButtonFocusRect, &panel, this); - - QImage image(":/icons/resource/downArrow.png"); - QRect rectDelta(0, 0, 7, 4); - rectDelta.moveCenter(r.center()); - painter.drawImage(rectDelta, image); -} - -void statusLineEdit::focusInEvent(QFocusEvent* event) -{ - QLineEdit::focusInEvent(event); - QLineEdit::selectAll(); -} - -void statusLineEdit::mousePressEvent(QMouseEvent* event) -{ - QLineEdit::mousePressEvent(event); - QLineEdit::selectAll(); -} - -statusTextWidget::statusTextWidget(QWidget* parent) - : QWidget(parent) - , m_statusLineEdit(0) - , m_statusButton(0) - , m_clearStatusTextHistory("Clear Status Message", this) -{ - bool check; - Q_UNUSED(check); - - m_statusLineEdit = new statusLineEdit(this); - QHBoxLayout* layout = new QHBoxLayout; - layout->addWidget(m_statusLineEdit); - layout->setSpacing(0); - layout->setContentsMargins(0, 0, 0, 0); - m_statusButton = new statusLineEditButton(this); - layout->addWidget(m_statusButton); - setLayout(layout); - - check = connect(m_statusButton, SIGNAL(clicked(bool)), SLOT(showMenu())); - Q_ASSERT(check); - - check = connect(m_statusLineEdit, SIGNAL(textChanged(QString)), SLOT(textChanged())); - Q_ASSERT(check); - - check = connect(m_statusLineEdit, SIGNAL(editingFinished()), SLOT(statusTextChanged_helper())); - Q_ASSERT(check); - - check = connect(&m_clearStatusTextHistory, SIGNAL(triggered()), SLOT(clearStatusTextHistory())); - Q_ASSERT(check); -} - -void statusTextWidget::showMenu() -{ - QMenu menu(this); - - int size = m_statusTextActionList.size(); - for(int i = 0; i < size; ++i) - { - menu.addAction(m_statusTextActionList.at(size - 1 - i)); - } - - menu.addSeparator(); - menu.addAction(&m_clearStatusTextHistory); - m_clearStatusTextHistory.setDisabled(size == 0); - menu.exec(m_statusLineEdit->mapToGlobal(QPoint(0, m_statusLineEdit->height()))); -} - -void statusTextWidget::textChanged() -{ - m_statusLineEdit->updateGeometry(); -} - -void statusTextWidget::statusTextChanged_helper() -{ - addStatusTextToList(m_statusLineEdit->text()); - emit statusTextChanged(m_statusLineEdit->text()); - parentWidget()->setFocus(); -} - -void statusTextWidget::setStatusText(const QString& statusText) -{ - m_statusLineEdit->setText(statusText); -} - -void statusTextWidget::addStatusTextToList(const QString& status) -{ - for(int i = 0; i < m_statusTextActionList.size(); ++i) - { - if(m_statusTextActionList.at(i)->data().toString() == status) - { - QAction* action = m_statusTextActionList.takeAt(i); - m_statusTextActionList.append(action); - return; - } - } - - QAction* action = new QAction(status, this); - action->setData(status); - bool check = connect(action, SIGNAL(triggered()), SLOT(statusTextChanged_menuClick())); - Q_ASSERT(check); - Q_UNUSED(check); - m_statusTextActionList.append(action); -} - -void statusTextWidget::statusTextChanged_menuClick() -{ - QAction* action = qobject_cast<QAction*>(sender()); - if(action) - { - int i = 0; - while(i < m_statusTextActionList.size() && action != m_statusTextActionList.at(i)) - { - ++i; - } - - if(action == m_statusTextActionList.at(i)) - { - m_statusTextActionList.removeAt(i); - m_statusTextActionList.append(action); - } - m_statusLineEdit->setText(action->data().toString()); - emit statusTextChanged(action->data().toString()); - } -} - -void statusTextWidget::clearStatusTextHistory() -{ - emit statusTextChanged(""); -} diff --git a/examples/GuiClient/statusTextWidget.h b/examples/GuiClient/statusTextWidget.h deleted file mode 100644 index ca280672..00000000 --- a/examples/GuiClient/statusTextWidget.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef STATUSTEXTWIDGET_H -#define STATUSTEXTWIDGET_H - -#include <QWidget> -#include <QAction> -#include <QLineEdit> -#include <QPainter> -#include <QPushButton> -#include <QStyleOptionFrameV2> -#include <QFontMetrics> - - -class statusLineEditButton : public QPushButton -{ - Q_OBJECT - -public: - statusLineEditButton(QWidget* parent = 0): QPushButton(parent) - { - setCursor(Qt::PointingHandCursor); - } - void paintEvent(QPaintEvent* event); - QSize sizeHint() const - { - return QSize(14, 14); - } -}; - -class statusLineEdit : public QLineEdit -{ -public: - statusLineEdit(QWidget* parent = 0) : QLineEdit(parent) - { - setAttribute(Qt::WA_Hover, true); - setText("Available"); - setMinimumSize(QSize(20, 18)); - } - void focusInEvent(QFocusEvent* event); - void mousePressEvent(QMouseEvent* event); - - void paintEvent(QPaintEvent* event) - { - if(hasFocus()) - { - QLineEdit::paintEvent(event); - } - else - { - QPainter p(this); - QRect r = rect(); - QPalette pal = palette(); - - QStyleOptionFrameV2 panel; - initStyleOption(&panel); - r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); - r.adjust(-1, -1, 0, 0); - r.setLeft(r.left() + 4); - p.setPen(Qt::darkGray); - p.drawText(r, Qt::AlignVCenter, text()); - } - - if(underMouse() && !hasFocus()) - { - QPainter p(this); - QRect r = rect(); - QPalette pal = palette(); - - QStyleOptionFrameV2 panel; - initStyleOption(&panel); - r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); - r.adjust(-1, -1, 0, 0); - p.setPen(Qt::gray); - p.drawRect(r); - r.setLeft(r.left() + 4); - p.setPen(Qt::darkGray); - p.drawText(r, Qt::AlignVCenter, text()); - } - } - QSize sizeHint() const; -}; - -class statusTextWidget : public QWidget -{ - Q_OBJECT - -public: - statusTextWidget(QWidget* parent = 0); - void setStatusText(const QString& statusText); - -public slots: - void showMenu(); - void textChanged(); - -private slots: - void statusTextChanged_helper(); - void statusTextChanged_menuClick(); - void clearStatusTextHistory(); - -signals: - void statusTextChanged(const QString&); - -private: - void addStatusTextToList(const QString& status); - statusLineEdit* m_statusLineEdit; - statusLineEditButton* m_statusButton; - - QList<QAction*> m_statusTextActionList; - QAction m_clearStatusTextHistory; -}; - -#endif // STATUSTEXTWIDGET_H diff --git a/examples/GuiClient/statusToolButton.cpp b/examples/GuiClient/statusToolButton.cpp deleted file mode 100644 index c14bc324..00000000 --- a/examples/GuiClient/statusToolButton.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "statusToolButton.h" -#include <QPainter> -#include <QStyle> -#include <QStyleOptionToolButton> - -statusToolButton::statusToolButton(QWidget* parent) : QToolButton(parent) -{ - setMinimumSize(QSize(20, 18)); -} - -void statusToolButton::paintEvent(QPaintEvent* event) -{ - Q_UNUSED(event); - QPainter painter(this); - if(underMouse()) - { - QStyleOptionToolButton panel; - initStyleOption(&panel); - style()->drawPrimitive(QStyle::PE_PanelButtonTool, &panel, &painter, this); - } - QRect r = rect(); - QFont font; - painter.setFont(font); - painter.setPen(Qt::gray); - - QRect rectSize(0, 0, sizeHint().width(), sizeHint().height()); - rectSize.moveCenter(r.center()); - r = rectSize; - r.adjust(0, 0, -1, -1); - painter.setPen(Qt::black); - painter.setBrush(Qt::black); - r.moveLeft(r.left() + 3); - font.setBold(true); - painter.setFont(font); - painter.drawText(r, Qt::AlignVCenter|Qt::TextSingleLine, text()); - - QImage image(":/icons/resource/downArrow.png"); - QRect rectDelta(0, 0, 7, 4); - rectDelta.moveRight(r.right() - 4); - rectDelta.moveCenter(QPoint(rectDelta.center().x(), r.center().y())); - painter.drawImage(rectDelta, image); -} - -QSize statusToolButton::sizeHint() const -{ - QFont font; - font.setBold(true); - QFontMetrics fm(font); - int width = fm.width(text()); - if(width <= (160 - 8 - 9)) - return QSize(width+8+9, 18); - else - return QSize(160, 18); -} diff --git a/examples/GuiClient/statusToolButton.h b/examples/GuiClient/statusToolButton.h deleted file mode 100644 index 9bc1a03f..00000000 --- a/examples/GuiClient/statusToolButton.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef STATUSTOOLBUTTON_H -#define STATUSTOOLBUTTON_H - -#include <QToolButton> - -class statusToolButton : public QToolButton -{ -public: - statusToolButton(QWidget* parent = 0); - void paintEvent(QPaintEvent* event); - QSize sizeHint() const; -}; - -#endif // STATUSTOOLBUTTON_H diff --git a/examples/GuiClient/statusWidget.cpp b/examples/GuiClient/statusWidget.cpp deleted file mode 100644 index c18e78e4..00000000 --- a/examples/GuiClient/statusWidget.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "statusWidget.h" - -#include <QMenu> -#include <QFileDialog> -#include <QMessageBox> - -statusWidget::statusWidget(QWidget* parent) - : QWidget(parent) -{ - bool check; - Q_UNUSED(check); - - setupUi(this); - - QMenu* menu = new QMenu(this); - menu->addAction(actionAvailable); - menu->addAction(actionBusy); - menu->addAction(actionAway); -// menu->addAction(actionInvisible); - menu->addSeparator(); - menu->addAction(actionSign_out); - toolButton_userName->setMenu(menu); - - check = connect(statusTextWidgetObject, SIGNAL(statusTextChanged(QString)), SIGNAL(statusTextChanged(QString))); - Q_ASSERT(check); - - check = connect(actionAvailable, SIGNAL(triggered()), SLOT(presenceMenuTriggered())); - Q_ASSERT(check); - - check = connect(actionBusy, SIGNAL(triggered()), SLOT(presenceMenuTriggered())); - Q_ASSERT(check); - - check = connect(actionAway, SIGNAL(triggered()), SLOT(presenceMenuTriggered())); - Q_ASSERT(check); - -// check = connect(actionInvisible, SIGNAL(triggered()), SLOT(presenceMenuTriggered())); -// Q_ASSERT(check); - - check = connect(actionSign_out, SIGNAL(triggered()), SLOT(presenceMenuTriggered())); - Q_ASSERT(check); - - check = connect(pushButton_avatar, SIGNAL(clicked()), SLOT(avatarSelection())); - Q_ASSERT(check); -} - -void statusWidget::setStatusText(const QString& statusText) -{ - statusTextWidgetObject->setStatusText(statusText); -} - -void statusWidget::presenceMenuTriggered() -{ - QString icon = "green"; - QAction* action = qobject_cast<QAction*>(sender()); - if(action == actionAvailable) - { - emit presenceTypeChanged(QXmppPresence::Available); - icon = "green"; - } - else if(action == actionBusy) - { - emit presenceStatusTypeChanged(QXmppPresence::DND); - icon = "red"; - } - else if(action == actionAway) - { - emit presenceStatusTypeChanged(QXmppPresence::Away); - icon = "orange"; - } -#if 0 - else if(action == actionInvisible) - { - emit presenceStatusTypeChanged(QXmppPresence::Invisible); - icon = "gray"; - } -#endif - else if(action == actionSign_out) - { - emit presenceTypeChanged(QXmppPresence::Unavailable); - icon = "gray"; - } - label->setPixmap(QPixmap(":/icons/resource/"+icon+".png")); -} - -void statusWidget::setPresenceAndStatusType(QXmppPresence::Type presenceType, - QXmppPresence::AvailableStatusType statusType) -{ - if(presenceType == QXmppPresence::Available) - { - QString icon = "green"; - switch(statusType) - { - case QXmppPresence::Online: - case QXmppPresence::Chat: - icon = "green"; - break; - case QXmppPresence::Away: - case QXmppPresence::XA: - icon = "orange"; - break; - case QXmppPresence::DND: - icon = "red"; - break; - case QXmppPresence::Invisible: - icon = "gray"; - break; - } - label->setPixmap(QPixmap(":/icons/resource/"+icon+".png")); - } - else if(presenceType == QXmppPresence::Unavailable) - { - label->setPixmap(QPixmap(":/icons/resource/gray.png")); - } -} - -void statusWidget::avatarSelection() -{ - QString fileFilters = QString("Images (*.png *.jpeg *.jpg *.gif *.bmp);;All Files (*.*)"); - QString file = QFileDialog::getOpenFileName(this, "Select your avatar", - QString(), fileFilters); - if(file.isEmpty()) - return; - - QImage image; - if(image.load(file)) - { - QImage scaled = image.scaled(QSize(96, 96), Qt::KeepAspectRatio, - Qt::SmoothTransformation); - emit avatarChanged(scaled); - } - else - QMessageBox::information(this, "Avatar selection", "Invalid image file"); -} - -void statusWidget::setDisplayName(const QString& name) -{ - toolButton_userName->setText(name); -} - -void statusWidget::setAvatar(const QImage& image) -{ - pushButton_avatar->setIcon(QIcon(QPixmap::fromImage(image))); -} diff --git a/examples/GuiClient/statusWidget.h b/examples/GuiClient/statusWidget.h deleted file mode 100644 index f8e1f5f7..00000000 --- a/examples/GuiClient/statusWidget.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef STATUSWIDGET_H -#define STATUSWIDGET_H - -#include "ui_statusWidget.h" - -#include "QXmppPresence.h" - -/// Main Widget for the client's status/status text/avatar management - -class statusWidget : public QWidget, public Ui::statusWidgetClass -{ - Q_OBJECT - -public: - statusWidget(QWidget* parent = 0); - - void setDisplayName(const QString& name); - void setStatusText(const QString& statusText); - void setPresenceAndStatusType(QXmppPresence::Type presenceType, - QXmppPresence::AvailableStatusType statusType); - void setAvatar(const QImage&); - -private slots: - void presenceMenuTriggered(); - void avatarSelection(); - -signals: - void statusTextChanged(const QString&); - void presenceTypeChanged(QXmppPresence::Type); - void presenceStatusTypeChanged(QXmppPresence::AvailableStatusType); - void avatarChanged(const QImage&); -}; - -#endif // STATUSWIDGET_H diff --git a/examples/GuiClient/statusWidget.ui b/examples/GuiClient/statusWidget.ui deleted file mode 100644 index abd9ce35..00000000 --- a/examples/GuiClient/statusWidget.ui +++ /dev/null @@ -1,213 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>statusWidgetClass</class> - <widget class="QWidget" name="statusWidgetClass"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>251</width> - <height>40</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>4</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>4</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="resources.qrc">:/icons/resource/green.png</pixmap> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>3</number> - </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="statusToolButton" name="toolButton_userName"> - <property name="text"> - <string>toolbutton</string> - </property> - <property name="popupMode"> - <enum>QToolButton::InstantPopup</enum> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - <property name="arrowType"> - <enum>Qt::DownArrow</enum> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>10</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="statusTextWidget" name="statusTextWidgetObject" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>10</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="statusAvatarWidget" name="pushButton_avatar"> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/avatar.png</normaloff>:/icons/resource/avatar.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - </widget> - </item> - </layout> - <action name="actionBusy"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/red.png</normaloff>:/icons/resource/red.png</iconset> - </property> - <property name="text"> - <string>Busy</string> - </property> - </action> - <action name="actionAvailable"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/green.png</normaloff>:/icons/resource/green.png</iconset> - </property> - <property name="text"> - <string>Available</string> - </property> - </action> - <action name="actionInvisible"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/gray.png</normaloff>:/icons/resource/gray.png</iconset> - </property> - <property name="text"> - <string>Invisible</string> - </property> - </action> - <action name="actionSign_out"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/gray.png</normaloff>:/icons/resource/gray.png</iconset> - </property> - <property name="text"> - <string>Sign out</string> - </property> - </action> - <action name="actionAway"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/orange.png</normaloff>:/icons/resource/orange.png</iconset> - </property> - <property name="text"> - <string>Away</string> - </property> - </action> - </widget> - <customwidgets> - <customwidget> - <class>statusAvatarWidget</class> - <extends>QPushButton</extends> - <header>statusAvatarWidget.h</header> - </customwidget> - <customwidget> - <class>statusTextWidget</class> - <extends>QWidget</extends> - <header>statusTextWidget.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>statusToolButton</class> - <extends>QToolButton</extends> - <header>statusToolButton.h</header> - </customwidget> - </customwidgets> - <resources> - <include location="resources.qrc"/> - </resources> - <connections/> -</ui> diff --git a/examples/GuiClient/utils.cpp b/examples/GuiClient/utils.cpp deleted file mode 100644 index 9006fbbf..00000000 --- a/examples/GuiClient/utils.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "utils.h" -#include <QDir> -#if QT_VERSION >= 0x050000 -#include <QStandardPaths> -#else -#include <QDesktopServices> -#endif - -int comparisonWeightsPresenceStatusType(QXmppPresence::AvailableStatusType statusType) -{ - switch(statusType) - { - case QXmppPresence::Online: - case QXmppPresence::Chat: - return 0; - case QXmppPresence::DND: - return 1; - case QXmppPresence::Away: - case QXmppPresence::XA: - return 2; - case QXmppPresence::Invisible: - return 3; - default: - return 5; - } -} - -int comparisonWeightsPresenceType(QXmppPresence::Type type) -{ - switch(type) - { - case QXmppPresence::Available: - return 0; - case QXmppPresence::Unavailable: - return 1; - case QXmppPresence::Error: - case QXmppPresence::Subscribe: - case QXmppPresence::Subscribed: - case QXmppPresence::Unsubscribe: - case QXmppPresence::Unsubscribed: - case QXmppPresence::Probe: - return 3; - default: - return 5; - } -} - -QString presenceToStatusText(const QXmppPresence& presence) -{ - QString statusText = presence.statusText(); - if(statusText.isEmpty()) - { - if(presence.type() == QXmppPresence::Available) - { - switch(presence.availableStatusType()) - { - case QXmppPresence::Invisible: - statusText = "Offline"; - break; - case QXmppPresence::Online: - case QXmppPresence::Chat: - statusText = "Available"; - break; - case QXmppPresence::Away: - case QXmppPresence::XA: - statusText = "Idle"; - break; - case QXmppPresence::DND: - statusText = "Busy"; - break; - } - } - else - statusText = "Offline"; - } - - return statusText; -} - -QString getSettingsDir(const QString& bareJid) -{ -#if QT_VERSION >= 0x050000 - QStringList dirList = QStandardPaths::standardLocations(QStandardPaths::DataLocation); - QString dir = dirList.size() > 0 ? dirList.at(0) : ""; -#else - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); -#endif - if(bareJid.isEmpty()) - return dir + "/"; - else - return QString(dir + "/%1/").arg(bareJid); -} - -QString getSha1HashAsHex(const QByteArray& image) -{ - if(image.isEmpty()) - return ""; - else - return QString(QCryptographicHash::hash(image, - QCryptographicHash::Sha1).toHex()); -} - -QImage getImageFromByteArray(const QByteArray& image) -{ - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QImageReader imageReader(&buffer); - return imageReader.read(); -} - -QString getImageType1(const QByteArray& image) -{ - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QString format = QImageReader::imageFormat(&buffer); - - if(format.toUpper() == "PNG") - return "image/png"; - else if(format.toUpper() == "MNG") - return "video/x-mng"; - else if(format.toUpper() == "GIF") - return "image/gif"; - else if(format.toUpper() == "BMP") - return "image/bmp"; - else if(format.toUpper() == "XPM") - return "image/x-xpm"; - else if(format.toUpper() == "SVG") - return "image/svg+xml"; - else if(format.toUpper() == "JPEG") - return "image/jpeg"; - - return "image/unknown"; -} - -bool isValidBareJid(const QString& bareJid) -{ - QRegExp re("^[^@]+@[^@]+$"); - return re.exactMatch(bareJid); -} - -QByteArray calculateXor(const QByteArray& data, const QByteArray& key) -{ - if(key.isEmpty()) - return data; - - QByteArray result; - for(int i = 0 , j = 0; i < data.length(); ++i , ++j) - { - if(j == key.length()) - j = 0; - result.append(data.at(i) ^ key.at(j)); - } - return result; -} diff --git a/examples/GuiClient/utils.h b/examples/GuiClient/utils.h deleted file mode 100644 index a7f0df90..00000000 --- a/examples/GuiClient/utils.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef CLIENTUTILS_H -#define CLIENTUTILS_H - -#include "QXmppPresence.h" - -#include <QCryptographicHash> -#include <QBuffer> -#include <QImageReader> - -int comparisonWeightsPresenceStatusType(QXmppPresence::AvailableStatusType); -int comparisonWeightsPresenceType(QXmppPresence::Type); - -QString presenceToStatusText(const QXmppPresence& presence); - -QString getSettingsDir(const QString& bareJid = ""); - -QString getSha1HashAsHex(const QByteArray& image); -QImage getImageFromByteArray(const QByteArray& image); -QString getImageType1(const QByteArray& image); - -bool isValidBareJid(const QString& bareJid); - -QByteArray calculateXor(const QByteArray& data, const QByteArray& key); - -#endif // CLIENTUTILS_H diff --git a/examples/GuiClient/vCardCache.cpp b/examples/GuiClient/vCardCache.cpp deleted file mode 100644 index ede247c0..00000000 --- a/examples/GuiClient/vCardCache.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "vCardCache.h" -#include "utils.h" - -#include "QXmppClient.h" -#include "QXmppUtils.h" -#include "QXmppVCardManager.h" - -#include <QDir> -#include <QDomDocument> -#include <QCoreApplication> - -vCardCache::vCardCache(QXmppClient* client) : QObject(client), - m_client(client) -{ -} - -void vCardCache::vCardReceived(const QXmppVCardIq& vcard) -{ - QString from = vcard.from(); - - if(from.isEmpty() && m_client) - from = m_client->configuration().jidBare(); - - m_mapBareJidVcard[from] = vcard; - - saveToFile(from); - - emit vCardReadyToUse(from); -} - -bool vCardCache::isVCardAvailable(const QString& bareJid) const -{ - return m_mapBareJidVcard.contains(bareJid); -} - -// TODO don't request again, if it is already requested -void vCardCache::requestVCard(const QString& bareJid) -{ - if(m_client) - m_client->vCardManager().requestVCard(bareJid); -} - -//TODO not a good way to handle -QXmppVCardIq& vCardCache::getVCard(const QString& bareJid) -{ - return m_mapBareJidVcard[bareJid]; -} - -void vCardCache::saveToFile(const QString& bareJid) -{ - QDir dir; - if(!dir.exists(getSettingsDir(m_client->configuration().jidBare()))) - dir.mkpath(getSettingsDir(m_client->configuration().jidBare())); - - QDir dir2; - if(!dir2.exists(getSettingsDir(m_client->configuration().jidBare())+ "vCards/")) - dir2.mkpath(getSettingsDir(m_client->configuration().jidBare())+ "vCards/"); - - if(m_mapBareJidVcard.contains(bareJid)) - { - QString fileVCard = getSettingsDir(m_client->configuration().jidBare()) + "vCards/" + bareJid + ".xml"; - QFile file(fileVCard); - - if(file.open(QIODevice::ReadWrite)) - { - QXmlStreamWriter stream(&file); - stream.setAutoFormatting(true); - stream.setAutoFormattingIndent(2); - m_mapBareJidVcard[bareJid].toXml(&stream); - file.close(); - } - } -} - -void vCardCache::loadFromFile() -{ - m_mapBareJidVcard.clear(); - - QDir dirVCards(getSettingsDir(m_client->configuration().jidBare())+ "vCards/"); - if(dirVCards.exists()) - { - QStringList list = dirVCards.entryList(QStringList("*.xml")); - foreach(QString fileName, list) - { - QFile file(getSettingsDir(m_client->configuration().jidBare())+ "vCards/" + fileName); - QString bareJid = fileName; - bareJid.chop(4); - if(file.open(QIODevice::ReadOnly)) - { - QDomDocument doc; - if(doc.setContent(&file, true)) - { - QXmppVCardIq vCardIq; - vCardIq.parse(doc.documentElement()); - m_mapBareJidVcard[bareJid] = vCardIq; - QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - } - } - } - } -} - -//TODO: this should return scaled image -QImage vCardCache::getAvatar(const QString& bareJid) const -{ - if(m_mapBareJidVcard.contains(bareJid)) - return getImageFromByteArray(m_mapBareJidVcard[bareJid].photo()); - else - return QImage(); -} - -QByteArray vCardCache::getPhotoHash(const QString& bareJid) const -{ - if(!m_mapBareJidVcard.contains(bareJid)) - return QByteArray(); - - if(m_mapBareJidVcard[bareJid].photo().isEmpty()) - return QByteArray(); - else - return QCryptographicHash::hash(m_mapBareJidVcard[bareJid].photo(), - QCryptographicHash::Sha1); -} diff --git a/examples/GuiClient/vCardCache.h b/examples/GuiClient/vCardCache.h deleted file mode 100644 index 0f5c6dd2..00000000 --- a/examples/GuiClient/vCardCache.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef VCARDCACHE_H -#define VCARDCACHE_H - -#include <QObject> -#include <QMap> -#include "QXmppVCardIq.h" - -class QImage; -class QXmppClient; - -class vCardCache : public QObject -{ - Q_OBJECT - -public: - vCardCache(QXmppClient* client); - - bool isVCardAvailable(const QString& bareJid) const; - void requestVCard(const QString& bareJid); - QXmppVCardIq& getVCard(const QString& bareJid); - QImage getAvatar(const QString& bareJid) const; - - void loadFromFile(); - - QByteArray getPhotoHash(const QString& bareJid) const; - -signals: - void vCardReadyToUse(const QString& bareJid); - -public slots: - void vCardReceived(const QXmppVCardIq&); - -private: - void saveToFile(const QString& bareJid); - - QXmppClient* m_client; - QMap<QString, QXmppVCardIq> m_mapBareJidVcard; -}; - -#endif // VCARDCACHE_H diff --git a/examples/GuiClient/xmlConsoleDialog.cpp b/examples/GuiClient/xmlConsoleDialog.cpp deleted file mode 100644 index da52a1db..00000000 --- a/examples/GuiClient/xmlConsoleDialog.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#include "xmlConsoleDialog.h" -#include "ui_xmlConsoleDialog.h" - -#include <QDomDocument> -#include <QTextStream> - -static QString s_colorHexSent("#02aa3f"); -static QString s_colorHexReceived("#aa0000"); - -xmlConsoleDialog::xmlConsoleDialog(QWidget *parent) : - QDialog(parent, Qt::Window), - ui(new Ui::xmlConsoleDialog) -{ - ui->setupUi(this); - setWindowTitle("Debugging Console"); - - ui->label_legend->setText( - QString("<html><body><p><span style=\"color:%1\">Sent</span><span> | </span><span style=\"color:%2\">Received</span></p></body></html>").arg(s_colorHexSent).arg(s_colorHexReceived)); -} - -xmlConsoleDialog::~xmlConsoleDialog() -{ - delete ui; -} - -void xmlConsoleDialog::message(QXmppLogger::MessageType type, const QString& text) -{ - if(!ui->checkBox_enable->isChecked()) - return; - - QColor color; - switch(type) - { - case QXmppLogger::ReceivedMessage: - color = QColor(s_colorHexReceived); - break; - case QXmppLogger::SentMessage: - color = QColor(s_colorHexSent); - break; - default: - return; - } - - QDomDocument doc; - -// Indent XML string - bool isXml = doc.setContent(text); - QString formattedText; - QTextStream stream(&formattedText); - doc.save(stream, 2); - - ui->textBrowser->setTextColor(color); - if(isXml) - ui->textBrowser->append(formattedText); - else - ui->textBrowser->append(text); -} diff --git a/examples/GuiClient/xmlConsoleDialog.h b/examples/GuiClient/xmlConsoleDialog.h deleted file mode 100644 index 5bc974ed..00000000 --- a/examples/GuiClient/xmlConsoleDialog.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef XMLCONSOLEDIALOG_H -#define XMLCONSOLEDIALOG_H - -#include <QDialog> -#include "QXmppLogger.h" - -namespace Ui { - class xmlConsoleDialog; -} - -class xmlConsoleDialog : public QDialog -{ - Q_OBJECT - -public: - explicit xmlConsoleDialog(QWidget *parent = 0); - ~xmlConsoleDialog(); - -public slots: - void message(QXmppLogger::MessageType, const QString &); - -private: - Ui::xmlConsoleDialog *ui; -}; - -#endif // XMLCONSOLEDIALOG_H diff --git a/examples/GuiClient/xmlConsoleDialog.ui b/examples/GuiClient/xmlConsoleDialog.ui deleted file mode 100644 index 61a3a1e2..00000000 --- a/examples/GuiClient/xmlConsoleDialog.ui +++ /dev/null @@ -1,139 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>xmlConsoleDialog</class> - <widget class="QDialog" name="xmlConsoleDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>569</width> - <height>349</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <property name="windowIcon"> - <iconset resource="resources.qrc"> - <normaloff>:/icons/resource/icon.png</normaloff>:/icons/resource/icon.png</iconset> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="margin"> - <number>6</number> - </property> - <item> - <widget class="QTextBrowser" name="textBrowser"/> - </item> - <item> - <widget class="QLabel" name="label_legend"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QCheckBox" name="checkBox_enable"> - <property name="text"> - <string>Enable</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_clear"> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources> - <include location="resources.qrc"/> - </resources> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>xmlConsoleDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>389</x> - <y>289</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>xmlConsoleDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>389</x> - <y>289</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>pushButton_clear</sender> - <signal>clicked()</signal> - <receiver>textBrowser</receiver> - <slot>clear()</slot> - <hints> - <hint type="sourcelabel"> - <x>257</x> - <y>283</y> - </hint> - <hint type="destinationlabel"> - <x>178</x> - <y>202</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/examples/example_0_connected/example_0_connected.pro b/examples/example_0_connected/example_0_connected.pro deleted file mode 100644 index fcb74477..00000000 --- a/examples/example_0_connected/example_0_connected.pro +++ /dev/null @@ -1,7 +0,0 @@ -include(../examples.pri) - -TARGET = example_0_connected - -SOURCES += example_0_connected.cpp - -OTHER_FILES += README diff --git a/examples/example_1_echoClient/example_1_echoClient.pro b/examples/example_1_echoClient/example_1_echoClient.pro deleted file mode 100644 index 8a39a64a..00000000 --- a/examples/example_1_echoClient/example_1_echoClient.pro +++ /dev/null @@ -1,9 +0,0 @@ -include(../examples.pri) - -TARGET = example_1_echoClient - -SOURCES += example_1_echoClient.cpp - -HEADERS += example_1_echoClient.h - -OTHER_FILES += README diff --git a/examples/example_2_rosterHandling/example_2_rosterHandling.pro b/examples/example_2_rosterHandling/example_2_rosterHandling.pro deleted file mode 100644 index c9c886f9..00000000 --- a/examples/example_2_rosterHandling/example_2_rosterHandling.pro +++ /dev/null @@ -1,9 +0,0 @@ -include(../examples.pri) - -TARGET = example_2_rosterHandling - -SOURCES += example_2_rosterHandling.cpp - -HEADERS += example_2_rosterHandling.h - -OTHER_FILES += README diff --git a/examples/example_3_transferHandling/example_3_transferHandling.pro b/examples/example_3_transferHandling/example_3_transferHandling.pro deleted file mode 100644 index 73370a03..00000000 --- a/examples/example_3_transferHandling/example_3_transferHandling.pro +++ /dev/null @@ -1,9 +0,0 @@ -include(../examples.pri) - -TARGET = example_3_transferHandling - -RESOURCES += example_3_transferHandling.qrc - -SOURCES += example_3_transferHandling.cpp - -HEADERS += example_3_transferHandling.h diff --git a/examples/example_4_callHandling/example_4_callHandling.cpp b/examples/example_4_callHandling/example_4_callHandling.cpp deleted file mode 100644 index c2989f3b..00000000 --- a/examples/example_4_callHandling/example_4_callHandling.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Authors: - * Ian Reinhart Geiser - * Jeremy Lainé - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - -#include <cstdlib> -#include <cstdio> - -#include <QAudioInput> -#include <QAudioOutput> -#include <QCoreApplication> -#include <QDebug> -#include <QHostInfo> - -#include "QXmppCallManager.h" -#include "QXmppJingleIq.h" -#include "QXmppRtpChannel.h" -#include "QXmppUtils.h" - -#include "example_4_callHandling.h" - -xmppClient::xmppClient(QObject *parent) - : QXmppClient(parent) - , m_turnPort(0) - , m_turnFinished(false) -{ - bool check; - Q_UNUSED(check); - - // add QXmppCallManager extension - callManager = new QXmppCallManager; - addExtension(callManager); - - check = connect(this, SIGNAL(connected()), - this, SLOT(slotConnected())); - Q_ASSERT(check); - - check = connect(this, SIGNAL(presenceReceived(QXmppPresence)), - this, SLOT(slotPresenceReceived(QXmppPresence))); - Q_ASSERT(check); - - check = connect(callManager, SIGNAL(callReceived(QXmppCall*)), - this, SLOT(slotCallReceived(QXmppCall*))); - Q_ASSERT(check); - - check = connect(&m_dns, SIGNAL(finished()), - this, SLOT(slotDnsLookupFinished())); - Q_ASSERT(check); -} - -void xmppClient::setRecipient(const QString &recipient) -{ - m_recipient = recipient; -} - -/// The audio mode of a call changed. - -void xmppClient::slotAudioModeChanged(QIODevice::OpenMode mode) -{ - QXmppCall *call = qobject_cast<QXmppCall*>(sender()); - Q_ASSERT(call); - QXmppRtpAudioChannel *channel = call->audioChannel(); - - // prepare audio format - QAudioFormat format; - format.setFrequency(channel->payloadType().clockrate()); - format.setChannels(channel->payloadType().channels()); - format.setSampleSize(16); - format.setCodec("audio/pcm"); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setSampleType(QAudioFormat::SignedInt); - - // the size in bytes of the audio buffers to/from sound devices - // 160 ms seems to be the minimum to work consistently on Linux/Mac/Windows - const int bufferSize = (format.frequency() * format.channels() * (format.sampleSize() / 8) * 160) / 1000; - - if (mode & QIODevice::ReadOnly) { - // initialise audio output - QAudioOutput *audioOutput = new QAudioOutput(format, this); - audioOutput->setBufferSize(bufferSize); - audioOutput->start(channel); - } - - if (mode & QIODevice::WriteOnly) { - // initialise audio input - QAudioInput *audioInput = new QAudioInput(format, this); - audioInput->setBufferSize(bufferSize); - audioInput->start(channel); - } -} - - -/// A call was received. - -void xmppClient::slotCallReceived(QXmppCall *call) -{ - bool check; - Q_UNUSED(check); - - qDebug() << "Got call from:" << call->jid(); - - check = connect(call, SIGNAL(stateChanged(QXmppCall::State)), - this, SLOT(slotCallStateChanged(QXmppCall::State))); - Q_ASSERT(check); - - check = connect(call, SIGNAL(audioModeChanged(QIODevice::OpenMode)), - this, SLOT(slotAudioModeChanged(QIODevice::OpenMode))); - Q_ASSERT(check); - - // accept call - call->accept(); -} - -/// A call changed state. - -void xmppClient::slotCallStateChanged(QXmppCall::State state) -{ - if (state == QXmppCall::ActiveState) - qDebug("Call active"); - else if (state == QXmppCall::DisconnectingState) - qDebug("Call disconnecting"); - else if (state == QXmppCall::FinishedState) - qDebug("Call finished"); -} - -void xmppClient::slotConnected() -{ - // lookup TURN server - const QString domain = configuration().domain(); - debug(QString("Looking up TURN server for domain %1").arg(domain)); - m_dns.setType(QDnsLookup::SRV); - m_dns.setName("_turn._udp." + domain); - m_dns.lookup(); -} - -/// The DNS SRV lookup for TURN completed. - -void xmppClient::slotDnsLookupFinished() -{ - QString serverName; - - if (m_dns.error() == QDnsLookup::NoError && !m_dns.serviceRecords().isEmpty()) { - m_turnPort = m_dns.serviceRecords().first().port(); - QHostInfo::lookupHost(m_dns.serviceRecords().first().target(), - this, SLOT(slotHostInfoFinished(QHostInfo))); - } else { - warning("Could not find STUN server for domain " + configuration().domain()); - m_turnFinished = true; - startCall(); - } -} - -void xmppClient::slotHostInfoFinished(const QHostInfo &hostInfo) -{ - if (!hostInfo.addresses().isEmpty()) { - info(QString("Found TURN server %1 port %2 for domain %3").arg(hostInfo.addresses().first().toString(), QString::number(m_turnPort), configuration().domain())); - callManager->setTurnServer(hostInfo.addresses().first(), m_turnPort); - callManager->setTurnUser(configuration().user()); - callManager->setTurnPassword(configuration().password()); - } - m_turnFinished = true; - startCall(); -} - -/// A presence was received. - -void xmppClient::slotPresenceReceived(const QXmppPresence &presence) -{ - // if we don't have a recipient, or if the presence is not from the recipient, - // do nothing - if (m_recipient.isEmpty() || - QXmppUtils::jidToBareJid(presence.from()) != m_recipient || - presence.type() != QXmppPresence::Available) - return; - - // start the call and connect to the its signals - m_recipientFullJid = presence.from(); - startCall(); -} - -void xmppClient::startCall() -{ - bool check; - Q_UNUSED(check); - - if (!m_turnFinished || m_recipientFullJid.isEmpty()) - return; - - // start the call and connect to the its signals - QXmppCall *call = callManager->call(m_recipientFullJid); - - check = connect(call, SIGNAL(stateChanged(QXmppCall::State)), - this, SLOT(slotCallStateChanged(QXmppCall::State))); - Q_ASSERT(check); - - check = connect(call, SIGNAL(audioModeChanged(QIODevice::OpenMode)), - this, SLOT(slotAudioModeChanged(QIODevice::OpenMode))); - Q_ASSERT(check); -} - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - // we want one argument : "send" or "receive" - if (argc != 2 || (strcmp(argv[1], "send") && strcmp(argv[1], "receive"))) - { - fprintf(stderr, "Usage: %s send|receive\n", argv[0]); - return EXIT_FAILURE; - } - - xmppClient client; - client.logger()->setLoggingType(QXmppLogger::StdoutLogging); - if (!strcmp(argv[1], "send")) { - client.setRecipient("qxmpp.test2@qxmpp.org"); - client.connectToServer("qxmpp.test1@qxmpp.org", "qxmpp123"); - } else { - client.connectToServer("qxmpp.test2@qxmpp.org", "qxmpp456"); - } - - return a.exec(); -} diff --git a/examples/example_4_callHandling/example_4_callHandling.h b/examples/example_4_callHandling/example_4_callHandling.h deleted file mode 100644 index 09af27c8..00000000 --- a/examples/example_4_callHandling/example_4_callHandling.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2008-2014 The QXmpp developers - * - * Author: - * Ian Reinhart Geiser - * - * Source: - * https://github.com/qxmpp-project/qxmpp - * - * This file is a part of QXmpp library. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - */ - - -#ifndef XMPPCLIENT_H -#define XMPPCLIENT_H - -#include "QXmppCallManager.h" -#include "QXmppClient.h" -#include "qdnslookup.h" - -class QHostInfo; - -class xmppClient : public QXmppClient -{ - Q_OBJECT - -public: - xmppClient(QObject *parent = 0); - void setRecipient(const QString &recipient); - -private slots: - void slotAudioModeChanged(QIODevice::OpenMode mode); - void slotCallReceived(QXmppCall *call); - void slotCallStateChanged(QXmppCall::State state); - void slotConnected(); - void slotDnsLookupFinished(); - void slotHostInfoFinished(const QHostInfo &hostInfo); - void slotPresenceReceived(const QXmppPresence &presence); - -private: - void startCall(); - - QXmppCallManager *callManager; - QDnsLookup m_dns; - QString m_recipient; - QString m_recipientFullJid; - quint16 m_turnPort; - bool m_turnFinished; -}; - -#endif // IBBCLIENT_H diff --git a/examples/example_4_callHandling/example_4_callHandling.pro b/examples/example_4_callHandling/example_4_callHandling.pro deleted file mode 100644 index 039455ef..00000000 --- a/examples/example_4_callHandling/example_4_callHandling.pro +++ /dev/null @@ -1,15 +0,0 @@ -include(../examples.pri) - -CONFIG += mobility -MOBILITY += multimedia - -TARGET = example_4_callHandling - -SOURCES += example_4_callHandling.cpp - -HEADERS += example_4_callHandling.h - -# Symbian packaging rules -symbian { - TARGET.CAPABILITY = "UserEnvironment" -} diff --git a/examples/example_5_rpcInterface/CMakeLists.txt b/examples/example_5_rpcInterface/CMakeLists.txt new file mode 100644 index 00000000..40f014ef --- /dev/null +++ b/examples/example_5_rpcInterface/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(5_rpcInterface main.cpp remoteinterface.cpp) +target_link_libraries(5_rpcInterface qxmpp) diff --git a/examples/example_5_rpcInterface/example_5_rpcInterface.pro b/examples/example_5_rpcInterface/example_5_rpcInterface.pro deleted file mode 100644 index ab50fdfd..00000000 --- a/examples/example_5_rpcInterface/example_5_rpcInterface.pro +++ /dev/null @@ -1,10 +0,0 @@ -include(../examples.pri) - -TARGET = example_5_rpcInterface - -SOURCES += main.cpp \ - remoteinterface.cpp - -HEADERS += remoteinterface.h - -OTHER_FILES += README diff --git a/examples/example_6_rpcClient/CMakeLists.txt b/examples/example_6_rpcClient/CMakeLists.txt new file mode 100644 index 00000000..d3b10b92 --- /dev/null +++ b/examples/example_6_rpcClient/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(6_rpcClient main.cpp rpcClient.cpp) +target_link_libraries(6_rpcClient qxmpp) diff --git a/examples/example_6_rpcClient/example_6_rpcClient.pro b/examples/example_6_rpcClient/example_6_rpcClient.pro deleted file mode 100644 index 0f642962..00000000 --- a/examples/example_6_rpcClient/example_6_rpcClient.pro +++ /dev/null @@ -1,10 +0,0 @@ -include(../examples.pri) - -TARGET = example_6_rpcClient - -SOURCES += main.cpp \ - rpcClient.cpp - -HEADERS += rpcClient.h - -OTHER_FILES += README diff --git a/examples/example_7_archiveHandling/example_7_archiveHandling.pro b/examples/example_7_archiveHandling/example_7_archiveHandling.pro deleted file mode 100644 index fc80314a..00000000 --- a/examples/example_7_archiveHandling/example_7_archiveHandling.pro +++ /dev/null @@ -1,7 +0,0 @@ -include(../examples.pri) - -TARGET = example_7_archiveHandling - -SOURCES += example_7_archiveHandling.cpp - -HEADERS += example_7_archiveHandling.h diff --git a/examples/example_8_server/main.cpp b/examples/example_8_server/example_8_server.cpp index e28f1de5..e28f1de5 100644 --- a/examples/example_8_server/main.cpp +++ b/examples/example_8_server/example_8_server.cpp diff --git a/examples/example_8_server/example_8_server.pro b/examples/example_8_server/example_8_server.pro deleted file mode 100644 index d8013ef5..00000000 --- a/examples/example_8_server/example_8_server.pro +++ /dev/null @@ -1,5 +0,0 @@ -include(../examples.pri) - -TARGET = example_8_server - -SOURCES += main.cpp diff --git a/examples/example_9_vCard/CMakeLists.txt b/examples/example_9_vCard/CMakeLists.txt new file mode 100644 index 00000000..8b4a95c9 --- /dev/null +++ b/examples/example_9_vCard/CMakeLists.txt @@ -0,0 +1,4 @@ +find_package(Qt5 REQUIRED COMPONENTS Gui) + +add_executable(9_vCard example_9_vCard.cpp) +target_link_libraries(9_vCard Qt5::Gui qxmpp) diff --git a/examples/example_9_vCard/example_9_vCard.pro b/examples/example_9_vCard/example_9_vCard.pro deleted file mode 100644 index 4ecdc816..00000000 --- a/examples/example_9_vCard/example_9_vCard.pro +++ /dev/null @@ -1,7 +0,0 @@ -include(../examples.pri) - -TARGET = example_9_vCard - -SOURCES += example_9_vCard.cpp - -HEADERS += example_9_vCard.h diff --git a/examples/examples.pri b/examples/examples.pri deleted file mode 100644 index 973473db..00000000 --- a/examples/examples.pri +++ /dev/null @@ -1,25 +0,0 @@ -include(../qxmpp.pri) - -TEMPLATE = app -CONFIG += console - -QMAKE_LIBDIR += ../../src -QMAKE_RPATHDIR += $$OUT_PWD/../../src -INCLUDEPATH += $$QXMPP_INCLUDEPATH -LIBS += $$QXMPP_LIBS - -# Symbian packaging rules -symbian { - vendorinfo = \ - "; Localised Vendor name" \ - "%{\"QXmpp\"}" \ - " " \ - "; Unique Vendor name" \ - ":\"QXmpp\"" \ - " " - - examples_deployment.pkg_prerules += vendorinfo - DEPLOYMENT += examples_deployment - - TARGET.CAPABILITY = "NetworkServices" -} diff --git a/examples/examples.pro b/examples/examples.pro deleted file mode 100644 index 9ca216ef..00000000 --- a/examples/examples.pro +++ /dev/null @@ -1,16 +0,0 @@ -include(../qxmpp.pri) - -TEMPLATE = subdirs - -SUBDIRS = example_0_connected \ - example_1_echoClient \ - example_2_rosterHandling \ - example_3_transferHandling \ -# example_4_callHandling \ - example_5_rpcInterface \ - example_6_rpcClient \ - example_7_archiveHandling \ - example_8_server \ - example_9_vCard -# GuiClient - diff --git a/qxmpp.pc.in b/qxmpp.pc.in new file mode 100644 index 00000000..69e29ba9 --- /dev/null +++ b/qxmpp.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/qxmpp + + +Name: Qxmpp +Description: Qxmpp Library +Version: @VERSION_STRING@ +Libs: -lqxmpp +Libs.private: -lQt5Network -lQt5Xml -lQt5Core +Cflags: -I${includedir} + diff --git a/qxmpp.prf b/qxmpp.prf deleted file mode 100644 index 1d5c45f6..00000000 --- a/qxmpp.prf +++ /dev/null @@ -1,46 +0,0 @@ -QXMPP_INCDIR = $$[QT_INSTALL_HEADERS] -QXMPP_LIBDIR = $$[QT_INSTALL_LIBS] - -## Distributions can adjust this for Qt 4 -QXMPP_INCDIR ~= s!/qt5*!! -QXMPP_LIBDIR ~= s!/qt5*!! - -CONFIG *= qt - - -# if we are including qxmpp.prf from the qxmpp tree (and not utilizing it as -# an installed qmake CONFIG feature), then point to the tree. this allows our -# qxmpp tree apps to build before qxmpp itself is installed. -exists($$PWD/qxmpp.pro) { - ## Jan // I doubt this is needed for QXMPP - QXMPP_INCDIR = $$PWD/include - QXMPP_LIBDIR = $$PWD/lib -} - -LINKAGE = - -# on mac, if qxmpp was built as a framework, link against it -mac: { - ## Jan // No idea about any of this Mac stuff - framework_dir = $${QXMPP_LIBDIR} - exists($$framework_dir/qxmpp.framework) { - LIBS += -F$$framework_dir - exists($$PWD/qxmpp.pro): INCLUDEPATH += $$QXMPP_INCDIR - else: INCLUDEPATH += $$framework_dir/qxmpp.framework/Headers - LINKAGE = -framework qxmpp - } -} - -# else, link normally -isEmpty(LINKAGE) { - exists($$PWD/qxmpp.pro): INCLUDEPATH += $$QXMPP_INCDIR - else: INCLUDEPATH += $$QXMPP_INCDIR/qxmpp ## Jan // This is probably the usual case - LIBS += -L$$QXMPP_LIBDIR - LINKAGE = -lqxmpp ## Jan // Distributions might tune this with -lqxmpp_qt5, etc. - CONFIG(debug, debug|release) { - windows:LINKAGE = -lqxmppd - mac:LINKAGE = -lqxmpp_debug - } -} - -LIBS += $$LINKAGE diff --git a/qxmpp.pri b/qxmpp.pri deleted file mode 100644 index 9e8d2398..00000000 --- a/qxmpp.pri +++ /dev/null @@ -1,90 +0,0 @@ -# Common definitions - -QT += network xml -QXMPP_VERSION = 0.9.3 -QXMPP_INCLUDEPATH = $$PWD/src/base $$PWD/src/client $$PWD/src/server - -# Determine library name -CONFIG(debug, debug|release) { - QXMPP_LIBRARY_NAME = qxmpp_d -} else { - QXMPP_LIBRARY_NAME = qxmpp -} - -# Determine library type (shared or staticlib) -isEmpty(QXMPP_LIBRARY_TYPE) { - android | ios { - QXMPP_LIBRARY_TYPE = staticlib - } else { - QXMPP_LIBRARY_TYPE = shared - } -} - -# Libraries used internally by QXmpp -android { - -} else:contains(MEEGO_EDITION,harmattan) { - # meego/harmattan has speex for sure - QXMPP_USE_SPEEX=1 -} else:symbian { - QXMPP_INTERNAL_INCLUDES = $$APP_LAYER_SYSTEMINCLUDE - QXMPP_INTERNAL_LIBS = -lesock -} else:win32 { - QXMPP_INTERNAL_LIBS = -ldnsapi -lws2_32 -} - -!isEmpty(QXMPP_USE_OPUS) { - DEFINES += QXMPP_USE_OPUS - QXMPP_INTERNAL_LIBS += -lopus -} - -!isEmpty(QXMPP_USE_SPEEX) { - DEFINES += QXMPP_USE_SPEEX - QXMPP_INTERNAL_LIBS += -lspeex -} - -!isEmpty(QXMPP_USE_THEORA) { - DEFINES += QXMPP_USE_THEORA - QXMPP_INTERNAL_LIBS += -ltheoradec -ltheoraenc -} - -!isEmpty(QXMPP_USE_VPX) { - DEFINES += QXMPP_USE_VPX - QXMPP_INTERNAL_LIBS += -lvpx -} - -# Libraries for apps which use QXmpp -QXMPP_LIBS = -l$${QXMPP_LIBRARY_NAME} -contains(QXMPP_LIBRARY_TYPE,staticlib) { - # Symbian needs a .lib extension to recognise the library as static - symbian: QXMPP_LIBS = -l$${QXMPP_LIBRARY_NAME}.lib - - # FIXME: we should be able to use the link_prl option to automatically pull - # in the extra libraries which the qxmpp library needs, but this does not - # seem to work on win32, so we specify the dependencies here: - QXMPP_LIBS += $$QXMPP_INTERNAL_LIBS - DEFINES += QXMPP_STATIC -} else { - # Windows needs the major library version - win32: QXMPP_LIBS = -l$${QXMPP_LIBRARY_NAME}0 - DEFINES += QXMPP_SHARED -} - -# Installation prefix and library directory -isEmpty(PREFIX) { - contains(MEEGO_EDITION,harmattan) { - PREFIX = /usr - } else:unix { - PREFIX = /usr/local - } else { - PREFIX = $$[QT_INSTALL_PREFIX] - } -} -isEmpty(LIBDIR) { - LIBDIR = lib -} - -# Internal API auto-tests -!isEmpty(QXMPP_AUTOTEST_INTERNAL) { - DEFINES += QXMPP_AUTOTEST_INTERNAL -} diff --git a/qxmpp.pro b/qxmpp.pro deleted file mode 100644 index 98974b7f..00000000 --- a/qxmpp.pro +++ /dev/null @@ -1,24 +0,0 @@ -include(qxmpp.pri) - -CONFIG += ordered -TEMPLATE = subdirs - -SUBDIRS = src -isEmpty(QXMPP_NO_TESTS) { - SUBDIRS += tests -} -isEmpty(QXMPP_NO_EXAMPLES) { - SUBDIRS += examples -} - -!isEmpty(QXMPP_USE_DOXYGEN) { - docs.commands = cd doc/ && $(MAKE) docs - docs.depends = sub-doc - docs.files = doc/html - docs.path = $$PREFIX/share/doc/qxmpp - docs.CONFIG += no_check_exist directory - - INSTALLS += docs - QMAKE_EXTRA_TARGETS += docs - SUBDIRS += doc -} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..628c0ae5 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,239 @@ +add_definitions(-DQXMPP_BUILD) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/base) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/client) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/server) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/base/QXmppGlobal.h.in ${CMAKE_CURRENT_BINARY_DIR}/base/QXmppGlobal.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/base) + +set(INSTALL_HEADER_FILES + ${CMAKE_CURRENT_BINARY_DIR}/base/QXmppGlobal.h + + # Base + base/QXmppArchiveIq.h + base/QXmppBindIq.h + base/QXmppBookmarkSet.h + base/QXmppByteStreamIq.h + base/QXmppDataForm.h + base/QXmppDiscoveryIq.h + base/QXmppElement.h + base/QXmppEntityTimeIq.h + base/QXmppIbbIq.h + base/QXmppIq.h + base/QXmppJingleIq.h + base/QXmppLogger.h + base/QXmppMamIq.h + base/QXmppMessage.h + base/QXmppMucIq.h + base/QXmppNonSASLAuth.h + base/QXmppPingIq.h + base/QXmppPresence.h + base/QXmppPubSubIq.h + base/QXmppRegisterIq.h + base/QXmppResultSet.h + base/QXmppRosterIq.h + base/QXmppRpcIq.h + base/QXmppRtcpPacket.h + base/QXmppRtpChannel.h + base/QXmppRtpPacket.h + base/QXmppSessionIq.h + base/QXmppSocks.h + base/QXmppStanza.h + base/QXmppStream.h + base/QXmppStreamFeatures.h + base/QXmppStun.h + base/QXmppUtils.h + base/QXmppVCardIq.h + base/QXmppVersionIq.h + + # Client + client/QXmppArchiveManager.h + client/QXmppBookmarkManager.h + client/QXmppCallManager.h + client/QXmppCarbonManager.h + client/QXmppClient.h + client/QXmppClientExtension.h + client/QXmppConfiguration.h + client/QXmppDiscoveryManager.h + client/QXmppEntityTimeManager.h + client/QXmppInvokable.h + client/QXmppMamManager.h + client/QXmppMessageReceiptManager.h + client/QXmppMucManager.h + client/QXmppOutgoingClient.h + client/QXmppRemoteMethod.h + client/QXmppRosterManager.h + client/QXmppRpcManager.h + client/QXmppTransferManager.h + client/QXmppTransferManager_p.h + client/QXmppVCardManager.h + client/QXmppVersionManager.h + + # Server + server/QXmppDialback.h + server/QXmppIncomingClient.h + server/QXmppIncomingServer.h + server/QXmppOutgoingServer.h + server/QXmppPasswordChecker.h + server/QXmppServer.h + server/QXmppServerExtension.h + server/QXmppServerPlugin.h +) + +set(SOURCE_FILES + # Base + base/QXmppArchiveIq.cpp + base/QXmppBindIq.cpp + base/QXmppBookmarkSet.cpp + base/QXmppByteStreamIq.cpp + base/QXmppCodec.cpp + base/QXmppConstants.cpp + base/QXmppDataForm.cpp + base/QXmppDiscoveryIq.cpp + base/QXmppElement.cpp + base/QXmppEntityTimeIq.cpp + base/QXmppIbbIq.cpp + base/QXmppIq.cpp + base/QXmppJingleIq.cpp + base/QXmppLogger.cpp + base/QXmppMamIq.cpp + base/QXmppMessage.cpp + base/QXmppMucIq.cpp + base/QXmppNonSASLAuth.cpp + base/QXmppPingIq.cpp + base/QXmppPresence.cpp + base/QXmppPubSubIq.cpp + base/QXmppRegisterIq.cpp + base/QXmppResultSet.cpp + base/QXmppRosterIq.cpp + base/QXmppRpcIq.cpp + base/QXmppRtcpPacket.cpp + base/QXmppRtpChannel.cpp + base/QXmppRtpPacket.cpp + base/QXmppSasl.cpp + base/QXmppSessionIq.cpp + base/QXmppSocks.cpp + base/QXmppStanza.cpp + base/QXmppStream.cpp + base/QXmppStreamFeatures.cpp + base/QXmppStreamInitiationIq.cpp + base/QXmppStreamManagement.cpp + base/QXmppStun.cpp + base/QXmppUtils.cpp + base/QXmppVCardIq.cpp + base/QXmppVersionIq.cpp + + # Client + client/QXmppDiscoveryManager.cpp + client/QXmppArchiveManager.cpp + client/QXmppBookmarkManager.cpp + client/QXmppCallManager.cpp + client/QXmppCarbonManager.cpp + client/QXmppClient.cpp + client/QXmppClientExtension.cpp + client/QXmppConfiguration.cpp + client/QXmppEntityTimeManager.cpp + client/QXmppInvokable.cpp + client/QXmppMamManager.cpp + client/QXmppMessageReceiptManager.cpp + client/QXmppMucManager.cpp + client/QXmppOutgoingClient.cpp + client/QXmppRemoteMethod.cpp + client/QXmppRosterManager.cpp + client/QXmppRpcManager.cpp + client/QXmppTransferManager.cpp + client/QXmppVCardManager.cpp + client/QXmppVersionManager.cpp + + # Server + server/QXmppDialback.cpp + server/QXmppIncomingClient.cpp + server/QXmppIncomingServer.cpp + server/QXmppOutgoingServer.cpp + server/QXmppPasswordChecker.cpp + server/QXmppServer.cpp + server/QXmppServerExtension.cpp + server/QXmppServerPlugin.cpp +) + +option(WITH_SPEEX "Support the Speex codec" OFF) +option(WITH_OPUS "Support the Opus codec" OFF) +option(WITH_THEORA "Support the Theora codec" OFF) +option(WITH_VPX "Support the VPX codec" OFF) + +if(WITH_SPEEX) + find_package(Speex REQUIRED) + include_directories(${Speex_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${Speex_LIBRARIES}) + add_definitions(-DQXMPP_USE_SPEEX) +endif() +if(WITH_OPUS) + find_package(Opus REQUIRED) + include_directories(${Opus_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${Opus_LIBRARIES}) + add_definitions(-DQXMPP_USE_OPUS) +endif() +if(WITH_THEORA) + find_package(Theora REQUIRED) + include_directories(${Theora_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${Theora_LIBRARIES}) + add_definitions(-DQXMPP_USE_THEORA) +endif() +if(WITH_VPX) + find_package(VPX REQUIRED) + include_directories(${VPX_INCLUDE_DIRS}) + set(MULTIMEDIA_LIBS ${MULTIMEDIA_LIBS} ${VPX_LIBRARIES}) + add_definitions(-DQXMPP_USE_VPX) +endif() + +add_library(qxmpp SHARED ${SOURCE_FILES}) + +set_target_properties(qxmpp PROPERTIES + VERSION ${VERSION_STRING} + SOVERSION ${SO_VERSION} + EXPORT_NAME QXmpp +) + +target_include_directories(qxmpp + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/base> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/client> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/server> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/base> + $<INSTALL_INTERFACE:include/qmake> +) + +target_link_libraries(qxmpp + PUBLIC + Qt5::Core + Qt5::Network + Qt5::Xml + PRIVATE + ${MULTIMEDIA_LIBS} +) + +install( + TARGETS qxmpp + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + EXPORT QXmppTarget +) + +install( + EXPORT QXmppTarget + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/qxmpp" + FILE QXmpp.cmake + NAMESPACE QXmpp:: + COMPONENT Devel +) + +export( + TARGETS qxmpp + FILE QXmpp.cmake +) + +install( + FILES ${INSTALL_HEADER_FILES} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qxmpp" +) + diff --git a/src/base/QXmppGlobal.h b/src/base/QXmppGlobal.h.in index 8024ce73..80ba8375 100644 --- a/src/base/QXmppGlobal.h +++ b/src/base/QXmppGlobal.h.in @@ -1,8 +1,9 @@ /* - * Copyright (C) 2008-2014 The QXmpp developers + * Copyright (C) 2008-2017 The QXmpp developers * * Author: * Manjeet Dahiya + * Niels Ole Salscheider * * Source: * https://github.com/qxmpp-project/qxmpp @@ -27,21 +28,13 @@ #include <QString> -#if defined(QXMPP_STATIC) -# define QXMPP_EXPORT -#else -# if defined(QXMPP_BUILD) +#if defined(QXMPP_BUILD) # define QXMPP_EXPORT Q_DECL_EXPORT -# else +#else # define QXMPP_EXPORT Q_DECL_IMPORT -# endif #endif -#if defined(QXMPP_AUTOTEST_INTERNAL) -# define QXMPP_AUTOTEST_EXPORT QXMPP_EXPORT -#else -# define QXMPP_AUTOTEST_EXPORT -#endif +#define QXMPP_AUTOTEST_EXPORT /// This macro expands a numeric value of the form 0xMMNNPP (MM = /// major, NN = minor, PP = patch) that specifies QXmpp's version @@ -52,8 +45,12 @@ /// available. /// -#define QXMPP_VERSION 0x000903 +#define QXMPP_VERSION (0x@VERSION_MAJOR@ << 16) | (0x@VERSION_MINOR@ << 8) | 0x@VERSION_PATCH@ -QXMPP_EXPORT QString QXmppVersion(); +inline QLatin1String QXmppVersion() +{ + return QLatin1String("@VERSION_STRING@"); +} #endif //QXMPPGLOBAL_H + diff --git a/src/base/QXmppSasl.cpp b/src/base/QXmppSasl.cpp index cb44007f..cf3347e2 100644 --- a/src/base/QXmppSasl.cpp +++ b/src/base/QXmppSasl.cpp @@ -27,11 +27,7 @@ #include <QCryptographicHash> #include <QDomElement> #include <QStringList> -#if QT_VERSION >= 0x050000 #include <QUrlQuery> -#else -#include <QUrl> -#endif #include "QXmppSasl_p.h" #include "QXmppUtils.h" @@ -437,23 +433,14 @@ bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &r return true; } else if (m_step == 1) { // parse request -#if QT_VERSION >= 0x050000 QUrlQuery requestUrl(challenge); -#else - QUrl requestUrl; - requestUrl.setEncodedQuery(challenge); -#endif if (!requestUrl.hasQueryItem("method") || !requestUrl.hasQueryItem("nonce")) { warning("QXmppSaslClientFacebook : Invalid challenge, nonce or method missing"); return false; } // build response -#if QT_VERSION >= 0x050000 QUrlQuery responseUrl; -#else - QUrl responseUrl; -#endif responseUrl.addQueryItem("access_token", password()); responseUrl.addQueryItem("api_key", username()); responseUrl.addQueryItem("call_id", 0); @@ -461,11 +448,8 @@ bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &r responseUrl.addQueryItem("nonce", requestUrl.queryItemValue("nonce")); responseUrl.addQueryItem("v", "1.0"); -#if QT_VERSION >= 0x050000 response = responseUrl.query().toUtf8(); -#else - response = responseUrl.encodedQuery(); -#endif + m_step++; return true; } else { diff --git a/src/base/base.pri b/src/base/base.pri deleted file mode 100644 index 45a74afb..00000000 --- a/src/base/base.pri +++ /dev/null @@ -1,102 +0,0 @@ -# Header files -INSTALL_HEADERS += \ - base/QXmppArchiveIq.h \ - base/QXmppBindIq.h \ - base/QXmppBookmarkSet.h \ - base/QXmppByteStreamIq.h \ - base/QXmppDataForm.h \ - base/QXmppDiscoveryIq.h \ - base/QXmppElement.h \ - base/QXmppEntityTimeIq.h \ - base/QXmppGlobal.h \ - base/QXmppIbbIq.h \ - base/QXmppIq.h \ - base/QXmppJingleIq.h \ - base/QXmppLogger.h \ - base/QXmppMamIq.h \ - base/QXmppMessage.h \ - base/QXmppMucIq.h \ - base/QXmppNonSASLAuth.h \ - base/QXmppPingIq.h \ - base/QXmppPresence.h \ - base/QXmppPubSubIq.h \ - base/QXmppRegisterIq.h \ - base/QXmppResultSet.h \ - base/QXmppRosterIq.h \ - base/QXmppRpcIq.h \ - base/QXmppRtcpPacket.h \ - base/QXmppRtpChannel.h \ - base/QXmppRtpPacket.h \ - base/QXmppSessionIq.h \ - base/QXmppSocks.h \ - base/QXmppStanza.h \ - base/QXmppStream.h \ - base/QXmppStreamFeatures.h \ - base/QXmppStun.h \ - base/QXmppUtils.h \ - base/QXmppVCardIq.h \ - base/QXmppVersionIq.h - -HEADERS += \ - base/QXmppCodec_p.h \ - base/QXmppConstants_p.h \ - base/QXmppSasl_p.h \ - base/QXmppStanza_p.h \ - base/QXmppStreamInitiationIq_p.h \ - base/QXmppStun_p.h - -# Source files -SOURCES += \ - base/QXmppArchiveIq.cpp \ - base/QXmppBindIq.cpp \ - base/QXmppBookmarkSet.cpp \ - base/QXmppByteStreamIq.cpp \ - base/QXmppCodec.cpp \ - base/QXmppConstants.cpp \ - base/QXmppDataForm.cpp \ - base/QXmppDiscoveryIq.cpp \ - base/QXmppElement.cpp \ - base/QXmppEntityTimeIq.cpp \ - base/QXmppGlobal.cpp \ - base/QXmppIbbIq.cpp \ - base/QXmppIq.cpp \ - base/QXmppJingleIq.cpp \ - base/QXmppLogger.cpp \ - base/QXmppMamIq.cpp \ - base/QXmppMessage.cpp \ - base/QXmppMucIq.cpp \ - base/QXmppNonSASLAuth.cpp \ - base/QXmppPingIq.cpp \ - base/QXmppPresence.cpp \ - base/QXmppPubSubIq.cpp \ - base/QXmppRegisterIq.cpp \ - base/QXmppResultSet.cpp \ - base/QXmppRosterIq.cpp \ - base/QXmppRpcIq.cpp \ - base/QXmppRtcpPacket.cpp \ - base/QXmppRtpChannel.cpp \ - base/QXmppRtpPacket.cpp \ - base/QXmppSasl.cpp \ - base/QXmppSessionIq.cpp \ - base/QXmppSocks.cpp \ - base/QXmppStanza.cpp \ - base/QXmppStream.cpp \ - base/QXmppStreamFeatures.cpp \ - base/QXmppStreamInitiationIq.cpp \ - base/QXmppStreamManagement.cpp \ - base/QXmppStun.cpp \ - base/QXmppUtils.cpp \ - base/QXmppVCardIq.cpp \ - base/QXmppVersionIq.cpp - -# DNS -qt_version = $$QT_MAJOR_VERSION -contains(qt_version, 4) { - INSTALL_HEADERS += base/qdnslookup.h base/qdnslookup_p.h - SOURCES += base/qdnslookup.cpp - android:SOURCES += base/qdnslookup_stub.cpp - else:symbian:SOURCES += base/qdnslookup_symbian.cpp - else:unix:SOURCES += base/qdnslookup_unix.cpp - else:win32:SOURCES += base/qdnslookup_win.cpp - else:SOURCES += base/qdnslookup_stub.cpp -} diff --git a/src/base/qdnslookup.cpp b/src/base/qdnslookup.cpp deleted file mode 100644 index 7b1e7c8f..00000000 --- a/src/base/qdnslookup.cpp +++ /dev/null @@ -1,989 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup.h" -#include "qdnslookup_p.h" - -#include <QCoreApplication> -#include <QDateTime> -#include <QMetaType> -#include <QThreadStorage> -#include <QUrl> - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDnsLookupThreadPool, theDnsLookupThreadPool); -Q_GLOBAL_STATIC(QThreadStorage<bool *>, theDnsLookupSeedStorage); - -static bool qt_qdnsmailexchangerecord_less_than(const QDnsMailExchangeRecord &r1, const QDnsMailExchangeRecord &r2) -{ - // Lower numbers are more preferred than higher ones. - return r1.preference() < r2.preference(); -} - -/*! - Sorts a list of QDnsMailExchangeRecord objects according to RFC 5321. -*/ - -static void qt_qdnsmailexchangerecord_sort(QList<QDnsMailExchangeRecord> &records) -{ - // If we have no more than one result, we are done. - if (records.size() <= 1) - return; - - // Order the records by preference. - qSort(records.begin(), records.end(), qt_qdnsmailexchangerecord_less_than); - - int i = 0; - while (i < records.size()) { - - // Determine the slice of records with the current preference. - QList<QDnsMailExchangeRecord> slice; - const quint16 slicePreference = records[i].preference(); - for (int j = i; j < records.size(); ++j) { - if (records[j].preference() != slicePreference) - break; - slice << records[j]; - } - - // Randomize the slice of records. - while (!slice.isEmpty()) { - const unsigned int pos = qrand() % slice.size(); - records[i++] = slice.takeAt(pos); - } - } -} - -static bool qt_qdnsservicerecord_less_than(const QDnsServiceRecord &r1, const QDnsServiceRecord &r2) -{ - // Order by priority, or if the priorities are equal, - // put zero weight records first. - return r1.priority() < r2.priority() - || (r1.priority() == r2.priority() - && r1.weight() == 0 && r2.weight() > 0); -} - -/*! - Sorts a list of QDnsServiceRecord objects according to RFC 2782. -*/ - -static void qt_qdnsservicerecord_sort(QList<QDnsServiceRecord> &records) -{ - // If we have no more than one result, we are done. - if (records.size() <= 1) - return; - - // Order the records by priority, and for records with an equal - // priority, put records with a zero weight first. - qSort(records.begin(), records.end(), qt_qdnsservicerecord_less_than); - - int i = 0; - while (i < records.size()) { - - // Determine the slice of records with the current priority. - QList<QDnsServiceRecord> slice; - const quint16 slicePriority = records[i].priority(); - unsigned int sliceWeight = 0; - for (int j = i; j < records.size(); ++j) { - if (records[j].priority() != slicePriority) - break; - sliceWeight += records[j].weight(); - slice << records[j]; - } -#ifdef QDNSLOOKUP_DEBUG - qDebug("qt_qdnsservicerecord_sort() : priority %i (size: %i, total weight: %i)", - slicePriority, slice.size(), sliceWeight); -#endif - - // Order the slice of records. - while (!slice.isEmpty()) { - const unsigned int weightThreshold = qrand() % (sliceWeight + 1); - unsigned int summedWeight = 0; - for (int j = 0; j < slice.size(); ++j) { - summedWeight += slice[j].weight(); - if (summedWeight >= weightThreshold) { -#ifdef QDNSLOOKUP_DEBUG - qDebug("qt_qdnsservicerecord_sort() : adding %s %i (weight: %i)", - qPrintable(slice[j].target()), slice[j].port(), - slice[j].weight()); -#endif - // Adjust the slice weight and take the current record. - sliceWeight -= slice[j].weight(); - records[i++] = slice.takeAt(j); - break; - } - } - } - } -} - -/*! - \class QDnsLookup - \brief The QDnsLookup class represents a DNS lookup. - - \inmodule QtNetwork - \ingroup network - - QDnsLookup uses the mechanisms provided by the operating system to perform - DNS lookups. To perform a lookup you need to specify a \l name and \l type - then invoke the \l{QDnsLookup::lookup()}{lookup()} slot. The - \l{QDnsLookup::finished()}{finished()} signal will be emitted upon - completion. - - For example, you can determine which servers an XMPP chat client should - connect to for a given domain with: - - \snippet doc/src/snippets/code/src_network_kernel_qdnslookup.cpp 0 - - Once the request finishes you can handle the results with: - - \snippet doc/src/snippets/code/src_network_kernel_qdnslookup.cpp 1 - - \note If you simply want to find the IP address(es) associated with a host - name, or the host name associated with an IP address you should use - QHostInfo instead. -*/ - -/*! - \enum QDnsLookup::Error - - Indicates all possible error conditions found during the - processing of the DNS lookup. - - \value NoError no error condition. - - \value ResolverError there was an error initializing the system's - DNS resolver. - - \value OperationCancelledError the lookup was aborted using the abort() - method. - - \value InvalidRequestError the requested DNS lookup was invalid. - - \value InvalidReplyError the reply returned by the server was invalid. - - \value ServerFailureError the server encountered an internal failure - while processing the request (SERVFAIL). - - \value ServerRefusedError the server refused to process the request for - security or policy reasons (REFUSED). - - \value NotFoundError the requested domain name does not exist - (NXDOMAIN). -*/ - -/*! - \enum QDnsLookup::Type - - Indicates the type of DNS lookup that was performed. - - \value A IPv4 address records. - - \value AAAA IPv6 address records. - - \value ANY any records. - - \value CNAME canonical name records. - - \value MX mail exchange records. - - \value NS name server records. - - \value PTR pointer records. - - \value SRV service records. - - \value TXT text records. -*/ - -/*! - \fn void QDnsLookup::finished() - - This signal is emitted when the reply has finished processing. -*/ - -/*! - \fn void QDnsLookup::nameChanged(const QString &name) - - This signal is emitted when the lookup \l name changes. - \a name is the new lookup name. -*/ - -/*! - \fn void QDnsLookup::typeChanged(Type type) - - This signal is emitted when the lookup \l type changes. - \a type is the new lookup type. -*/ - -/*! - Constructs a QDnsLookup object and sets \a parent as the parent object. - - The \l type property will default to QDnsLookup::A. -*/ - -QDnsLookup::QDnsLookup(QObject *parent) - : QObject(parent) - , d_ptr(new QDnsLookupPrivate(this)) -{ - qRegisterMetaType<QDnsLookupReply>(); -} -/*! - Constructs a QDnsLookup object for the given \a type and \a name and sets - \a parent as the parent object. -*/ - -QDnsLookup::QDnsLookup(Type type, const QString &name, QObject *parent) - : QObject(parent) - , d_ptr(new QDnsLookupPrivate(this)) -{ - Q_D(QDnsLookup); - qRegisterMetaType<QDnsLookupReply>(); - d->name = name; - d->type = type; -} - -/*! - Destroys the QDnsLookup object. - - It is safe to delete a QDnsLookup object even if it is not finished, you - will simply never receive its results. -*/ - -QDnsLookup::~QDnsLookup() -{ -} - -/*! - \property QDnsLookup::error - \brief the type of error that occurred if the DNS lookup failed, or NoError. -*/ - -QDnsLookup::Error QDnsLookup::error() const -{ - return d_func()->reply.error; -} - -/*! - \property QDnsLookup::errorString - \brief a human-readable description of the error if the DNS lookup failed. -*/ - -QString QDnsLookup::errorString() const -{ - return d_func()->reply.errorString; -} - -/*! - \property QDnsLookup::finished - \brief whether the reply has finished or was aborted. -*/ - -bool QDnsLookup::isFinished() const -{ - return d_func()->isFinished; -} - -/*! - \property QDnsLookup::name - \brief the name to lookup. - - \note The name will be encoded using IDNA, which means it's unsuitable for - querying SRV records compatible with the DNS-SD specification. -*/ - -QString QDnsLookup::name() const -{ - return d_func()->name; -} - -void QDnsLookup::setName(const QString &name) -{ - Q_D(QDnsLookup); - if (name != d->name) { - d->name = name; - emit nameChanged(name); - } -} - -/*! - \property QDnsLookup::type - \brief the type of DNS lookup. -*/ - -QDnsLookup::Type QDnsLookup::type() const -{ - return d_func()->type; -} - -void QDnsLookup::setType(Type type) -{ - Q_D(QDnsLookup); - if (type != d->type) { - d->type = type; - emit typeChanged(type); - } -} - -/*! - Returns the list of canonical name records associated with this lookup. -*/ - -QList<QDnsDomainNameRecord> QDnsLookup::canonicalNameRecords() const -{ - return d_func()->reply.canonicalNameRecords; -} - -/*! - Returns the list of host address records associated with this lookup. -*/ - -QList<QDnsHostAddressRecord> QDnsLookup::hostAddressRecords() const -{ - return d_func()->reply.hostAddressRecords; -} - -/*! - Returns the list of mail exchange records associated with this lookup. - - The records are sorted according to - \l{http://www.rfc-editor.org/rfc/rfc5321.txt}{RFC 5321}, so if you use them - to connect to servers, you should try them in the order they are listed. -*/ - -QList<QDnsMailExchangeRecord> QDnsLookup::mailExchangeRecords() const -{ - return d_func()->reply.mailExchangeRecords; -} - -/*! - Returns the list of name server records associated with this lookup. -*/ - -QList<QDnsDomainNameRecord> QDnsLookup::nameServerRecords() const -{ - return d_func()->reply.nameServerRecords; -} - -/*! - Returns the list of pointer records associated with this lookup. -*/ - -QList<QDnsDomainNameRecord> QDnsLookup::pointerRecords() const -{ - return d_func()->reply.pointerRecords; -} - -/*! - Returns the list of service records associated with this lookup. - - The records are sorted according to - \l{http://www.rfc-editor.org/rfc/rfc2782.txt}{RFC 2782}, so if you use them - to connect to servers, you should try them in the order they are listed. -*/ - -QList<QDnsServiceRecord> QDnsLookup::serviceRecords() const -{ - return d_func()->reply.serviceRecords; -} - -/*! - Returns the list of text records associated with this lookup. -*/ - -QList<QDnsTextRecord> QDnsLookup::textRecords() const -{ - return d_func()->reply.textRecords; -} - -/*! - Aborts the DNS lookup operation. - - If the lookup is already finished, does nothing. -*/ - -void QDnsLookup::abort() -{ - Q_D(QDnsLookup); - if (d->runnable) { - d->runnable = 0; - d->reply = QDnsLookupReply(); - d->reply.error = QDnsLookup::OperationCancelledError; - d->reply.errorString = tr("Operation cancelled"); - d->isFinished = true; - emit finished(); - } -} - -/*! - Performs the DNS lookup. - - The \l{QDnsLookup::finished()}{finished()} signal is emitted upon completion. -*/ - -void QDnsLookup::lookup() -{ - Q_D(QDnsLookup); - d->isFinished = false; - d->reply = QDnsLookupReply(); - d->runnable = new QDnsLookupRunnable(d->type, QUrl::toAce(d->name)); - connect(d->runnable, SIGNAL(finished(QDnsLookupReply)), - this, SLOT(_q_lookupFinished(QDnsLookupReply)), - Qt::BlockingQueuedConnection); - theDnsLookupThreadPool()->start(d->runnable); -} - -/*! - \class QDnsDomainNameRecord - \brief The QDnsDomainNameRecord class stores information about a domain - name record. - - \inmodule QtNetwork - \ingroup network - - When performing a name server lookup, zero or more records will be returned. - Each record is represented by a QDnsDomainNameRecord instance. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty domain name record object. -*/ - -QDnsDomainNameRecord::QDnsDomainNameRecord() - : d(new QDnsDomainNameRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsDomainNameRecord::QDnsDomainNameRecord(const QDnsDomainNameRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a domain name record. -*/ - -QDnsDomainNameRecord::~QDnsDomainNameRecord() -{ -} - -/*! - Returns the name for this record. -*/ - -QString QDnsDomainNameRecord::name() const -{ - return d->name; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsDomainNameRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the value for this domain name record. -*/ - -QString QDnsDomainNameRecord::value() const -{ - return d->value; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsDomainNameRecord &QDnsDomainNameRecord::operator=(const QDnsDomainNameRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsHostAddressRecord - \brief The QDnsHostAddressRecord class stores information about a host - address record. - - \inmodule QtNetwork - \ingroup network - - When performing an address lookup, zero or more records will be - returned. Each record is represented by a QDnsHostAddressRecord instance. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty host address record object. -*/ - -QDnsHostAddressRecord::QDnsHostAddressRecord() - : d(new QDnsHostAddressRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsHostAddressRecord::QDnsHostAddressRecord(const QDnsHostAddressRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a host address record. -*/ - -QDnsHostAddressRecord::~QDnsHostAddressRecord() -{ -} - -/*! - Returns the name for this record. -*/ - -QString QDnsHostAddressRecord::name() const -{ - return d->name; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsHostAddressRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the value for this host address record. -*/ - -QHostAddress QDnsHostAddressRecord::value() const -{ - return d->value; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsHostAddressRecord &QDnsHostAddressRecord::operator=(const QDnsHostAddressRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsMailExchangeRecord - \brief The QDnsMailExchangeRecord class stores information about a DNS MX record. - - \inmodule QtNetwork - \ingroup network - - When performing a lookup on a service, zero or more records will be - returned. Each record is represented by a QDnsMailExchangeRecord instance. - - The meaning of the fields is defined in - \l{http://www.rfc-editor.org/rfc/rfc1035.txt}{RFC 1035}. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty mail exchange record object. -*/ - -QDnsMailExchangeRecord::QDnsMailExchangeRecord() - : d(new QDnsMailExchangeRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsMailExchangeRecord::QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a mail exchange record. -*/ - -QDnsMailExchangeRecord::~QDnsMailExchangeRecord() -{ -} - -/*! - Returns the domain name of the mail exchange for this record. -*/ - -QString QDnsMailExchangeRecord::exchange() const -{ - return d->exchange; -} - -/*! - Returns the name for this record. -*/ - -QString QDnsMailExchangeRecord::name() const -{ - return d->name; -} - -/*! - Returns the preference for this record. -*/ - -quint16 QDnsMailExchangeRecord::preference() const -{ - return d->preference; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsMailExchangeRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsMailExchangeRecord &QDnsMailExchangeRecord::operator=(const QDnsMailExchangeRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsServiceRecord - \brief The QDnsServiceRecord class stores information about a DNS SRV record. - - \inmodule QtNetwork - \ingroup network - - When performing a lookup on a service, zero or more records will be - returned. Each record is represented by a QDnsServiceRecord instance. - - The meaning of the fields is defined in - \l{http://www.rfc-editor.org/rfc/rfc2782.txt}{RFC 2782}. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty service record object. -*/ - -QDnsServiceRecord::QDnsServiceRecord() - : d(new QDnsServiceRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsServiceRecord::QDnsServiceRecord(const QDnsServiceRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a service record. -*/ - -QDnsServiceRecord::~QDnsServiceRecord() -{ -} - -/*! - Returns the name for this record. -*/ - -QString QDnsServiceRecord::name() const -{ - return d->name; -} - -/*! - Returns the port on the target host for this service record. -*/ - -quint16 QDnsServiceRecord::port() const -{ - return d->port; -} - -/*! - Returns the priority for this service record. - - A client must attempt to contact the target host with the lowest-numbered - priority. -*/ - -quint16 QDnsServiceRecord::priority() const -{ - return d->priority; -} - -/*! - Returns the domain name of the target host for this service record. -*/ - -QString QDnsServiceRecord::target() const -{ - return d->target; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsServiceRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the weight for this service record. - - The weight field specifies a relative weight for entries with the same - priority. Entries with higher weights should be selected with a higher - probability. -*/ - -quint16 QDnsServiceRecord::weight() const -{ - return d->weight; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsServiceRecord &QDnsServiceRecord::operator=(const QDnsServiceRecord &other) -{ - d = other.d; - return *this; -} - -/*! - \class QDnsTextRecord - \brief The QDnsTextRecord class stores information about a DNS TXT record. - - \inmodule QtNetwork - \ingroup network - - When performing a text lookup, zero or more records will be - returned. Each record is represented by a QDnsTextRecord instance. - - The meaning of the fields is defined in - \l{http://www.rfc-editor.org/rfc/rfc1035.txt}{RFC 1035}. - - \sa QDnsLookup -*/ - -/*! - Constructs an empty text record object. -*/ - -QDnsTextRecord::QDnsTextRecord() - : d(new QDnsTextRecordPrivate) -{ -} - -/*! - Constructs a copy of \a other. -*/ - -QDnsTextRecord::QDnsTextRecord(const QDnsTextRecord &other) - : d(other.d) -{ -} - -/*! - Destroys a text record. -*/ - -QDnsTextRecord::~QDnsTextRecord() -{ -} - -/*! - Returns the name for this text record. -*/ - -QString QDnsTextRecord::name() const -{ - return d->name; -} - -/*! - Returns the duration in seconds for which this record is valid. -*/ - -quint32 QDnsTextRecord::timeToLive() const -{ - return d->timeToLive; -} - -/*! - Returns the values for this text record. -*/ - -QList<QByteArray> QDnsTextRecord::values() const -{ - return d->values; -} - -/*! - Assigns the data of the \a other object to this record object, - and returns a reference to it. -*/ - -QDnsTextRecord &QDnsTextRecord::operator=(const QDnsTextRecord &other) -{ - d = other.d; - return *this; -} - -void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply) -{ - Q_Q(QDnsLookup); - if (runnable == q->sender()) { -#ifdef QDNSLOOKUP_DEBUG - qDebug("DNS reply for %s: %i (%s)", qPrintable(name), _reply.error, qPrintable(_reply.errorString)); -#endif - reply = _reply; - runnable = 0; - isFinished = true; - emit q->finished(); - } -} - -void QDnsLookupRunnable::run() -{ - QDnsLookupReply reply; - - // Validate input. - if (requestName.isEmpty()) { - reply.error = QDnsLookup::InvalidRequestError; - reply.errorString = tr("Invalid domain name"); - emit finished(reply); - return; - } - - // Perform request. - query(requestType, requestName, &reply); - - // Sort results. - if (!theDnsLookupSeedStorage()->hasLocalData()) { - qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()) ^ reinterpret_cast<quintptr>(this)); - theDnsLookupSeedStorage()->setLocalData(new bool(true)); - } - qt_qdnsmailexchangerecord_sort(reply.mailExchangeRecords); - qt_qdnsservicerecord_sort(reply.serviceRecords); - - emit finished(reply); -} - -QDnsLookupThreadPool::QDnsLookupThreadPool() - : signalsConnected(false) -{ - // Run up to 5 lookups in parallel. - setMaxThreadCount(5); -} - -void QDnsLookupThreadPool::start(QRunnable *runnable) -{ - // Ensure threads complete at application destruction. - if (!signalsConnected) { - QMutexLocker signalsLocker(&signalsMutex); - if (!signalsConnected) { - QCoreApplication *app = QCoreApplication::instance(); - if (!app) { - qWarning("QDnsLookup requires a QCoreApplication"); - delete runnable; - return; - } - - moveToThread(app->thread()); - connect(app, SIGNAL(destroyed()), - SLOT(_q_applicationDestroyed()), Qt::DirectConnection); - signalsConnected = true; - } - } - - QThreadPool::start(runnable); -} - -void QDnsLookupThreadPool::_q_applicationDestroyed() -{ - waitForDone(); - signalsConnected = false; -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup.h b/src/base/qdnslookup.h deleted file mode 100644 index bd5f6602..00000000 --- a/src/base/qdnslookup.h +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDNSLOOKUP_H -#define QDNSLOOKUP_H - -#include <QList> -#include <QObject> -#include <QSharedData> -#include <QSharedPointer> -#include <QString> - -#include "QXmppGlobal.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Network) - -class QHostAddress; -class QDnsLookupPrivate; -class QDnsDomainNameRecordPrivate; -class QDnsHostAddressRecordPrivate; -class QDnsMailExchangeRecordPrivate; -class QDnsServiceRecordPrivate; -class QDnsTextRecordPrivate; - -class QXMPP_EXPORT QDnsDomainNameRecord -{ -public: - QDnsDomainNameRecord(); - QDnsDomainNameRecord(const QDnsDomainNameRecord &other); - ~QDnsDomainNameRecord(); - - QString name() const; - quint32 timeToLive() const; - QString value() const; - - QDnsDomainNameRecord &operator=(const QDnsDomainNameRecord &other); - -private: - QSharedDataPointer<QDnsDomainNameRecordPrivate> d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsHostAddressRecord -{ -public: - QDnsHostAddressRecord(); - QDnsHostAddressRecord(const QDnsHostAddressRecord &other); - ~QDnsHostAddressRecord(); - - QString name() const; - quint32 timeToLive() const; - QHostAddress value() const; - - QDnsHostAddressRecord &operator=(const QDnsHostAddressRecord &other); - -private: - QSharedDataPointer<QDnsHostAddressRecordPrivate> d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsMailExchangeRecord -{ -public: - QDnsMailExchangeRecord(); - QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other); - ~QDnsMailExchangeRecord(); - - QString exchange() const; - QString name() const; - quint16 preference() const; - quint32 timeToLive() const; - - QDnsMailExchangeRecord &operator=(const QDnsMailExchangeRecord &other); - -private: - QSharedDataPointer<QDnsMailExchangeRecordPrivate> d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsServiceRecord -{ -public: - QDnsServiceRecord(); - QDnsServiceRecord(const QDnsServiceRecord &other); - ~QDnsServiceRecord(); - - QString name() const; - quint16 port() const; - quint16 priority() const; - QString target() const; - quint32 timeToLive() const; - quint16 weight() const; - - QDnsServiceRecord &operator=(const QDnsServiceRecord &other); - -private: - QSharedDataPointer<QDnsServiceRecordPrivate> d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsTextRecord -{ -public: - QDnsTextRecord(); - QDnsTextRecord(const QDnsTextRecord &other); - ~QDnsTextRecord(); - - QString name() const; - quint32 timeToLive() const; - QList<QByteArray> values() const; - - QDnsTextRecord &operator=(const QDnsTextRecord &other); - -private: - QSharedDataPointer<QDnsTextRecordPrivate> d; - friend class QDnsLookupRunnable; -}; - -class QXMPP_EXPORT QDnsLookup : public QObject -{ - Q_OBJECT - Q_ENUMS(Error Type) - Q_PROPERTY(Error error READ error NOTIFY finished) - Q_PROPERTY(QString errorString READ errorString NOTIFY finished) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged) - -public: - enum Error - { - NoError = 0, - ResolverError, - OperationCancelledError, - InvalidRequestError, - InvalidReplyError, - ServerFailureError, - ServerRefusedError, - NotFoundError - }; - - enum Type - { - A = 1, - AAAA = 28, - ANY = 255, - CNAME = 5, - MX = 15, - NS = 2, - PTR = 12, - SRV = 33, - TXT = 16 - }; - - QDnsLookup(QObject *parent = 0); - QDnsLookup(Type type, const QString &name, QObject *parent = 0); - ~QDnsLookup(); - - Error error() const; - QString errorString() const; - bool isFinished() const; - - QString name() const; - void setName(const QString &name); - - Type type() const; - void setType(QDnsLookup::Type); - - QList<QDnsDomainNameRecord> canonicalNameRecords() const; - QList<QDnsHostAddressRecord> hostAddressRecords() const; - QList<QDnsMailExchangeRecord> mailExchangeRecords() const; - QList<QDnsDomainNameRecord> nameServerRecords() const; - QList<QDnsDomainNameRecord> pointerRecords() const; - QList<QDnsServiceRecord> serviceRecords() const; - QList<QDnsTextRecord> textRecords() const; - - -public Q_SLOTS: - void abort(); - void lookup(); - -Q_SIGNALS: - void finished(); - void nameChanged(const QString &name); - void typeChanged(Type type); - -private: - QDnsLookupPrivate *d_ptr; - Q_DECLARE_PRIVATE(QDnsLookup) - Q_PRIVATE_SLOT(d_func(), void _q_lookupFinished(const QDnsLookupReply &reply)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#include "qdnslookup_p.h" - -#endif // QDNSLOOKUP_H diff --git a/src/base/qdnslookup_p.h b/src/base/qdnslookup_p.h deleted file mode 100644 index 4797f345..00000000 --- a/src/base/qdnslookup_p.h +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDNSLOOKUP_P_H -#define QDNSLOOKUP_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the QDnsLookup class. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include <QHostAddress> -#include <QMetaType> -#include <QMutex> -#include <QRunnable> -#include <QSharedPointer> -#include <QThreadPool> - -#include "qdnslookup.h" - -QT_BEGIN_NAMESPACE - -//#define QDNSLOOKUP_DEBUG - -class QDnsLookupRunnable; - -class QDnsLookupReply -{ -public: - QDnsLookupReply() - : error(QDnsLookup::NoError) - { } - - QDnsLookup::Error error; - QString errorString; - - QList<QDnsDomainNameRecord> canonicalNameRecords; - QList<QDnsHostAddressRecord> hostAddressRecords; - QList<QDnsMailExchangeRecord> mailExchangeRecords; - QList<QDnsDomainNameRecord> nameServerRecords; - QList<QDnsDomainNameRecord> pointerRecords; - QList<QDnsServiceRecord> serviceRecords; - QList<QDnsTextRecord> textRecords; -}; - -class QDnsLookupPrivate -{ -public: - QDnsLookupPrivate(QDnsLookup *qq) - : isFinished(false) - , type(QDnsLookup::A) - , runnable(0) - , q_ptr(qq) - { } - - void _q_lookupFinished(const QDnsLookupReply &reply); - - bool isFinished; - QString name; - QDnsLookup::Type type; - QDnsLookupReply reply; - QDnsLookupRunnable *runnable; - QDnsLookup *q_ptr; - - Q_DECLARE_PUBLIC(QDnsLookup) -}; - -class QDnsLookupRunnable : public QObject, public QRunnable -{ - Q_OBJECT - -public: - QDnsLookupRunnable(QDnsLookup::Type type, const QByteArray &name) - : requestType(type) - , requestName(name) - { } - void run(); - -signals: - void finished(const QDnsLookupReply &reply); - -private: - static void query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply); - QDnsLookup::Type requestType; - QByteArray requestName; -}; - -class QDnsLookupThreadPool : public QThreadPool -{ - Q_OBJECT - -public: - QDnsLookupThreadPool(); - void start(QRunnable *runnable); - -private slots: - void _q_applicationDestroyed(); - -private: - QMutex signalsMutex; - bool signalsConnected; -}; - -class QDnsRecordPrivate : public QSharedData -{ -public: - QDnsRecordPrivate() - : timeToLive(0) - { } - - QString name; - quint32 timeToLive; -}; - -class QDnsDomainNameRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsDomainNameRecordPrivate() - { } - - QString value; -}; - -class QDnsHostAddressRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsHostAddressRecordPrivate() - { } - - QHostAddress value; -}; - -class QDnsMailExchangeRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsMailExchangeRecordPrivate() - : preference(0) - { } - - QString exchange; - quint16 preference; -}; - -class QDnsServiceRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsServiceRecordPrivate() - : port(0), - priority(0), - weight(0) - { } - - QString target; - quint16 port; - quint16 priority; - quint16 weight; -}; - -class QDnsTextRecordPrivate : public QDnsRecordPrivate -{ -public: - QDnsTextRecordPrivate() - { } - - QList<QByteArray> values; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDnsLookupReply) - -#endif // QDNSLOOKUP_P_H diff --git a/src/base/qdnslookup_stub.cpp b/src/base/qdnslookup_stub.cpp deleted file mode 100644 index df9ed349..00000000 --- a/src/base/qdnslookup_stub.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup_p.h" - -QT_BEGIN_NAMESPACE - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - Q_UNUSED(requestType); - Q_UNUSED(requestName); - reply->error = QDnsLookup::ResolverError; - reply->errorString = QLatin1String("QDnsLookup is not implemented for this platform"); -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup_symbian.cpp b/src/base/qdnslookup_symbian.cpp deleted file mode 100644 index bed5278e..00000000 --- a/src/base/qdnslookup_symbian.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup_p.h" - -#include <QUrl> -#include <QMutex> -#include <QLibrary> - -#include <dns_qry.h> - -QT_BEGIN_NAMESPACE - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - RHostResolver dnsResolver; - RSocketServ dnsSocket; - - // Initialise resolver. - TInt err = dnsSocket.Connect(); - err = dnsResolver.Open(dnsSocket, KAfInet, KProtocolInetUdp); - if (err != KErrNone) { - reply->error = QDnsLookup::ResolverError; - reply->errorString = QLatin1String("RHostResolver::Open failed"); - return; - } - - // Perform DNS query. - TDnsQueryBuf dnsQuery; - TDnsRespSRVBuf dnsResponse; - dnsQuery().SetClass(KDnsRRClassIN); - TPtrC8 queryPtr(reinterpret_cast<const TUint8*>(requestName.constData()), requestName.size()); - dnsQuery().SetData(queryPtr); - dnsQuery().SetType(requestType); - err = dnsResolver.Query(dnsQuery, dnsResponse); - if (err != KErrNone) { - reply->error = QDnsLookup::NotFoundError; - reply->errorString = QLatin1String("RHostResolver::Query failed"); - return; - } - - // Extract results. - while (err == KErrNone) { - const QByteArray aceName((const char*)dnsResponse().Target().Ptr(), - dnsResponse().Target().Length()); - - QDnsServiceRecord record; - record.d->name = QUrl::fromAce(requestName); - record.d->target = QUrl::fromAce(aceName); - record.d->port = dnsResponse().Port(); - record.d->priority = dnsResponse().Priority(); - record.d->timeToLive = dnsResponse().RRTtl(); - record.d->weight = dnsResponse().Weight(); - reply->serviceRecords.append(record); - - err = dnsResolver.QueryGetNext(dnsResponse); - } -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup_unix.cpp b/src/base/qdnslookup_unix.cpp deleted file mode 100644 index f4d1c64c..00000000 --- a/src/base/qdnslookup_unix.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdnslookup_p.h" - -#include <QLibrary> -#include <QMutex> -#include <QScopedPointer> -#include <QUrl> - -#include <sys/types.h> -#include <netinet/in.h> -#include <arpa/nameser.h> -#include <arpa/nameser_compat.h> -#include <resolv.h> - -QT_BEGIN_NAMESPACE - -static QMutex local_res_mutex; -typedef int (*dn_expand_proto)(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); -static dn_expand_proto local_dn_expand = 0; -typedef void (*res_nclose_proto)(res_state); -static res_nclose_proto local_res_nclose = 0; -typedef int (*res_ninit_proto)(res_state); -static res_ninit_proto local_res_ninit = 0; -typedef int (*res_nquery_proto)(res_state, const char *, int, int, unsigned char *, int); -static res_nquery_proto local_res_nquery = 0; - -// Custom deleter to close resolver state. - -struct QDnsLookupStateDeleter -{ - static inline void cleanup(struct __res_state *pointer) - { - local_res_nclose(pointer); - } -}; - -static void resolveLibrary() -{ - QLibrary lib(QLatin1String("resolv")); - if (!lib.load()) - return; - - local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand")); - if (!local_dn_expand) - local_dn_expand = dn_expand_proto(lib.resolve("dn_expand")); - - local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose")); - if (!local_res_nclose) - local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose")); - if (!local_res_nclose) - local_res_nclose = res_nclose_proto(lib.resolve("res_nclose")); - - local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit")); - if (!local_res_ninit) - local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit")); - if (!local_res_ninit) - local_res_ninit = res_ninit_proto(lib.resolve("res_ninit")); - - local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery")); - if (!local_res_nquery) - local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery")); - if (!local_res_nquery) - local_res_nquery = res_nquery_proto(lib.resolve("res_nquery")); -} - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - // Load dn_expand, res_ninit and res_nquery on demand. - static volatile bool triedResolve = false; - if (!triedResolve) { - QMutexLocker locker(&local_res_mutex); - if (!triedResolve) { - resolveLibrary(); - triedResolve = true; - } - } - - // If dn_expand, res_ninit or res_nquery is missing, fail. - if (!local_dn_expand || !local_res_nclose || !local_res_ninit || !local_res_nquery) { - reply->error = QDnsLookup::ResolverError; - reply->errorString = tr("Resolver functions not found"); - return; - } - - // Initialize state. - struct __res_state state; - memset(&state, 0, sizeof(state)); - if (local_res_ninit(&state) < 0) { - reply->error = QDnsLookup::ResolverError; - reply->errorString = tr("Resolver initialization failed"); - return; - } -#ifdef QDNSLOOKUP_DEBUG - state.options |= RES_DEBUG; -#endif - QScopedPointer<struct __res_state, QDnsLookupStateDeleter> state_ptr(&state); - - // Perform DNS query. - unsigned char response[PACKETSZ]; - memset(response, 0, sizeof(response)); - const int responseLength = local_res_nquery(&state, requestName, C_IN, requestType, response, sizeof(response)); - - // Check the response header. - HEADER *header = (HEADER*)response; - const int answerCount = ntohs(header->ancount); - switch (header->rcode) { - case NOERROR: - break; - case FORMERR: - reply->error = QDnsLookup::InvalidRequestError; - reply->errorString = tr("Server could not process query"); - return; - case SERVFAIL: - reply->error = QDnsLookup::ServerFailureError; - reply->errorString = tr("Server failure"); - return; - case NXDOMAIN: - reply->error = QDnsLookup::NotFoundError; - reply->errorString = tr("Non existent domain"); - return; - case REFUSED: - reply->error = QDnsLookup::ServerRefusedError; - reply->errorString = tr("Server refused to answer"); - return; - default: - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid reply received"); - return; - } - - // Check the reply is valid. - if (responseLength < int(sizeof(HEADER))) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid reply received"); - return; - } - - // Skip the query host, type (2 bytes) and class (2 bytes). - char host[PACKETSZ], answer[PACKETSZ]; - unsigned char *p = response + sizeof(HEADER); - int status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Could not expand domain name"); - return; - } - p += status + 4; - - // Extract results. - int answerIndex = 0; - while ((p < response + responseLength) && (answerIndex < answerCount)) { - status = local_dn_expand(response, response + responseLength, p, host, sizeof(host)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Could not expand domain name"); - return; - } - const QString name = QUrl::fromAce(host); - - p += status; - const quint16 type = (p[0] << 8) | p[1]; - p += 2; // RR type - p += 2; // RR class - const quint32 ttl = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; - p += 4; - const quint16 size = (p[0] << 8) | p[1]; - p += 2; - - if (type == QDnsLookup::A) { - if (size != 4) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid IPv4 address record"); - return; - } - const quint32 addr = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QHostAddress(addr); - reply->hostAddressRecords.append(record); - } else if (type == QDnsLookup::AAAA) { - if (size != 16) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid IPv6 address record"); - return; - } - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QHostAddress(p); - reply->hostAddressRecords.append(record); - } else if (type == QDnsLookup::CNAME) { - status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid canonical name record"); - return; - } - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QUrl::fromAce(answer); - reply->canonicalNameRecords.append(record); - } else if (type == QDnsLookup::NS) { - status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid name server record"); - return; - } - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QUrl::fromAce(answer); - reply->nameServerRecords.append(record); - } else if (type == QDnsLookup::PTR) { - status = local_dn_expand(response, response + responseLength, p, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid pointer record"); - return; - } - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - record.d->value = QUrl::fromAce(answer); - reply->pointerRecords.append(record); - } else if (type == QDnsLookup::MX) { - const quint16 preference = (p[0] << 8) | p[1]; - status = local_dn_expand(response, response + responseLength, p + 2, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid mail exchange record"); - return; - } - QDnsMailExchangeRecord record; - record.d->exchange = QUrl::fromAce(answer); - record.d->name = name; - record.d->preference = preference; - record.d->timeToLive = ttl; - reply->mailExchangeRecords.append(record); - } else if (type == QDnsLookup::SRV) { - const quint16 priority = (p[0] << 8) | p[1]; - const quint16 weight = (p[2] << 8) | p[3]; - const quint16 port = (p[4] << 8) | p[5]; - status = local_dn_expand(response, response + responseLength, p + 6, answer, sizeof(answer)); - if (status < 0) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid service record"); - return; - } - QDnsServiceRecord record; - record.d->name = name; - record.d->target = QUrl::fromAce(answer); - record.d->port = port; - record.d->priority = priority; - record.d->timeToLive = ttl; - record.d->weight = weight; - reply->serviceRecords.append(record); - } else if (type == QDnsLookup::TXT) { - unsigned char *txt = p; - QDnsTextRecord record; - record.d->name = name; - record.d->timeToLive = ttl; - while (txt < p + size) { - const unsigned char length = *txt; - txt++; - if (txt + length > p + size) { - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid text record"); - return; - } - record.d->values << QByteArray((char*)txt, length); - txt += length; - } - reply->textRecords.append(record); - } - p += size; - answerIndex++; - } -} - -QT_END_NAMESPACE diff --git a/src/base/qdnslookup_win.cpp b/src/base/qdnslookup_win.cpp deleted file mode 100644 index d89ec623..00000000 --- a/src/base/qdnslookup_win.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org> -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <winsock2.h> -#include "qdnslookup_p.h" - -#include <QUrl> -#include <QMutex> -#include <QLibrary> - -#include <windows.h> -#include <windns.h> - -QT_BEGIN_NAMESPACE - -void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) -{ - // Perform DNS query. - PDNS_RECORD dns_records = 0; - const DNS_STATUS status = DnsQuery_UTF8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL); - switch (status) { - case ERROR_SUCCESS: - break; - case DNS_ERROR_RCODE_FORMAT_ERROR: - reply->error = QDnsLookup::InvalidRequestError; - reply->errorString = tr("Server could not process query"); - return; - case DNS_ERROR_RCODE_SERVER_FAILURE: - reply->error = QDnsLookup::ServerFailureError; - reply->errorString = tr("Server failure"); - return; - case DNS_ERROR_RCODE_NAME_ERROR: - reply->error = QDnsLookup::NotFoundError; - reply->errorString = tr("Non existent domain"); - return; - case DNS_ERROR_RCODE_REFUSED: - reply->error = QDnsLookup::ServerRefusedError; - reply->errorString = tr("Server refused to answer"); - return; - default: - reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid reply received"); - return; - } - - // Extract results. - for (PDNS_RECORD ptr = dns_records; ptr != NULL; ptr = ptr->pNext) { - const QString name = QUrl::fromAce((char*)ptr->pName); - if (ptr->wType == QDnsLookup::A) { - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QHostAddress(ntohl(ptr->Data.A.IpAddress)); - reply->hostAddressRecords.append(record); - } else if (ptr->wType == QDnsLookup::AAAA) { - Q_IPV6ADDR addr; - memcpy(&addr, &ptr->Data.AAAA.Ip6Address, sizeof(Q_IPV6ADDR)); - - QDnsHostAddressRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QHostAddress(addr); - reply->hostAddressRecords.append(record); - } else if (ptr->wType == QDnsLookup::CNAME) { - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QUrl::fromAce((char*)ptr->Data.Cname.pNameHost); - reply->canonicalNameRecords.append(record); - } else if (ptr->wType == QDnsLookup::MX) { - QDnsMailExchangeRecord record; - record.d->name = name; - record.d->exchange = QUrl::fromAce((char*)ptr->Data.Mx.pNameExchange); - record.d->preference = ptr->Data.Mx.wPreference; - record.d->timeToLive = ptr->dwTtl; - reply->mailExchangeRecords.append(record); - } else if (ptr->wType == QDnsLookup::NS) { - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QUrl::fromAce((char*)ptr->Data.Ns.pNameHost); - reply->nameServerRecords.append(record); - } else if (ptr->wType == QDnsLookup::PTR) { - QDnsDomainNameRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - record.d->value = QUrl::fromAce((char*)ptr->Data.Ptr.pNameHost); - reply->pointerRecords.append(record); - } else if (ptr->wType == QDnsLookup::SRV) { - QDnsServiceRecord record; - record.d->name = name; - record.d->target = QUrl::fromAce((char*)ptr->Data.Srv.pNameTarget); - record.d->port = ptr->Data.Srv.wPort; - record.d->priority = ptr->Data.Srv.wPriority; - record.d->timeToLive = ptr->dwTtl; - record.d->weight = ptr->Data.Srv.wWeight; - reply->serviceRecords.append(record); - } else if (ptr->wType == QDnsLookup::TXT) { - QDnsTextRecord record; - record.d->name = name; - record.d->timeToLive = ptr->dwTtl; - for (unsigned int i = 0; i < ptr->Data.Txt.dwStringCount; ++i) { - record.d->values << QByteArray((char*)ptr->Data.Txt.pStringArray[i]); - } - reply->textRecords.append(record); - } - } - - DnsRecordListFree(dns_records, DnsFreeRecordList); -} - -QT_END_NAMESPACE diff --git a/src/client/QXmppInvokable.cpp b/src/client/QXmppInvokable.cpp index 39b92f85..e44b6296 100644 --- a/src/client/QXmppInvokable.cpp +++ b/src/client/QXmppInvokable.cpp @@ -58,11 +58,7 @@ QVariant QXmppInvokable::dispatch( const QByteArray & method, const QList< QVari const char *typeName = metaObject()->method(idx).typeName(); int resultType = QMetaType::type(typeName); -#if QT_VERSION >= 0x050000 void *result = QMetaType::create(resultType, 0); -#else - void *result = QMetaType::construct(resultType, 0); -#endif QGenericReturnArgument ret( typeName, result ); QList<QGenericArgument> genericArgs; @@ -115,11 +111,7 @@ void QXmppInvokable::buildMethodHash( ) int methodCount = metaObject()->methodCount (); for( int idx = 0; idx < methodCount; ++idx) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QByteArray signature = metaObject()->method(idx).methodSignature(); -#else - QByteArray signature = metaObject()->method(idx).signature(); -#endif m_methodHash[signature.left(signature.indexOf('('))] = idx; // qDebug() << metaObject()->method(idx).parameterTypes(); } @@ -133,11 +125,7 @@ QStringList QXmppInvokable::interfaces( ) const { if( metaObject()->method(idx).methodType() == QMetaMethod::Slot ) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QByteArray signature = metaObject()->method(idx).methodSignature(); -#else - QByteArray signature = metaObject()->method(idx).signature(); -#endif results << signature.left(signature.indexOf('(')); } } diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp index 552f6f07..b5c7052a 100644 --- a/src/client/QXmppOutgoingClient.cpp +++ b/src/client/QXmppOutgoingClient.cpp @@ -26,11 +26,7 @@ #include <QNetworkProxy> #include <QSslSocket> #include <QUrl> -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include <QDnsLookup> -#else -#include "qdnslookup.h" -#endif #include "QXmppConfiguration.h" #include "QXmppConstants_p.h" @@ -144,10 +140,8 @@ void QXmppOutgoingClientPrivate::connectToHost(const QString &host, quint16 port // respect proxy q->socket()->setProxy(config.networkProxy()); -#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) // set the name the SSL certificate should match q->socket()->setPeerVerifyName(config.domain()); -#endif // connect to host const QXmppConfiguration::StreamSecurityMode localSecurity = q->configuration().streamSecurityMode(); diff --git a/src/client/client.pri b/src/client/client.pri deleted file mode 100644 index bfb3094f..00000000 --- a/src/client/client.pri +++ /dev/null @@ -1,46 +0,0 @@ -# Header files -INSTALL_HEADERS += \ - client/QXmppArchiveManager.h \ - client/QXmppBookmarkManager.h \ - client/QXmppCallManager.h \ - client/QXmppCarbonManager.h \ - client/QXmppClient.h \ - client/QXmppClientExtension.h \ - client/QXmppConfiguration.h \ - client/QXmppDiscoveryManager.h \ - client/QXmppEntityTimeManager.h \ - client/QXmppInvokable.h \ - client/QXmppMamManager.h \ - client/QXmppMessageReceiptManager.h \ - client/QXmppMucManager.h \ - client/QXmppOutgoingClient.h \ - client/QXmppRemoteMethod.h \ - client/QXmppRosterManager.h \ - client/QXmppRpcManager.h \ - client/QXmppTransferManager.h \ - client/QXmppTransferManager_p.h \ - client/QXmppVCardManager.h \ - client/QXmppVersionManager.h - -# Source files -SOURCES += \ - client/QXmppDiscoveryManager.cpp \ - client/QXmppArchiveManager.cpp \ - client/QXmppBookmarkManager.cpp \ - client/QXmppCallManager.cpp \ - client/QXmppCarbonManager.cpp \ - client/QXmppClient.cpp \ - client/QXmppClientExtension.cpp \ - client/QXmppConfiguration.cpp \ - client/QXmppEntityTimeManager.cpp \ - client/QXmppInvokable.cpp \ - client/QXmppMamManager.cpp \ - client/QXmppMessageReceiptManager.cpp \ - client/QXmppMucManager.cpp \ - client/QXmppOutgoingClient.cpp \ - client/QXmppRemoteMethod.cpp \ - client/QXmppRosterManager.cpp \ - client/QXmppRpcManager.cpp \ - client/QXmppTransferManager.cpp \ - client/QXmppVCardManager.cpp \ - client/QXmppVersionManager.cpp diff --git a/src/server/QXmppOutgoingServer.cpp b/src/server/QXmppOutgoingServer.cpp index 3855da4d..2da1628a 100644 --- a/src/server/QXmppOutgoingServer.cpp +++ b/src/server/QXmppOutgoingServer.cpp @@ -25,11 +25,7 @@ #include <QSslKey> #include <QSslSocket> #include <QTimer> -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include <QDnsLookup> -#else -#include "qdnslookup.h" -#endif #include "QXmppConstants_p.h" #include "QXmppDialback.h" @@ -137,10 +133,8 @@ void QXmppOutgoingServer::_q_dnsLookupFinished() port = 5269; } -#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)) // set the name the SSL certificate should match socket()->setPeerVerifyName(d->remoteDomain); -#endif // connect to server info(QString("Connecting to %1:%2").arg(host, QString::number(port))); diff --git a/src/server/QXmppServer.cpp b/src/server/QXmppServer.cpp index 13be2169..73a7415e 100644 --- a/src/server/QXmppServer.cpp +++ b/src/server/QXmppServer.cpp @@ -891,11 +891,7 @@ QXmppSslServer::~QXmppSslServer() delete d; } -#if QT_VERSION < 0x050000 -void QXmppSslServer::incomingConnection(int socketDescriptor) -#else void QXmppSslServer::incomingConnection(qintptr socketDescriptor) -#endif { QSslSocket *socket = new QSslSocket; if (!socket->setSocketDescriptor(socketDescriptor)) { diff --git a/src/server/QXmppServer.h b/src/server/QXmppServer.h index f6866f92..992f0c4a 100644 --- a/src/server/QXmppServer.h +++ b/src/server/QXmppServer.h @@ -143,11 +143,7 @@ signals: void newConnection(QSslSocket *socket); private: - #if QT_VERSION < 0x050000 - void incomingConnection(int socketDescriptor); - #else - void incomingConnection(qintptr socketDescriptor); - #endif + void incomingConnection(qintptr socketDescriptor) override; QXmppSslServerPrivate * const d; }; diff --git a/src/base/QXmppGlobal.cpp b/src/server/QXmppServerPlugin.cpp index a0d9ce89..d723ee4d 100644 --- a/src/base/QXmppGlobal.cpp +++ b/src/server/QXmppServerPlugin.cpp @@ -1,8 +1,8 @@ /* - * Copyright (C) 2008-2014 The QXmpp developers + * Copyright (C) 2017 The QXmpp developers * * Author: - * Manjeet Dahiya + * Niels Ole Salscheider * * Source: * https://github.com/qxmpp-project/qxmpp @@ -21,14 +21,5 @@ * */ - -#include "QXmppGlobal.h" - -QString QXmppVersion() -{ - return QString("%1.%2.%3").arg( - QString::number((QXMPP_VERSION >> 16) & 0xff), - QString::number((QXMPP_VERSION >> 8) & 0xff), - QString::number(QXMPP_VERSION & 0xff)); -} +#include "QXmppServerPlugin.h" diff --git a/src/server/server.pri b/src/server/server.pri deleted file mode 100644 index 718119a8..00000000 --- a/src/server/server.pri +++ /dev/null @@ -1,20 +0,0 @@ -# Headers -INSTALL_HEADERS += \ - server/QXmppDialback.h \ - server/QXmppIncomingClient.h \ - server/QXmppIncomingServer.h \ - server/QXmppOutgoingServer.h \ - server/QXmppPasswordChecker.h \ - server/QXmppServer.h \ - server/QXmppServerExtension.h \ - server/QXmppServerPlugin.h - -# Source files -SOURCES += \ - server/QXmppDialback.cpp \ - server/QXmppIncomingClient.cpp \ - server/QXmppIncomingServer.cpp \ - server/QXmppOutgoingServer.cpp \ - server/QXmppPasswordChecker.cpp \ - server/QXmppServer.cpp \ - server/QXmppServerExtension.cpp diff --git a/src/src.pro b/src/src.pro deleted file mode 100644 index 6d4aa331..00000000 --- a/src/src.pro +++ /dev/null @@ -1,42 +0,0 @@ -include(../qxmpp.pri) - -QT -= gui - -TEMPLATE = lib - -CONFIG += $$QXMPP_LIBRARY_TYPE -DEFINES += QXMPP_BUILD -DEFINES += $$QXMPP_INTERNAL_DEFINES -INCLUDEPATH += $$QXMPP_INCLUDEPATH $$QXMPP_INTERNAL_INCLUDES -LIBS += $$QXMPP_INTERNAL_LIBS - -# Target definition -TARGET = $$QXMPP_LIBRARY_NAME -VERSION = $$QXMPP_VERSION -win32 { - DESTDIR = $$OUT_PWD -} - -include(base/base.pri) -include(client/client.pri) -include(server/server.pri) - -HEADERS += $$INSTALL_HEADERS - -# Installation -headers.files = $$INSTALL_HEADERS -headers.path = $$PREFIX/include/qxmpp -target.path = $$PREFIX/$$LIBDIR -INSTALLS += headers target - -# pkg-config support -CONFIG += create_pc create_prl no_install_prl -QMAKE_PKGCONFIG_DESTDIR = pkgconfig -QMAKE_PKGCONFIG_LIBDIR = $$target.path -QMAKE_PKGCONFIG_INCDIR = $$headers.path -equals(QXMPP_LIBRARY_TYPE,staticlib) { - QMAKE_PKGCONFIG_CFLAGS = -DQXMPP_STATIC -} else { - QMAKE_PKGCONFIG_CFLAGS = -DQXMPP_SHARED -} -unix:QMAKE_CLEAN += -r pkgconfig lib$${TARGET}.prl diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..64bd58d7 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,51 @@ +include_directories(.) + +find_package(Qt5 REQUIRED COMPONENTS Test) + +macro(add_simple_test TEST_NAME) + add_executable(tst_${TEST_NAME} ${TEST_NAME}/tst_${TEST_NAME}.cpp) + add_test(tst_${TEST_NAME} tst_${TEST_NAME}) + target_link_libraries(tst_${TEST_NAME} Qt5::Test qxmpp) +endmacro() + +include_directories(${PROJECT_SOURCE_DIR}/src/base) +include_directories(${PROJECT_SOURCE_DIR}/src/client) +include_directories(${PROJECT_SOURCE_DIR}/src/server) +include_directories(${PROJECT_BINARY_DIR}/src/base) + +add_simple_test(qxmpparchiveiq) +add_simple_test(qxmppbindiq) +add_simple_test(qxmppcallmanager) +add_simple_test(qxmppcarbonmanager) +add_simple_test(qxmppcodec) +add_simple_test(qxmppdataform) +add_simple_test(qxmppdiscoveryiq) +add_simple_test(qxmppentitytimeiq) +add_simple_test(qxmppiceconnection) +add_simple_test(qxmppiq) +add_simple_test(qxmppjingleiq) +add_simple_test(qxmppmammanager) +add_simple_test(qxmppmessage) +add_simple_test(qxmppnonsaslauthiq) +add_simple_test(qxmpppresence) +add_simple_test(qxmpppubsubiq) +add_simple_test(qxmppregisteriq) +add_simple_test(qxmppresultset) +add_simple_test(qxmpprosteriq) +add_simple_test(qxmpprpciq) +add_simple_test(qxmpprtcppacket) +add_simple_test(qxmpprtppacket) +add_simple_test(qxmppsasl) +add_simple_test(qxmppserver) +add_simple_test(qxmppsessioniq) +add_simple_test(qxmppsocks) +add_simple_test(qxmppstanza) +add_simple_test(qxmppstreamfeatures) +add_simple_test(qxmppstreaminitiationiq) +add_simple_test(qxmppstunmessage) +add_simple_test(qxmppvcardiq) +add_simple_test(qxmppversioniq) + +add_subdirectory(qxmpptransfermanager) +add_subdirectory(qxmpputils) + diff --git a/tests/qxmpparchiveiq/qxmpparchiveiq.pro b/tests/qxmpparchiveiq/qxmpparchiveiq.pro deleted file mode 100644 index 53b38e14..00000000 --- a/tests/qxmpparchiveiq/qxmpparchiveiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpparchiveiq -SOURCES += tst_qxmpparchiveiq.cpp diff --git a/tests/qxmppbindiq/qxmppbindiq.pro b/tests/qxmppbindiq/qxmppbindiq.pro deleted file mode 100644 index 8e5d580f..00000000 --- a/tests/qxmppbindiq/qxmppbindiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppbindiq -SOURCES += tst_qxmppbindiq.cpp diff --git a/tests/qxmppcallmanager/qxmppcallmanager.pro b/tests/qxmppcallmanager/qxmppcallmanager.pro deleted file mode 100644 index 27465093..00000000 --- a/tests/qxmppcallmanager/qxmppcallmanager.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppcallmanager -SOURCES += tst_qxmppcallmanager.cpp diff --git a/tests/qxmppcarbonmanager/qxmppcarbonmanager.pro b/tests/qxmppcarbonmanager/qxmppcarbonmanager.pro deleted file mode 100644 index 7f118000..00000000 --- a/tests/qxmppcarbonmanager/qxmppcarbonmanager.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppcarbonmanager -SOURCES += tst_qxmppcarbonmanager.cpp diff --git a/tests/qxmppcodec/qxmppcodec.pro b/tests/qxmppcodec/qxmppcodec.pro deleted file mode 100644 index 28fc1031..00000000 --- a/tests/qxmppcodec/qxmppcodec.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppcodec -SOURCES += tst_qxmppcodec.cpp diff --git a/tests/qxmppdataform/qxmppdataform.pro b/tests/qxmppdataform/qxmppdataform.pro deleted file mode 100644 index ab92935a..00000000 --- a/tests/qxmppdataform/qxmppdataform.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppdataform -SOURCES += tst_qxmppdataform.cpp diff --git a/tests/qxmppdiscoveryiq/qxmppdiscoveryiq.pro b/tests/qxmppdiscoveryiq/qxmppdiscoveryiq.pro deleted file mode 100644 index 01016e8c..00000000 --- a/tests/qxmppdiscoveryiq/qxmppdiscoveryiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppdiscoveryiq -SOURCES += tst_qxmppdiscoveryiq.cpp diff --git a/tests/qxmppentitytimeiq/qxmppentitytimeiq.pro b/tests/qxmppentitytimeiq/qxmppentitytimeiq.pro deleted file mode 100644 index c6b6e91c..00000000 --- a/tests/qxmppentitytimeiq/qxmppentitytimeiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppentitytimeiq -SOURCES += tst_qxmppentitytimeiq.cpp diff --git a/tests/qxmppiceconnection/qxmppiceconnection.pro b/tests/qxmppiceconnection/qxmppiceconnection.pro deleted file mode 100644 index 5f2eaeb9..00000000 --- a/tests/qxmppiceconnection/qxmppiceconnection.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppiceconnection -SOURCES += tst_qxmppiceconnection.cpp diff --git a/tests/qxmppiq/qxmppiq.pro b/tests/qxmppiq/qxmppiq.pro deleted file mode 100644 index 5a2e162a..00000000 --- a/tests/qxmppiq/qxmppiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppiq -SOURCES += tst_qxmppiq.cpp diff --git a/tests/qxmppjingleiq/qxmppjingleiq.pro b/tests/qxmppjingleiq/qxmppjingleiq.pro deleted file mode 100644 index 9518df55..00000000 --- a/tests/qxmppjingleiq/qxmppjingleiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppjingleiq -SOURCES += tst_qxmppjingleiq.cpp diff --git a/tests/qxmppmammanager/qxmppmammanager.pro b/tests/qxmppmammanager/qxmppmammanager.pro deleted file mode 100644 index 685ea4ee..00000000 --- a/tests/qxmppmammanager/qxmppmammanager.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppmammanager -SOURCES += tst_qxmppmammanager.cpp diff --git a/tests/qxmppmessage/qxmppmessage.pro b/tests/qxmppmessage/qxmppmessage.pro deleted file mode 100644 index 3ab73fc9..00000000 --- a/tests/qxmppmessage/qxmppmessage.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppmessage -SOURCES += tst_qxmppmessage.cpp diff --git a/tests/qxmppnonsaslauthiq/qxmppnonsaslauthiq.pro b/tests/qxmppnonsaslauthiq/qxmppnonsaslauthiq.pro deleted file mode 100644 index 29cf99e9..00000000 --- a/tests/qxmppnonsaslauthiq/qxmppnonsaslauthiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppnonsaslauthiq -SOURCES += tst_qxmppnonsaslauthiq.cpp diff --git a/tests/qxmpppresence/qxmpppresence.pro b/tests/qxmpppresence/qxmpppresence.pro deleted file mode 100644 index 222054a6..00000000 --- a/tests/qxmpppresence/qxmpppresence.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpppresence -SOURCES += tst_qxmpppresence.cpp diff --git a/tests/qxmpppubsubiq/qxmpppubsubiq.pro b/tests/qxmpppubsubiq/qxmpppubsubiq.pro deleted file mode 100644 index 0847c919..00000000 --- a/tests/qxmpppubsubiq/qxmpppubsubiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpppubsubiq -SOURCES += tst_qxmpppubsubiq.cpp diff --git a/tests/qxmppregisteriq/qxmppregisteriq.pro b/tests/qxmppregisteriq/qxmppregisteriq.pro deleted file mode 100644 index 4a2b98f5..00000000 --- a/tests/qxmppregisteriq/qxmppregisteriq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppregisteriq -SOURCES += tst_qxmppregisteriq.cpp diff --git a/tests/qxmppresultset/qxmppresultset.pro b/tests/qxmppresultset/qxmppresultset.pro deleted file mode 100644 index f3b394d5..00000000 --- a/tests/qxmppresultset/qxmppresultset.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppresultset -SOURCES += tst_qxmppresultset.cpp diff --git a/tests/qxmpprosteriq/qxmpprosteriq.pro b/tests/qxmpprosteriq/qxmpprosteriq.pro deleted file mode 100644 index 94828f4f..00000000 --- a/tests/qxmpprosteriq/qxmpprosteriq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpprosteriq -SOURCES += tst_qxmpprosteriq.cpp diff --git a/tests/qxmpprpciq/qxmpprpciq.pro b/tests/qxmpprpciq/qxmpprpciq.pro deleted file mode 100644 index e818b0a3..00000000 --- a/tests/qxmpprpciq/qxmpprpciq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpprpciq -SOURCES += tst_qxmpprpciq.cpp diff --git a/tests/qxmpprtcppacket/qxmpprtcppacket.pro b/tests/qxmpprtcppacket/qxmpprtcppacket.pro deleted file mode 100644 index a20db449..00000000 --- a/tests/qxmpprtcppacket/qxmpprtcppacket.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpprtcppacket -SOURCES += tst_qxmpprtcppacket.cpp diff --git a/tests/qxmpprtppacket/qxmpprtppacket.pro b/tests/qxmpprtppacket/qxmpprtppacket.pro deleted file mode 100644 index afd4d804..00000000 --- a/tests/qxmpprtppacket/qxmpprtppacket.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpprtppacket -SOURCES += tst_qxmpprtppacket.cpp diff --git a/tests/qxmppsasl/qxmppsasl.pro b/tests/qxmppsasl/qxmppsasl.pro deleted file mode 100644 index d5720c2f..00000000 --- a/tests/qxmppsasl/qxmppsasl.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppsasl -SOURCES += tst_qxmppsasl.cpp diff --git a/tests/qxmppsasl/tst_qxmppsasl.cpp b/tests/qxmppsasl/tst_qxmppsasl.cpp index abaff3fc..4f029f84 100644 --- a/tests/qxmppsasl/tst_qxmppsasl.cpp +++ b/tests/qxmppsasl/tst_qxmppsasl.cpp @@ -268,7 +268,7 @@ void tst_QXmppSasl::testClientFacebook() // challenge response QVERIFY(client->respond(QByteArray("version=1&method=auth.xmpp_login&nonce=AA4EFEE16F2AB64B131EEFFE6EACDDB8"), response)); - QCOMPARE(response, QByteArray("access_token=abcdefghijlkmno&api_key=123456789012345&call_id=&method=auth.xmpp_login&nonce=AA4EFEE16F2AB64B131EEFFE6EACDDB8&v=1.0")); + QCOMPARE(response, QByteArray("access_token=abcdefghijlkmno&api_key=123456789012345&call_id&method=auth.xmpp_login&nonce=AA4EFEE16F2AB64B131EEFFE6EACDDB8&v=1.0")); // any further step is an error QVERIFY(!client->respond(QByteArray(), response)); diff --git a/tests/qxmppserver/qxmppserver.pro b/tests/qxmppserver/qxmppserver.pro deleted file mode 100644 index 1ddd94a6..00000000 --- a/tests/qxmppserver/qxmppserver.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppserver -SOURCES += tst_qxmppserver.cpp diff --git a/tests/qxmppsessioniq/qxmppsessioniq.pro b/tests/qxmppsessioniq/qxmppsessioniq.pro deleted file mode 100644 index 7156defb..00000000 --- a/tests/qxmppsessioniq/qxmppsessioniq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppsessioniq -SOURCES += tst_qxmppsessioniq.cpp diff --git a/tests/qxmppsocks/qxmppsocks.pro b/tests/qxmppsocks/qxmppsocks.pro deleted file mode 100644 index fed3fa2e..00000000 --- a/tests/qxmppsocks/qxmppsocks.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppsocks -SOURCES += tst_qxmppsocks.cpp diff --git a/tests/qxmppstanza/qxmppstanza.pro b/tests/qxmppstanza/qxmppstanza.pro deleted file mode 100644 index a43df6ed..00000000 --- a/tests/qxmppstanza/qxmppstanza.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppstanza -SOURCES += tst_qxmppstanza.cpp diff --git a/tests/qxmppstreamfeatures/qxmppstreamfeatures.pro b/tests/qxmppstreamfeatures/qxmppstreamfeatures.pro deleted file mode 100644 index 62b50008..00000000 --- a/tests/qxmppstreamfeatures/qxmppstreamfeatures.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppstreamfeatures -SOURCES += tst_qxmppstreamfeatures.cpp diff --git a/tests/qxmppstreaminitiationiq/qxmppstreaminitiationiq.pro b/tests/qxmppstreaminitiationiq/qxmppstreaminitiationiq.pro deleted file mode 100644 index d19f5c41..00000000 --- a/tests/qxmppstreaminitiationiq/qxmppstreaminitiationiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppstreaminitiationiq -SOURCES += tst_qxmppstreaminitiationiq.cpp diff --git a/tests/qxmppstunmessage/qxmppstunmessage.pro b/tests/qxmppstunmessage/qxmppstunmessage.pro deleted file mode 100644 index 64fbbf6e..00000000 --- a/tests/qxmppstunmessage/qxmppstunmessage.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppstunmessage -SOURCES += tst_qxmppstunmessage.cpp diff --git a/tests/qxmpptransfermanager/CMakeLists.txt b/tests/qxmpptransfermanager/CMakeLists.txt new file mode 100644 index 00000000..f6f2c99d --- /dev/null +++ b/tests/qxmpptransfermanager/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(tst_qxmpptransfermanager tst_qxmpptransfermanager.cpp tst_qxmpptransfermanager.qrc) +add_test(tst_qxmpptransfermanager tst_qxmpptransfermanager) +target_link_libraries(tst_qxmpptransfermanager Qt5::Test qxmpp) diff --git a/tests/qxmpptransfermanager/qxmpptransfermanager.pro b/tests/qxmpptransfermanager/qxmpptransfermanager.pro deleted file mode 100644 index 325daa09..00000000 --- a/tests/qxmpptransfermanager/qxmpptransfermanager.pro +++ /dev/null @@ -1,4 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpptransfermanager -RESOURCES += tst_qxmpptransfermanager.qrc -SOURCES += tst_qxmpptransfermanager.cpp diff --git a/tests/qxmpputils/CMakeLists.txt b/tests/qxmpputils/CMakeLists.txt new file mode 100644 index 00000000..fbab1e64 --- /dev/null +++ b/tests/qxmpputils/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(tst_qxmpputils tst_qxmpputils.cpp tst_qxmpputils.qrc) +add_test(tst_qxmpputils tst_qxmpputils) +target_link_libraries(tst_qxmpputils Qt5::Test qxmpp) diff --git a/tests/qxmpputils/qxmpputils.pro b/tests/qxmpputils/qxmpputils.pro deleted file mode 100644 index 70c1b9bf..00000000 --- a/tests/qxmpputils/qxmpputils.pro +++ /dev/null @@ -1,4 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmpputils -RESOURCES += tst_qxmpputils.qrc -SOURCES += tst_qxmpputils.cpp diff --git a/tests/qxmpputils/tst_qxmpputils.cpp b/tests/qxmpputils/tst_qxmpputils.cpp index b2359d57..6a3958f0 100644 --- a/tests/qxmpputils/tst_qxmpputils.cpp +++ b/tests/qxmpputils/tst_qxmpputils.cpp @@ -35,7 +35,6 @@ private slots: void testHmac(); void testJid(); void testMime(); - void testLibVersion(); void testTimezoneOffset(); }; @@ -112,11 +111,6 @@ void tst_QXmppUtils::testMime() } #endif -void tst_QXmppUtils::testLibVersion() -{ - QCOMPARE(QXmppVersion(), QString("0.9.3")); -} - void tst_QXmppUtils::testTimezoneOffset() { // parsing diff --git a/tests/qxmppvcardiq/qxmppvcardiq.pro b/tests/qxmppvcardiq/qxmppvcardiq.pro deleted file mode 100644 index ca5081e6..00000000 --- a/tests/qxmppvcardiq/qxmppvcardiq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppvcardiq -SOURCES += tst_qxmppvcardiq.cpp diff --git a/tests/qxmppversioniq/qxmppversioniq.pro b/tests/qxmppversioniq/qxmppversioniq.pro deleted file mode 100644 index f018fe01..00000000 --- a/tests/qxmppversioniq/qxmppversioniq.pro +++ /dev/null @@ -1,3 +0,0 @@ -include(../tests.pri) -TARGET = tst_qxmppversioniq -SOURCES += tst_qxmppversioniq.cpp diff --git a/tests/tests.pri b/tests/tests.pri deleted file mode 100644 index 364d28bb..00000000 --- a/tests/tests.pri +++ /dev/null @@ -1,14 +0,0 @@ -include(../qxmpp.pri) - -QT -= gui -QT += testlib -CONFIG -= app_bundle -CONFIG += testcase - -QMAKE_LIBDIR += ../../src -QMAKE_RPATHDIR += $$OUT_PWD/../../src -INCLUDEPATH += $$PWD $$QXMPP_INCLUDEPATH -LIBS += $$QXMPP_LIBS - -# do not install testcases -target.CONFIG += no_default_install diff --git a/tests/tests.pro b/tests/tests.pro deleted file mode 100644 index 987ac7ee..00000000 --- a/tests/tests.pro +++ /dev/null @@ -1,39 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = \ - qxmpparchiveiq \ - qxmppbindiq \ - qxmppcallmanager \ - qxmppcarbonmanager \ - qxmppdataform \ - qxmppdiscoveryiq \ - qxmppentitytimeiq \ - qxmppiceconnection \ - qxmppiq \ - qxmppjingleiq \ - qxmppmammanager \ - qxmppmessage \ - qxmppnonsaslauthiq \ - qxmpppresence \ - qxmpppubsubiq \ - qxmppregisteriq \ - qxmppresultset \ - qxmpprosteriq \ - qxmpprpciq \ - qxmpprtcppacket \ - qxmpprtppacket \ - qxmppserver \ - qxmppsessioniq \ - qxmppsocks \ - qxmppstanza \ - qxmppstreamfeatures \ - qxmppstunmessage \ - qxmpptransfermanager \ - qxmpputils \ - qxmppvcardiq \ - qxmppversioniq - -!isEmpty(QXMPP_AUTOTEST_INTERNAL) { - SUBDIRS += qxmppcodec - SUBDIRS += qxmppsasl - SUBDIRS += qxmppstreaminitiationiq -} diff --git a/tests/travis/build-and-test b/tests/travis/build-and-test index 3d6ad4cd..64957ba6 100755 --- a/tests/travis/build-and-test +++ b/tests/travis/build-and-test @@ -1,43 +1,23 @@ #!/bin/sh set -e -QMAKE_ARGS="" - -if [ -n "$CC" ]; then - QMAKE_ARGS="$QMAKE_ARGS QMAKE_CC=$CC" -fi - - -if [ -n "$CXX" ]; then - QMAKE_ARGS="$QMAKE_ARGS QMAKE_CXX=$CXX" -fi - -if [ "$CXX" = "clang++" ]; then - QMAKE_ARGS="$QMAKE_ARGS QMAKE_LINK=clang++" - QMAKE_ARGS="$QMAKE_ARGS QMAKE_LINK_SHLIB=clang++" -fi +CMAKE_ARGS="-DBUILD_TESTS:BOOL=True" case "$CONFIG" in full*) - QMAKE_ARGS="$QMAKE_ARGS QXMPP_USE_DOXYGEN=1 QXMPP_USE_OPUS=1 QXMPP_USE_SPEEX=1 QXMPP_USE_THEORA=1 QXMPP_USE_VPX=1" + CMAKE_ARGS="-DBUILD_DOCUMENTATION:BOOL=True -DBUILD_EXAMPLES:BOOL=True -DWITH_OPUS:BOOL=True -DWITH_SPEEX:BOOL=True -DWITH_THEORA:BOOL=True -DWITH_VPX:BOOL=True" ;; esac case "$CONFIG" in *debug*) - QMAKE_ARGS="$QMAKE_ARGS CONFIG+=debug" - ;; -esac - -case "$CONFIG" in -*static*) - QMAKE_ARGS="$QMAKE_ARGS QXMPP_LIBRARY_TYPE=staticlib" + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=Debug" ;; esac # compile -qmake $QMAKE_ARGS -make VERBOSE=1 +cmake $CMAKE_ARGS +make # run tests -make check +make test diff --git a/tests/travis/install-build-depends b/tests/travis/install-build-depends index 2ea9a282..f735d816 100755 --- a/tests/travis/install-build-depends +++ b/tests/travis/install-build-depends @@ -2,12 +2,7 @@ set -e sudo apt-get update -qq - -if [ "$QT_SELECT" = "qt4" ]; then - sudo apt-get install -qq libqt4-dev -else - sudo apt-get install -qq qtbase5-dev -fi +sudo apt-get install -qq qtbase5-dev cmake case "$CONFIG" in full*) |
