Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:raulgs:gtk2_win
mingw32-libjreen
update-to-latest-git-fixes.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File update-to-latest-git-fixes.patch of Package mingw32-libjreen
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b248b1..512fd35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -CMAKE_MINIMUM_REQUIRED( VERSION 2.6 ) -PROJECT(Jreen) +cmake_minimum_required(VERSION 2.8.6) +project(Jreen) -LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_JREEN_VERSION_MAJOR 1 CACHE INT "Major Jreen version number" FORCE) set(CMAKE_JREEN_VERSION_MINOR 1 CACHE INT "Minor Jreen version number" FORCE) @@ -9,156 +9,139 @@ set(CMAKE_JREEN_VERSION_PATCH 1 CACHE INT "Release Jreen version number" FORCE) set(CMAKE_JREEN_VERSION_STRING "${CMAKE_JREEN_VERSION_MAJOR}.${CMAKE_JREEN_VERSION_MINOR}.${CMAKE_JREEN_VERSION_PATCH}" CACHE STRING "Jreen version string" FORCE) # Search for source and headers in source directory (non-recursive) -FILE(GLOB_RECURSE SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") -FILE(GLOB_RECURSE HDR "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") +file(GLOB_RECURSE SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") -# Require QT 4.6 -SET(QT_MIN_VERSION "4.6.0") +option(JREEN_FORCE_QT4 "Force using of Qt4 in Jreen" off) -# Search for QT4 -FIND_PACKAGE(Qt4 COMPONENTS QtCore QtNetwork REQUIRED) -INCLUDE(${QT_USE_FILE}) -INCLUDE(jreenMacros) -FIND_PACKAGE(QCA2 REQUIRED) +if(NOT JREEN_FORCE_QT4) + find_package(Qt5Core QUIET) +endif() + +if(Qt5Core_DIR) + find_package(Qt5Network QUIET) + message(STATUS "Found Qt5!") + + add_definitions("-DQT_DISABLE_DEPRECATED_BEFORE=0") + list(REMOVE_ITEM SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/sjdns.cpp") +else() + message(STATUS "Could not find Qt5, so let's use Qt4...") -if( JREEN_BUILD_INTERNAL ) - add_definitions( "-DJ_BUILD_INTERNAL" ) + find_package(Qt4 4.6.0 COMPONENTS QtCore QtNetwork REQUIRED) + + macro(qt5_use_modules) + endmacro() + + include(${QT_USE_FILE}) endif() -FIND_PACKAGE(PkgConfig) -#pkg_search_module(NICE nice) -#if(NOT NICE_FOUND) -# message(STATUS "Could not find nice library.") -#else(NOT NICE_FOUND) -# message(STATUS "Nice library is found.") -# include_directories(${NICE_INCLUDE_DIRS}) -# ADD_DEFINITIONS("-DJREEN_HAVE_NICE=1") -#endif(NOT NICE_FOUND) +if(JREEN_BUILD_INTERNAL) + add_definitions("-DJ_BUILD_INTERNAL") +endif() +find_package(PkgConfig) +find_package(GSASL REQUIRED) pkg_search_module(SPEEX speex) if(NOT SPEEX_FOUND) - message(STATUS "Could not find speex library.") -else(NOT SPEEX_FOUND) - message(STATUS "Speex library is found.") - include_directories(${SPEEX_INCLUDE_DIRS}) - ADD_DEFINITIONS("-DJREEN_HAVE_SPEEX=1") -endif(NOT SPEEX_FOUND) + message(STATUS "Could not find speex library.") +else() + message(STATUS "Speex library is found.") + include_directories(${SPEEX_INCLUDE_DIRS}) + add_definitions("-DJREEN_HAVE_SPEEX=1") +endif() # FindZLIB is broken on Ubuntu, so find the library using pkg-config if(LINUX) - find_package(PkgConfig) - pkg_search_module(ZLIB_PKGCONF REQUIRED zlib) - find_path(ZLIB_INCLUDE_DIR - NAMES zlib.h - PATHS ${ZLIB_PKGCONF_INCLUDE_DIRS} - ) - find_library(ZLIB_LIBRARIES - NAMES z - PATHS ${ZLIB_PKGCONF_LIBRARY_DIRS} - ) - if(NOT ZLIB_INCLUDE_DIR) - message(SEND_ERROR "Could not find zlib includes.") - endif(NOT ZLIB_INCLUDE_DIR) - if(NOT ZLIB_LIBRARIES) - message(SEND_ERROR "Could not find zlib library.") - endif(NOT ZLIB_LIBRARIES) - - + find_package(PkgConfig) + pkg_search_module(ZLIB_PKGCONF REQUIRED zlib) + + find_path(ZLIB_INCLUDE_DIR + NAMES zlib.h + PATHS ${ZLIB_PKGCONF_INCLUDE_DIRS} + ) + + find_library(ZLIB_LIBRARIES + NAMES z + PATHS ${ZLIB_PKGCONF_LIBRARY_DIRS} + ) + + if(NOT ZLIB_INCLUDE_DIR) + message(SEND_ERROR "Could not find zlib includes.") + endif(NOT ZLIB_INCLUDE_DIR) + + if(NOT ZLIB_LIBRARIES) + message(SEND_ERROR "Could not find zlib library.") + endif(NOT ZLIB_LIBRARIES) else() - find_package(ZLIB REQUIRED) + find_package(ZLIB REQUIRED) endif() -#add_subdirectory(3rdparty) - -#spike - # Add include directories -INCLUDE_DIRECTORIES(. - ${CMAKE_CURRENT_BINARY_DIR} - 3rdparty - ${QCA2_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR} +include_directories(. + ${CMAKE_CURRENT_BINARY_DIR} + 3rdparty + ${GSASL_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIR} ) LIST(APPEND SRC ${3RD_PARTY_SRC_C}) LIST(APPEND SRC ${3RD_PARTY_SRC}) -LIST(APPEND HDR ${3RD_PARTY_HDR}) # Ice support option(JREEN_USE_IRISICE "Use ICE from IRIS" OFF) if (JREEN_USE_IRISICE) - file(GLOB_RECURSE ICESUPPORT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/icesupport/*.cpp") - file(GLOB_RECURSE ICESUPPORT_SRC_C "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/icesupport/*.c") - file(GLOB_RECURSE ICESUPPORT_HDR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/icesupport/*.h") - list(APPEND SRC ${ICESUPPORT_SRC}) - list(APPEND SRC ${ICESUPPORT_SRC_C}) - list(APPEND HDR ${ICESUPPORT_HDR}) - add_definitions("-DHAVE_IRISICE") -endif() - -option(JREEN_USE_SIMPLESASL "Use SimpleSASL" ON) -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/simplesasl") - set(JREEN_USE_SIMPLESASL OFF) - message("Using cyrus sasl auth") -endif() -if(JREEN_USE_SIMPLESASL) - message("Using simple sasl auth instead cyrus sasl") - add_definitions("-DHAVE_SIMPLESASL") - file(GLOB_RECURSE SIMPLESASL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/simplesasl/*.cpp") - file(GLOB_RECURSE SIMPLESASL_SRC_C "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/simplesasl/*.c") - file(GLOB_RECURSE SIMPLESASL_HDR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/simplesasl/*.h") - list(APPEND SRC ${SIMPLESASL_SRC}) - list(APPEND SRC ${SIMPLESASL_SRC_C}) - list(APPEND HDR ${SIMPLESASL_HDR}) + file(GLOB_RECURSE ICESUPPORT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/icesupport/*.cpp") + file(GLOB_RECURSE ICESUPPORT_SRC_C "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/icesupport/*.c") + list(APPEND SRC ${ICESUPPORT_SRC}) + list(APPEND SRC ${ICESUPPORT_SRC_C}) + add_definitions("-DHAVE_IRISICE") endif() -option(JREEN_USE_SYSTEM_JDNS "Use system JDNS" OFF) -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns") - set(JREEN_USE_SYSTEM_JDNS ON) +if(NOT Qt5Core_DIR) + option(JREEN_USE_SYSTEM_JDNS "Use system JDNS" OFF) + + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns") + set(JREEN_USE_SYSTEM_JDNS ON) + endif() + + if(JREEN_USE_SYSTEM_JDNS) + # For Linux it was found already before at line 29 + if(NOT LINUX) + find_package(PkgConfig) + endif() + pkg_search_module(JDNS REQUIRED qjdns) + include_directories(${JDNS_INCLUDE_DIR}) + list(APPEND EXTRA_LIBS ${JDNS_LIBRARIES}) + else() + file(GLOB_RECURSE JDNS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns/*.cpp") + file(GLOB_RECURSE JDNS_SRC_C "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns/*.c") + list(APPEND SRC ${JDNS_SRC}) + list(APPEND SRC ${JDNS_SRC_C}) + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty") + endif() endif() -if(JREEN_USE_SYSTEM_JDNS) - # For Linux it was found already before at line 29 - if(NOT LINUX) - find_package(PkgConfig) - endif() - pkg_search_module(JDNS REQUIRED qjdns) - include_directories(${JDNS_INCLUDE_DIR}) - list(APPEND EXTRA_LIBS ${JDNS_LIBRARIES}) -else() - file(GLOB_RECURSE JDNS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns/*.cpp") - file(GLOB_RECURSE JDNS_SRC_C "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns/*.c") - file(GLOB_RECURSE JDNS_HDR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/jdns/*.h") - list(APPEND SRC ${JDNS_SRC}) - list(APPEND SRC ${JDNS_SRC_C}) - list(APPEND HDR ${JDNS_HDR}) - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty") -endif() - -# Generate moc files -JREEN_WRAP_CPP(MOC_SRC ${HDR}) # This project will generate library if(SYMBIAN) - set(JREEN_BUILD_TYPE STATIC) + set(JREEN_BUILD_TYPE STATIC) else() set(JREEN_BUILD_TYPE SHARED) endif() -ADD_LIBRARY(jreen ${JREEN_BUILD_TYPE} ${SRC} ${MOC_SRC} ${HDR} ) +ADD_LIBRARY(jreen ${JREEN_BUILD_TYPE} ${SRC} ${MOC_SRC}) #compiler flags #fixme add macro to clang if(CMAKE_COMPILER_IS_GNUCXX) - IF(SYMBIAN) + if(SYMBIAN) #disable stupid warnings ADD_DEFINITIONS("-w") - ELSE() + else() ADD_DEFINITIONS("-Wall -Wextra" ) #add -Werror - ENDIF() - if(NOT WIN32) + ENDif() + if(NOT WIN32) ADD_DEFINITIONS("-fvisibility=hidden" ) - endif(NOT WIN32) + endif(NOT WIN32) elseif(MSVC) ADD_DEFINITIONS("/W3" ) endif() @@ -171,14 +154,15 @@ set_target_properties(jreen PROPERTIES file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/jreen" ) file(GLOB_RECURSE JREEN_INCLUDE_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") + foreach(header ${JREEN_INCLUDE_HEADERS}) - if(NOT ${header} MATCHES ".*_p\\.h") - if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}") + if(NOT ${header} MATCHES ".*_p\\.h") + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}") file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}" "#include \"${CMAKE_CURRENT_SOURCE_DIR}/src/${header}\" " ) - endif(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}") + endif(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/include/jreen/${header}") get_filename_component(headerPath ${header} PATH) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/${header}" DESTINATION include/jreen/${headerPath} @@ -190,27 +174,24 @@ endforeach(header) set(JREEN_LIBRARIES jreen CACHE INTERNAL "" ) set(JREEN_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/include" CACHE INTERNAL "") -IF(WIN32) - LIST(APPEND EXTRA_LIBS ws2_32) -ENDIF() -#IF(NICE_FOUND) -# LIST(APPEND EXTRA_LIBS ${NICE_LIBRARIES}) -#ENDIF(NICE_FOUND) -IF(SPEEX_FOUND) - LIST(APPEND EXTRA_LIBS ${SPEEX_LIBRARIES}) -ENDIF(SPEEX_FOUND) - -# Link with Qt -#IF(SYMBIAN) -#ENDIF() - -JREEN_TARGET_LINK_LIBRARIES(jreen - ${QT_LIBRARIES} - ${QCA2_LIBRARIES} - ${ZLIB_LIBRARIES} - ${EXTRA_LIBS} +if(WIN32) + list(APPEND EXTRA_LIBS ws2_32) +endif() + +if(SPEEX_FOUND) + list(APPEND EXTRA_LIBS ${SPEEX_LIBRARIES} ) +endif() + +target_link_libraries(jreen + ${QT_LIBRARIES} + ${GSASL_LIBRARIES} + ${ZLIB_LIBRARIES} + ${EXTRA_LIBS} ) +set_target_properties(jreen PROPERTIES AUTOMOC TRUE) +qt5_use_modules(jreen Core Network) + # Install package config file if(NOT WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libjreen.pc.cmake @@ -219,7 +200,7 @@ if(NOT WIN32) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjreen.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig ) -endif(NOT WIN32) +endif() install( TARGETS jreen RUNTIME DESTINATION bin diff --git a/cmake/FindGSASL.cmake b/cmake/FindGSASL.cmake new file mode 100644 index 0000000..a80e24e --- /dev/null +++ b/cmake/FindGSASL.cmake @@ -0,0 +1,28 @@ +# - Try to find GSASL +# Find GSASL headers, libraries and the answer to all questions. +# +# GSASL_FOUND True if libgsasl got found +# GSASL_INCLUDE_DIRS Location of libgsasl headers +# GSASL_LIBRARIES List of libaries to use libgsasl +# +# Copyright (c) 2009 Nigmatullin Ruslan <euroelessar@gmail.com> +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +if( WIN32 ) + FIND_PATH( GSASL_INCLUDE_DIRS gsasl.h $ENV{INCLUDE} ) + FIND_LIBRARY( GSASL_LIBRARIES libgsasl libgsasl-7 libgsasl-8 $ENV{LIB} ) +else( ) + FIND_PACKAGE(PkgConfig) + PKG_SEARCH_MODULE(GSASL REQUIRED libgsasl) +endif( ) + +if( GSASL_LIBRARIES AND GSASL_INCLUDE_DIRS ) + message( STATUS "Found libgsasl: ${GSASL_LIBRARIES}" ) + set( GSASL_FOUND true ) +else( GSASL_LIBRARIES AND GSASL_INCLUDE_DIRS ) + message( STATUS "Could NOT find libgsasl" ) +endif( GSASL_LIBRARIES AND GSASL_INCLUDE_DIRS ) diff --git a/cmake/jreenMacros.cmake b/cmake/jreenMacros.cmake deleted file mode 100644 index 821bd3c..0000000 --- a/cmake/jreenMacros.cmake +++ /dev/null @@ -1,65 +0,0 @@ - - -if(SYMBIAN) - function(jreen_add_executable) - symbian_add_executable(${ARGN}) - endfunction() - function(jreen_target_link_libraries) - symbian_target_link_libraries(${ARGN}) - endfunction() -else(SYMBIAN) - function(jreen_add_executable) - add_executable(${ARGN}) - endfunction() - function(jreen_target_link_libraries) - target_link_libraries(${ARGN}) - endfunction() -endif(SYMBIAN) - -MACRO (JREEN_WRAP_CPP outfiles ) - # get include dirs - QT4_GET_MOC_FLAGS(moc_flags) - QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN}) - - FOREACH (it ${moc_files}) - GET_FILENAME_COMPONENT(_abs_FILE ${it} ABSOLUTE) - GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) - GET_FILENAME_COMPONENT(_basename ${it} NAME_WE) - - SET(_HAS_MOC false) - - IF(EXISTS ${_abs_PATH}/${_basename}.cpp) - SET(_header ${_abs_PATH}/${_basename}.cpp) - FILE(READ ${_header} _contents) - STRING(REGEX MATCHALL "# *include +[\">]moc_[^ ]+\\.cpp[\">]" _match "${_contents}") - STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match2 "${_contents}") - STRING(REGEX MATCHALL "Q_OBJECT" _match3 "${_contents}") - IF(_match) - SET(_HAS_MOC true) - FOREACH (_current_MOC_INC ${_match}) - STRING(REGEX MATCH "moc_[^ <\"]+\\.cpp" _current_MOC "${_current_MOC_INC}") - SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) - QT4_CREATE_MOC_COMMAND(${_abs_FILE} ${_moc} "${_moc_INCS}" "") - MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) - ENDFOREACH (_current_MOC_INC) - ENDIF() - IF(_match2) - FOREACH (_current_MOC_INC ${_match2}) - STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") - SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) - QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "") - MACRO_ADD_FILE_DEPENDENCIES(${_header} ${_moc}) - ENDFOREACH (_current_MOC_INC) - ENDIF() - ENDIF() - IF(NOT _HAS_MOC) - FILE(READ ${_abs_FILE} _contents) - STRING(REGEX MATCHALL "Q_OBJECT|Q_GADGET" _match2 "${_contents}") - IF(_match2) - QT4_MAKE_OUTPUT_FILE(${_abs_FILE} moc_ cpp outfile) - QT4_CREATE_MOC_COMMAND(${_abs_FILE} ${outfile} "${moc_flags}" "${moc_options}") - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDIF() - ENDIF() - ENDFOREACH(it) -ENDMACRO (JREEN_WRAP_CPP) diff --git a/src/abstractroster.cpp b/src/abstractroster.cpp index eac5d32..b829b99 100644 --- a/src/abstractroster.cpp +++ b/src/abstractroster.cpp @@ -221,7 +221,7 @@ void AbstractRoster::load() { Q_D(AbstractRoster); IQ iq(IQ::Get, JID(), d->client->getID()); - Logger::debug() << Q_FUNC_INFO << d->version; + jreenDebug() << Q_FUNC_INFO << d->version; iq.addExtension(new AbstractRosterQuery(d->version)); d->client->send(iq, this, SLOT(handleIQ(Jreen::IQ,int)), LoadRoster); } @@ -291,7 +291,7 @@ void AbstractRoster::handleIQ(const IQ &iq) d->version = roster->ver(); iq.accept(); foreach (const RosterItem::Ptr &item, roster->items()) { - Logger::debug() << "handle item" << item->jid(); + jreenDebug() << "handle item" << item->jid(); if(item->subscription() == RosterItem::Remove) { onItemRemoved(item->jid()); d->items.remove(item->jid()); @@ -340,7 +340,7 @@ void AbstractRoster::handleIQ(const IQ &iq, int context) break; case AddRosterItem: case RemoveRosterItem: { - Logger::debug() << "handle add/remove item" << (iq.subtype() == IQ::Error); + jreenDebug() << "handle add/remove item" << (iq.subtype() == IQ::Error); // IQ request = d->iqHash.take(iq.id()); // Q_ASSERT(request.subtype() != IQ::Invalid); // if(iq.subtype() == IQ::Error) diff --git a/src/abstractroster.h b/src/abstractroster.h index 602b3aa..6684b4b 100644 --- a/src/abstractroster.h +++ b/src/abstractroster.h @@ -25,8 +25,8 @@ // TODO: Create simple RosterManager for bots and simple applications -#ifndef ABSTRACTROSTER_H -#define ABSTRACTROSTER_H +#ifndef JREEN_ABSTRACTROSTER_H +#define JREEN_ABSTRACTROSTER_H #include <QSharedPointer> @@ -171,4 +171,4 @@ protected: } -#endif // ABSTRACTROSTER_H +#endif // JREEN_ABSTRACTROSTER_H diff --git a/src/abstractroster_p.h b/src/abstractroster_p.h index 8f7d283..e904fd1 100644 --- a/src/abstractroster_p.h +++ b/src/abstractroster_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ABSTRACTROSTER_P_H -#define ABSTRACTROSTER_P_H +#ifndef JREEN_ABSTRACTROSTER_P_H +#define JREEN_ABSTRACTROSTER_P_H #include "abstractroster.h" @@ -94,4 +94,4 @@ private: }; } -#endif // ABSTRACTROSTER_P_H +#endif // JREEN_ABSTRACTROSTER_P_H diff --git a/src/action_p.h b/src/action_p.h index 2cf38d0..990462e 100644 --- a/src/action_p.h +++ b/src/action_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ACTION_H -#define ACTION_H +#ifndef JREEN_ACTION_P_H +#define JREEN_ACTION_P_H #include <QObject> #include <QMap> @@ -51,4 +51,4 @@ private: } -#endif // ACTION_H +#endif // JREEN_ACTION_P_H diff --git a/src/activity.h b/src/activity.h index 2746ec8..7ada9c0 100644 --- a/src/activity.h +++ b/src/activity.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef ACTIVITY_H -#define ACTIVITY_H +#ifndef JREEN_ACTIVITY_H +#define JREEN_ACTIVITY_H #include "stanzaextension.h" namespace Jreen { @@ -148,4 +148,4 @@ private: } // namespace Jreen -#endif // ACTIVITY_H +#endif // JREEN_ACTIVITY_H diff --git a/src/activityfactory_p.h b/src/activityfactory_p.h index 7d1b685..5409b60 100644 --- a/src/activityfactory_p.h +++ b/src/activityfactory_p.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef ACTIVITYFACTORY_P_H -#define ACTIVITYFACTORY_P_H +#ifndef JREEN_ACTIVITYFACTORY_P_H +#define JREEN_ACTIVITYFACTORY_P_H #include "stanzaextension.h" #include "activity.h" @@ -60,4 +60,4 @@ private: } // namespace Jreen -#endif // ACTIVITYFACTORY_P_H +#endif // JREEN_ACTIVITYFACTORY_P_H diff --git a/src/attention.h b/src/attention.h index f8c0771..0bda1fd 100644 --- a/src/attention.h +++ b/src/attention.h @@ -22,8 +22,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef ATTENTION_H -#define ATTENTION_H +#ifndef JREEN_ATTENTION_H +#define JREEN_ATTENTION_H #include "stanzaextension.h" namespace Jreen { @@ -45,4 +45,4 @@ private: } // namespace Jreen -#endif // ATTENTION_H +#endif // JREEN_ATTENTION_H diff --git a/src/attentionfactory_p.h b/src/attentionfactory_p.h index 69e9ae9..e671c67 100644 --- a/src/attentionfactory_p.h +++ b/src/attentionfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ATTENTIONFACTORY_P_H -#define ATTENTIONFACTORY_P_H +#ifndef JREEN_ATTENTIONFACTORY_P_H +#define JREEN_ATTENTIONFACTORY_P_H #include "stanzaextension.h" #include "attention.h" @@ -46,4 +46,4 @@ public: } // namespace Jreen -#endif // ATTENTIONFACTORY_P_H +#endif // JREEN_ATTENTIONFACTORY_P_H diff --git a/src/bindfeature.cpp b/src/bindfeature.cpp index 44d9f51..ce9a20e 100644 --- a/src/bindfeature.cpp +++ b/src/bindfeature.cpp @@ -148,7 +148,7 @@ void BindFeature::reset() bool BindFeature::canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes) { Q_UNUSED(attributes); - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; return name == QLatin1String("bind") && uri == NS_BIND; } @@ -157,7 +157,7 @@ void BindFeature::handleStartElement(const QStringRef &name, const QStringRef &u Q_UNUSED(name); Q_UNUSED(uri); Q_UNUSED(attributes); - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; m_hasFeature = true; } diff --git a/src/bindfeature_p.h b/src/bindfeature_p.h index 5823edc..5f23e59 100644 --- a/src/bindfeature_p.h +++ b/src/bindfeature_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef BINDFEATURE_H -#define BINDFEATURE_H +#ifndef JREEN_BINDFEATURE_P_H +#define JREEN_BINDFEATURE_P_H #include "streamfeature_p.h" #include "stanzaextension.h" @@ -55,4 +55,4 @@ private: }; } -#endif // BINDFEATURE_H +#endif // JREEN_BINDFEATURE_P_H diff --git a/src/bookmark.h b/src/bookmark.h index e9d1d5f..9d26cbb 100644 --- a/src/bookmark.h +++ b/src/bookmark.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef BOOKMARK_H -#define BOOKMARK_H +#ifndef JREEN_BOOKMARK_H +#define JREEN_BOOKMARK_H #include "stanzaextension.h" #include "jid.h" @@ -108,4 +108,4 @@ private: } // namespace Jreen -#endif // BOOKMARK_H +#endif // JREEN_BOOKMARK_H diff --git a/src/bookmarkfactory_p.h b/src/bookmarkfactory_p.h index 1da0d53..35fa279 100644 --- a/src/bookmarkfactory_p.h +++ b/src/bookmarkfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef BOOKMARKFACTORY_H -#define BOOKMARKFACTORY_H +#ifndef JREEN_BOOKMARKFACTORY_P_H +#define JREEN_BOOKMARKFACTORY_P_H #include "bookmark.h" namespace Jreen { @@ -51,4 +51,4 @@ private: } // namespace Jreen -#endif // BOOKMARKFACTORY_H +#endif // JREEN_BOOKMARKFACTORY_P_H diff --git a/src/bookmarkstorage.cpp b/src/bookmarkstorage.cpp index a3bdeab..a563cf9 100644 --- a/src/bookmarkstorage.cpp +++ b/src/bookmarkstorage.cpp @@ -81,10 +81,10 @@ void BookmarkStorage::onResultReady(const Payload::Ptr &node, PrivateXml::Result result, const Error::Ptr &error) { Q_UNUSED(error); - Logger::debug() << "onResultReady"; + jreenDebug() << "onResultReady"; if(result == PrivateXml::RequestOk) { Bookmark *bookmark = se_cast<Bookmark*>(node.data()); - Logger::debug() << "received bookmarks" << bookmark << node.data(); + jreenDebug() << "received bookmarks" << bookmark << node.data(); if (bookmark) emit bookmarksReceived(node.staticCast<Bookmark>()); else diff --git a/src/bookmarkstorage.h b/src/bookmarkstorage.h index c0a2654..ad545da 100644 --- a/src/bookmarkstorage.h +++ b/src/bookmarkstorage.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef BOOKMARKSTORAGE_H -#define BOOKMARKSTORAGE_H +#ifndef JREEN_BOOKMARKSTORAGE_H +#define JREEN_BOOKMARKSTORAGE_H #include "bookmark.h" #include "privatexml.h" @@ -58,4 +58,4 @@ private: }; } -#endif // BOOKMARKSTORAGE_H +#endif // JREEN_BOOKMARKSTORAGE_H diff --git a/src/buffereddatastream.cpp b/src/buffereddatastream.cpp index 717ab77..2cf465d 100644 --- a/src/buffereddatastream.cpp +++ b/src/buffereddatastream.cpp @@ -93,7 +93,7 @@ void BufferedDataStream::incomingDataReady() int bytes = device()->bytesAvailable(); d->ensureSize(bytes); device()->read(d->buffer.data() + d->offset + d->len, bytes); -// Logger::debug("< \"%s\"", QByteArray(d->buffer.constData() + d->offset + d->len, bytes).constData()); +// jreenDebug("< \"%s\"", QByteArray(d->buffer.constData() + d->offset + d->len, bytes).constData()); d->len += bytes; emit readyRead(); } @@ -115,7 +115,7 @@ void BufferedDataStream::flush() foreach (XmlStreamHandler *handler, *d->handlers) handler->handleOutgoingData(d->outBuffer.constData(), d->outBuffer.size()); device()->write(d->outBuffer.constData(), d->outBuffer.size()); -// Logger::debug("> \"%s\"", d->outBuffer.constData()); +// jreenDebug("> \"%s\"", d->outBuffer.constData()); d->outBuffer.clear(); } @@ -123,7 +123,7 @@ qint64 BufferedDataStream::readData(char *data, qint64 maxlen) { Q_D(BufferedDataStream); int len = qMin<int>(maxlen, d->len); - qMemCopy(data, d->buffer.data() + d->offset, len); + memcpy(data, d->buffer.data() + d->offset, len); // foreach (XmlStreamHandler *handler, *d->handlers) // handler->handleIncomingData(d->buffer.data() + d->offset, len); if (maxlen < d->len) { diff --git a/src/buffereddatastream.h b/src/buffereddatastream.h index ee20550..11a4c4f 100644 --- a/src/buffereddatastream.h +++ b/src/buffereddatastream.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef BUFFEREDDATASTREAM_H -#define BUFFEREDDATASTREAM_H +#ifndef JREEN_BUFFEREDDATASTREAM_H +#define JREEN_BUFFEREDDATASTREAM_H #include "datastream.h" @@ -54,4 +54,4 @@ namespace Jreen }; } -#endif // BUFFEREDDATASTREAM_H +#endif // JREEN_BUFFEREDDATASTREAM_H diff --git a/src/capabilities.h b/src/capabilities.h index 05b5214..68125f7 100644 --- a/src/capabilities.h +++ b/src/capabilities.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef CAPABILITIES_H -#define CAPABILITIES_H +#ifndef JREEN_CAPABILITIES_H +#define JREEN_CAPABILITIES_H #include "stanzaextension.h" @@ -50,4 +50,4 @@ private: } -#endif // CAPABILITIES_H +#endif // JREEN_CAPABILITIES_H diff --git a/src/capabilitiesfactory_p.h b/src/capabilitiesfactory_p.h index b529fe2..e877e88 100644 --- a/src/capabilitiesfactory_p.h +++ b/src/capabilitiesfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef CAPABILITIESFACTORY_P_H -#define CAPABILITIESFACTORY_P_H +#ifndef JREEN_CAPABILITIESFACTORY_P_H +#define JREEN_CAPABILITIESFACTORY_P_H #include "stanzaextension.h" #include "capabilities.h" @@ -54,4 +54,4 @@ private: } // namespace Jreen -#endif // CAPABILITIESFACTORY_P_H +#endif // JREEN_CAPABILITIESFACTORY_P_H diff --git a/src/chatstate.h b/src/chatstate.h index 06df883..3f62ea5 100644 --- a/src/chatstate.h +++ b/src/chatstate.h @@ -22,8 +22,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef CHATSTATE_H -#define CHATSTATE_H +#ifndef JREEN_CHATSTATE_H +#define JREEN_CHATSTATE_H #include "stanzaextension.h" namespace Jreen { @@ -55,4 +55,4 @@ private: } // namespace Jreen Q_ENUMS(Jreen::ChatState::State) -#endif // CHATSTATE_H +#endif // JREEN_CHATSTATE_H diff --git a/src/chatstatefactory_p.h b/src/chatstatefactory_p.h index ad6558e..e21d0a4 100644 --- a/src/chatstatefactory_p.h +++ b/src/chatstatefactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef CHATSTATEFACTORY_P_H -#define CHATSTATEFACTORY_P_H +#ifndef JREEN_CHATSTATEFACTORY_P_H +#define JREEN_CHATSTATEFACTORY_P_H #include "stanzaextension.h" #include "chatstate.h" @@ -48,4 +48,4 @@ private: } // namespace Jreen -#endif // CHATSTATEFACTORY_P_H +#endif // JREEN_CHATSTATEFACTORY_P_H diff --git a/src/client.cpp b/src/client.cpp index 96630db..87af92b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -362,8 +362,8 @@ void Client::send(const Stanza &stanza) void Client::send(const Presence &pres) { Q_D(Client); - Logger::debug() << Q_FUNC_INFO << d->jid << d->conn << pres.priority(); - Logger::debug() << d->conn->isOpen(); + jreenDebug() << Q_FUNC_INFO << d->jid << d->conn << pres.priority(); + jreenDebug() << d->conn->isOpen(); if(!d->conn || !d->conn->isOpen() || !d->isConnected) return; if (StanzaPrivate::get(pres) == StanzaPrivate::get(d->presence)) { @@ -388,7 +388,7 @@ IQReply *Client::send(const IQ &iq) const_cast<StanzaPrivate*>(p)->id = getID(); } - Logger::debug() << "send iq to" << iq.to() << "from" << iq.from(); + jreenDebug() << "send iq to" << iq.to() << "from" << iq.from(); d->send(iq); if (iq.subtype() == IQ::Set || iq.subtype() == IQ::Get) { IQReply *reply = d->createIQReply(); @@ -410,7 +410,7 @@ void Client::send(const IQ &iq, QObject *handler, const char *member, int contex const_cast<StanzaPrivate*>(p)->id = getID(); } - Logger::debug() << "send iq to" << iq.to() << "from" << iq.from(); + jreenDebug() << "send iq to" << iq.to() << "from" << iq.from(); d->send(iq); if (iq.subtype() == IQ::Set || iq.subtype() == IQ::Get) { IQReply *reply = new IQTrack(handler, member, context, this); @@ -487,8 +487,10 @@ void Client::setPresence() void Client::setPresence(Presence::Type type, const QString &text, int priority) { Q_D(Client); - if(d->presence.subtype() == type || type == Presence::Error || type == Presence::Invalid || type == Presence::Probe) + if((d->presence.subtype() == type && d->presence.status() == text && d->presence.priority() == priority) + || type == Presence::Error || type == Presence::Invalid || type == Presence::Probe) { return; + } d->presence.setSubtype(type); d->presence.addStatus(text); d->presence.setPriority(priority); @@ -498,6 +500,7 @@ void Client::setPresence(Presence::Type type, const QString &text, int priority) void Client::connectToServer() { Q_D(Client); + if(!d->conn) setConnection(new TcpConnection(d->server, d->server_port)); @@ -549,7 +552,7 @@ void ClientPrivate::_q_iq_received(const IQ &iq, int context) serverIdentities = info->identities(); emit q_ptr->serverFeaturesReceived(serverFeatures); emit q_ptr->serverIdentitiesReceived(serverIdentities); - Logger::debug() << serverFeatures; + jreenDebug() << serverFeatures; } } @@ -616,7 +619,7 @@ void Client::handleIQ(const IQ &iq) void Client::handleMessage(const Message &message) { - Logger::debug() << "Handle message" << message.from(); + jreenDebug() << "Handle message" << message.from(); emit messageReceived(message); } diff --git a/src/client.h b/src/client.h index a8ee8ee..2c567fb 100644 --- a/src/client.h +++ b/src/client.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef CLIENT_H -#define CLIENT_H +#ifndef JREEN_CLIENT_H +#define JREEN_CLIENT_H #include <QObject> #include <QSet> @@ -176,4 +176,4 @@ private: } -#endif // CLIENT_H +#endif // JREEN_CLIENT_H diff --git a/src/client_p.h b/src/client_p.h index 5d632a5..2e252e2 100644 --- a/src/client_p.h +++ b/src/client_p.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef CLIENT_P_H -#define CLIENT_P_H +#ifndef JREEN_CLIENT_P_H +#define JREEN_CLIENT_P_H #include "logger.h" #include <QXmlStreamWriter> @@ -216,7 +216,7 @@ public: void _q_new_data() { QByteArray data = bufferedDevice->read(qMax(Q_INT64_C(0xffff), bufferedDevice->bytesAvailable())); // device->readAll(); - // Logger::debug() << "-" << data.size() << data; + // jreenDebug() << "-" << data.size() << data; parser->appendData(data); // parser->appendData(data); _q_read_more(); @@ -385,4 +385,4 @@ private: } -#endif // CLIENT_P_H +#endif // JREEN_CLIENT_P_H diff --git a/src/connection.cpp b/src/connection.cpp new file mode 100644 index 0000000..49620d3 --- /dev/null +++ b/src/connection.cpp @@ -0,0 +1,29 @@ +/**************************************************************************** +** +** Jreen +** +** Copyright © 2013 Ruslan Nigmatullin <euroelessar@yandex.ru> +** +***************************************************************************** +** +** $JREEN_BEGIN_LICENSE$ +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 2 of the License, or +** (at your option) any later version. +** +** This program 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 General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see http://www.gnu.org/licenses/. +** $JREEN_END_LICENSE$ +** +****************************************************************************/ + +// Force exporting of Jreen::Connection + +#include "connection.h" + diff --git a/src/connection.h b/src/connection.h index 84648ce..9001eb1 100644 --- a/src/connection.h +++ b/src/connection.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef CONNECTION_H -#define CONNECTION_H +#ifndef JREEN_CONNECTION_H +#define JREEN_CONNECTION_H #include <QIODevice> #include "jreen.h" @@ -106,4 +106,4 @@ signals: } -#endif // CONNECTION_H +#endif // JREEN_CONNECTION_H diff --git a/src/connectionbosh.cpp b/src/connectionbosh.cpp index 9a78b4b..c1044df 100644 --- a/src/connectionbosh.cpp +++ b/src/connectionbosh.cpp @@ -64,7 +64,7 @@ public: { QByteArray seed = Util::randomHash(); keys.clear(); - Logger::debug() << Q_FUNC_INFO << keyNum; + jreenDebug() << Q_FUNC_INFO << keyNum; for (int i = 0; i < keyNum; i++) { seed = QCryptographicHash::hash(seed, QCryptographicHash::Sha1).toHex(); keys.append(seed); @@ -84,7 +84,7 @@ void ConnectionBOSHPrivate::send(bool empty, bool header) QByteArray data = resultXml; resultBuffer.seek(0); resultXml.clear(); - Logger::debug() << Q_FUNC_INFO << data; + jreenDebug() << Q_FUNC_INFO << data; QNetworkRequest request(host); request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArray("text/xml; charset=utf-8")); @@ -222,9 +222,9 @@ qint64 ConnectionBOSH::readData(char *data, qint64 maxlen) qint64 ConnectionBOSH::writeData(const char *payloaddata, qint64 payloadlen) { - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; Q_D(ConnectionBOSH); - Logger::debug() << d->dataRequest << d->emptyRequest; + jreenDebug() << d->dataRequest << d->emptyRequest; if (d->dataRequest && payloadlen > 0) { d->payloads.append(payloaddata, payloadlen); return payloadlen; @@ -252,14 +252,14 @@ void ConnectionBOSH::onRequestFinished(QNetworkReply *reply) { Q_D(ConnectionBOSH); reply->deleteLater(); - Logger::debug() << Q_FUNC_INFO << reply->error() << reply->errorString(); + jreenDebug() << Q_FUNC_INFO << reply->error() << reply->errorString(); if (reply->error() != QNetworkReply::NoError) { // TODO: Implement return; } bool header = reply->property("header").toBool(); QByteArray data = reply->readAll(); - Logger::debug() << Q_FUNC_INFO << header << data; + jreenDebug() << Q_FUNC_INFO << header << data; d->reader.addData(data); // Hook for parsers invoked in eventloops, which are run inside parser if (d->depth != 0) diff --git a/src/connectionbosh.h b/src/connectionbosh.h index dd1fe9e..d78f41f 100644 --- a/src/connectionbosh.h +++ b/src/connectionbosh.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef CONNECTIONBOSH_H -#define CONNECTIONBOSH_H +#ifndef JREEN_CONNECTIONBOSH_H +#define JREEN_CONNECTIONBOSH_H #include "connection.h" #include "streamprocessor.h" @@ -63,4 +63,4 @@ private: }; } -#endif // CONNECTIONBOSH_H +#endif // JREEN_CONNECTIONBOSH_H diff --git a/src/dataform.h b/src/dataform.h index 6595c43..2bdc924 100644 --- a/src/dataform.h +++ b/src/dataform.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef DATAFORM_H -#define DATAFORM_H +#ifndef JREEN_DATAFORM_H +#define JREEN_DATAFORM_H #include "jid.h" #include "stanzaextension.h" @@ -403,4 +403,4 @@ Q_INLINE_TEMPLATE DataFormOptionContainer DataFormField::cast() const } -#endif // DATAFORM_H +#endif // JREEN_DATAFORM_H diff --git a/src/dataform_p.h b/src/dataform_p.h index 60531f4..9b2536e 100644 --- a/src/dataform_p.h +++ b/src/dataform_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef DATAFORM_P_H -#define DATAFORM_P_H +#ifndef JREEN_DATAFORM_P_H +#define JREEN_DATAFORM_P_H #include "dataform.h" #include <QVariant> @@ -79,4 +79,4 @@ namespace Jreen }; } -#endif // DATAFORM_P_H +#endif // JREEN_DATAFORM_P_H diff --git a/src/dataformfactory.cpp b/src/dataformfactory.cpp index 460a7e4..95a369c 100644 --- a/src/dataformfactory.cpp +++ b/src/dataformfactory.cpp @@ -257,7 +257,7 @@ public: if(m_state == AtOption) { m_optionParser.handleEndElement(name,uri); if(m_depth == 2) { - Logger::debug() << m_optionParser.create(); + jreenDebug() << m_optionParser.create(); m_options.append(m_optionParser.create()); } } else if(m_state == AtMedia) { diff --git a/src/dataformfactory_p.h b/src/dataformfactory_p.h index bf1a493..72dfc2f 100644 --- a/src/dataformfactory_p.h +++ b/src/dataformfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef DATAFORMFACTORY_P_H -#define DATAFORMFACTORY_P_H +#ifndef JREEN_DATAFORMFACTORY_P_H +#define JREEN_DATAFORMFACTORY_P_H #include "dataform_p.h" namespace Jreen { @@ -49,4 +49,4 @@ private: } // namespace Jreen -#endif // DATAFORMFACTORY_P_H +#endif // JREEN_DATAFORMFACTORY_P_H diff --git a/src/datastream.h b/src/datastream.h index 7bcff8b..97f1175 100644 --- a/src/datastream.h +++ b/src/datastream.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef DATASTREAM_H -#define DATASTREAM_H +#ifndef JREEN_DATASTREAM_H +#define JREEN_DATASTREAM_H #include <QIODevice> #include "jreen.h" @@ -49,4 +49,4 @@ private: } -#endif // DATASTREAM_H +#endif // JREEN_DATASTREAM_H diff --git a/src/delayeddelivery.h b/src/delayeddelivery.h index 4d2937a..7f7688a 100644 --- a/src/delayeddelivery.h +++ b/src/delayeddelivery.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef DELAYEDDELIVERY_H -#define DELAYEDDELIVERY_H +#ifndef JREEN_DELAYEDDELIVERY_H +#define JREEN_DELAYEDDELIVERY_H #include "stanzaextension.h" #include "jid.h" @@ -55,4 +55,4 @@ private: } -#endif // DELAYEDDELIVERY_H +#endif // JREEN_DELAYEDDELIVERY_H diff --git a/src/delayeddeliveryfactory_p.h b/src/delayeddeliveryfactory_p.h index ecf223b..383e37b 100644 --- a/src/delayeddeliveryfactory_p.h +++ b/src/delayeddeliveryfactory_p.h @@ -22,8 +22,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef DELAYEDDELIVERYFACTORY_H -#define DELAYEDDELIVERYFACTORY_H +#ifndef JREEN_DELAYEDDELIVERYFACTORY_P_H +#define JREEN_DELAYEDDELIVERYFACTORY_P_H #include "delayeddelivery.h" namespace Jreen @@ -48,4 +48,4 @@ private: }; } -#endif // DELAYEDDELIVERYFACTORY_H +#endif // JREEN_DELAYEDDELIVERYFACTORY_P_H diff --git a/src/directconnection.cpp b/src/directconnection.cpp index d09b5b2..77e6451 100644 --- a/src/directconnection.cpp +++ b/src/directconnection.cpp @@ -25,9 +25,12 @@ ****************************************************************************/ #include "directconnection_p.h" -#include <QSslSocket> -#include <QSslConfiguration> -#include <QSsl> + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +# include "sjdns_p.h" +#else +# include <QDnsLookup> +#endif #ifdef Q_OS_LINUX # include <sys/types.h> @@ -49,11 +52,7 @@ DirectConnectionPrivate::DirectConnectionPrivate(const QString &hn, int p, Direc void DirectConnectionPrivate::connectSocket() { - if (qobject_cast<QSslSocket*>(socket)) { - connect(socket, SIGNAL(encrypted()), parent, SIGNAL(connected())); - } else { - connect(socket, SIGNAL(connected()), parent, SIGNAL(connected())); - } + connect(socket, SIGNAL(connected()), parent, SIGNAL(connected())); connect(socket, SIGNAL(disconnected()), parent, SIGNAL(disconnected())); connect(socket, SIGNAL(readyRead()), parent, SIGNAL(readyRead())); connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), @@ -66,44 +65,52 @@ void DirectConnectionPrivate::connectSocket() void DirectConnectionPrivate::doLookup() { - Logger::debug() << "doLookup"; + jreenDebug() << "doLookup"; emit stateChanged(QAbstractSocket::HostLookupState); - if (SJDns::instance().isValid()) - SJDns::instance().doLookup(host_name, this, SLOT(lookupResultsReady())); - else - emit stateChanged(QAbstractSocket::UnconnectedState); + QDnsLookup *dns = new QDnsLookup(this); + connect(dns, SIGNAL(finished()), this, SLOT(lookupResultsReady())); + + dns->setType(QDnsLookup::SRV); + dns->setName(QString::fromLatin1("_xmpp-client._tcp." + QUrl::toAce(host_name))); + dns->lookup(); } void DirectConnectionPrivate::lookupResultsReady() { - const QJDns::Response *response = SJDns::instance().servers(host_name); + QDnsLookup *dns = qobject_cast<QDnsLookup*>(sender()); + dns->deleteLater(); + Q_ASSERT(dns); + + QList<QDnsServiceRecord> results = dns->serviceRecords(); dns_records.clear(); - if (!response || !response->answerRecords.size()) { + + if (results.isEmpty()) { Record record; record.host = host_name; dns_records << record; } else { - foreach(const QJDns::Record &qrecord, response->answerRecords) { + foreach (const QDnsServiceRecord &result, results) { Record record; - record.host = QUrl::fromAce(qrecord.name); + record.host = result.target(); // may be it's a reason of connection problems of some users if (record.host.endsWith(QLatin1Char('.'))) record.host.chop(1); - record.port = qrecord.port; - record.weight = qrecord.weight; - record.priority = qrecord.priority; + record.port = result.port(); + record.weight = result.weight(); + record.priority = result.priority(); dns_records << record; } } + Record &record = dns_records[0]; - Logger::debug() << "use:" << record.host << record.port; + jreenDebug() << "use:" << record.host << record.port; socket->connectToHost(record.host, record.port); } void DirectConnectionPrivate::stateChanged(QAbstractSocket::SocketState ss) { - Logger::debug() << ss; + jreenDebug() << Q_FUNC_INFO << socket_state << ss; if(socket_state == ss) return; @@ -113,21 +120,22 @@ void DirectConnectionPrivate::stateChanged(QAbstractSocket::SocketState ss) #if defined(Q_OS_LINUX) && !defined(Q_WS_MAEMO_5) && !defined(MEEGO_EDITION_HARMATTAN) if (qobject_cast<QTcpSocket*>(socket)) { int fd = socket->socketDescriptor(); - Q_ASSERT(fd != -1); - Logger::debug() << "Trying to set KeepAlive attributes to socket descriptor" << fd; if (fd != -1) { - socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); - int enableKeepAlive = 1; - Logger::debug() << setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &enableKeepAlive, sizeof(enableKeepAlive)); - - int maxIdle = 15; // seconds - Logger::debug() << setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle)); - - int count = 3; // send up to 3 keepalive packets out, then disconnect if no response - Logger::debug() << setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &count, sizeof(count)); - - int interval = 2; // send a keepalive packet out every 2 seconds (after the idle period) - Logger::debug() << setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &interval, sizeof(interval)); + jreenDebug() << "Trying to set KeepAlive attributes to socket descriptor" << fd; + if (fd != -1) { + socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); + int enableKeepAlive = 1; + jreenDebug() << setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &enableKeepAlive, sizeof(enableKeepAlive)); + + int maxIdle = 15; // seconds + jreenDebug() << setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle)); + + int count = 3; // send up to 3 keepalive packets out, then disconnect if no response + jreenDebug() << setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &count, sizeof(count)); + + int interval = 2; // send a keepalive packet out every 2 seconds (after the idle period) + jreenDebug() << setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &interval, sizeof(interval)); + } } } #endif @@ -142,8 +150,10 @@ void DirectConnectionPrivate::stateChanged(QAbstractSocket::SocketState ss) break; } - socket_state = ss; - emit parent->stateChanged(static_cast<Connection::SocketState>(ss)); + if (socket_state != socket->state()) { + socket_state = socket->state(); + emit parent->stateChanged(static_cast<Connection::SocketState>(socket_state)); + } } void DirectConnectionPrivate::error(QAbstractSocket::SocketError se) @@ -176,6 +186,7 @@ DirectConnection::~DirectConnection() bool DirectConnection::open() { Q_D(DirectConnection); + jreenDebug() << Q_FUNC_INFO << d->socket_state << d->socket->state(); if(d->socket_state != QAbstractSocket::UnconnectedState) { if(d->socket_state == QAbstractSocket::ListeningState) { d->socket_state = QAbstractSocket::ConnectedState; @@ -187,17 +198,9 @@ bool DirectConnection::open() if(d->do_lookup) { d->doLookup(); } else { - Logger::debug() << "connectToHost" << d->host_name << d->port; - Logger::debug() << "proxy" << d->socket->proxy().type() << d->socket->proxy().hostName() << d->socket->proxy().port(); - if (QSslSocket *socket = qobject_cast<QSslSocket*>(d->socket)) { - socket->setPeerVerifyMode(QSslSocket::VerifyNone); - QSslConfiguration conf = socket->sslConfiguration(); - conf.setProtocol(QSsl::TlsV1); - socket->setSslConfiguration(conf); - socket->connectToHostEncrypted(d->host_name, d->port); - } else { - d->socket->connectToHost(d->host_name, d->port); - } + jreenDebug() << "connectToHost" << d->host_name << d->port; + jreenDebug() << "proxy" << d->socket->proxy().type() << d->socket->proxy().hostName() << d->socket->proxy().port(); + d->socket->connectToHost(d->host_name, d->port); } return true; } @@ -247,6 +250,11 @@ Connection::SocketError DirectConnection::socketError() const return static_cast<SocketError>(d->socket_error); } +QAbstractSocket *DirectConnection::socket() const +{ + return d_func()->socket; +} + qint64 DirectConnection::readData(char *data, qint64 maxlen) { Q_D(DirectConnection); diff --git a/src/directconnection.h b/src/directconnection.h index 0c5ccf0..c3c0b0a 100644 --- a/src/directconnection.h +++ b/src/directconnection.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef DIRECTCONNECTION_H -#define DIRECTCONNECTION_H +#ifndef JREEN_DIRECTCONNECTION_H +#define JREEN_DIRECTCONNECTION_H #include "connection.h" @@ -55,6 +55,8 @@ public: SocketState socketState() const; SocketError socketError() const; + QAbstractSocket *socket() const; + signals: void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); @@ -71,4 +73,4 @@ protected: } -#endif // DIRECTCONNECTION_H +#endif // JREEN_DIRECTCONNECTION_H diff --git a/src/directconnection_p.h b/src/directconnection_p.h index 33c1e48..a82b6a7 100644 --- a/src/directconnection_p.h +++ b/src/directconnection_p.h @@ -23,15 +23,14 @@ ** ****************************************************************************/ -#ifndef DIRECTCONNECTION_P_H -#define DIRECTCONNECTION_P_H +#ifndef JREEN_DIRECTCONNECTION_P_H +#define JREEN_DIRECTCONNECTION_P_H #include <QSslSocket> #include <QHostAddress> #include <QNetworkProxy> #include "jreen.h" #include "directconnection.h" -#include "sjdns_p.h" #include "logger.h" #include <QUrl> @@ -73,4 +72,4 @@ public slots: } -#endif // DIRECTCONNECTION_P_H +#endif // JREEN_DIRECTCONNECTION_P_H diff --git a/src/disco.h b/src/disco.h index 382c380..02412ff 100644 --- a/src/disco.h +++ b/src/disco.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef DISCO_H -#define DISCO_H +#ifndef JREEN_DISCO_H +#define JREEN_DISCO_H #include <QObject> #include <QString> @@ -206,4 +206,4 @@ Q_DECLARE_METATYPE(Jreen::Disco::Item) Q_DECLARE_METATYPE(Jreen::Disco::ItemList) Q_DECLARE_OPERATORS_FOR_FLAGS(Jreen::Disco::Item::Actions) -#endif // DISCO_H +#endif // JREEN_DISCO_H diff --git a/src/disco_p.h b/src/disco_p.h index 52692e5..ff10b01 100644 --- a/src/disco_p.h +++ b/src/disco_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef DISCO_P_H -#define DISCO_P_H +#ifndef JREEN_DISCO_P_H +#define JREEN_DISCO_P_H #include "disco.h" #include "dataformfactory_p.h" @@ -88,4 +88,4 @@ private: } -#endif // DISCO_P_H +#endif // JREEN_DISCO_P_H diff --git a/src/entitytime.h b/src/entitytime.h index 7851e44..b1bd46f 100644 --- a/src/entitytime.h +++ b/src/entitytime.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ENTITYTIME_H -#define ENTITYTIME_H +#ifndef JREEN_ENTITYTIME_H +#define JREEN_ENTITYTIME_H #include "stanzaextension.h" #include <QDateTime> @@ -50,4 +50,4 @@ namespace Jreen }; } -#endif // ENTITYTIME_H +#endif // JREEN_ENTITYTIME_H diff --git a/src/entitytimefactory_p.h b/src/entitytimefactory_p.h index f57bbd9..f459962 100644 --- a/src/entitytimefactory_p.h +++ b/src/entitytimefactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ENTITYTIMEFACTORY_P_H -#define ENTITYTIMEFACTORY_P_H +#ifndef JREEN_ENTITYTIMEFACTORY_P_H +#define JREEN_ENTITYTIMEFACTORY_P_H #include "entitytime.h" @@ -50,4 +50,4 @@ namespace Jreen }; } -#endif // ENTITYTIMEFACTORY_P_H +#endif // JREEN_ENTITYTIMEFACTORY_P_H diff --git a/src/error.h b/src/error.h index 8f8c766..7491740 100644 --- a/src/error.h +++ b/src/error.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ERROR_H -#define ERROR_H +#ifndef JREEN_ERROR_H +#define JREEN_ERROR_H #include "stanzaextension.h" #include "langmap.h" @@ -170,4 +170,4 @@ private: } -#endif // ERROR_H +#endif // JREEN_ERROR_H diff --git a/src/errorfactory_p.h b/src/errorfactory_p.h index 8a03a82..119dee2 100644 --- a/src/errorfactory_p.h +++ b/src/errorfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ERRORFACTORY_P_H -#define ERRORFACTORY_P_H +#ifndef JREEN_ERRORFACTORY_P_H +#define JREEN_ERRORFACTORY_P_H #include "error.h" #include "stanzaextension.h" @@ -53,4 +53,4 @@ private: } // namespace Jreen -#endif // ERRORFACTORY_P_H +#endif // JREEN_ERRORFACTORY_P_H diff --git a/src/experimental/iristransport.h b/src/experimental/iristransport.h index 61fc0f8..a9fd018 100644 --- a/src/experimental/iristransport.h +++ b/src/experimental/iristransport.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JREEN_JINGLEICE_IRISTRANSPORT_H -#define JREEN_JINGLEICE_IRISTRANSPORT_H +#ifndef JREEN_IRISTRANSPORT_H +#define JREEN_IRISTRANSPORT_H #include "jingletransport.h" #include "3rdparty/icesupport/ice176.h" @@ -38,4 +38,4 @@ namespace JingleIce } // namespace JingleIce } // namespace Jreen -#endif // JREEN_JINGLEICE_IRISTRANSPORT_H +#endif // JREEN_IRISTRANSPORT_H diff --git a/src/experimental/jingle_p.h b/src/experimental/jingle_p.h index 9a4897a..cab4d1e 100644 --- a/src/experimental/jingle_p.h +++ b/src/experimental/jingle_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLE_H -#define JINGLE_H +#ifndef JREEN_JINGLE_P_H +#define JREEN_JINGLE_P_H #include "../stanzaextension.h" #include "../jid.h" @@ -105,4 +105,4 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(Jreen::Jingle::SendersType) -#endif // JINGLE_H +#endif // JREEN_JINGLE_P_H diff --git a/src/experimental/jingleaudiocontent.cpp b/src/experimental/jingleaudiocontent.cpp index 2555cfe..b5a4c75 100644 --- a/src/experimental/jingleaudiocontent.cpp +++ b/src/experimental/jingleaudiocontent.cpp @@ -135,9 +135,9 @@ void JingleAudioDevice::appendData(const QByteArray &data) qint64 JingleAudioDevice::readData(char *data, qint64 maxSize) { - qMemSet(data, 0, maxSize); + memset(data, 0, maxSize); qint64 size = qMin<qint64>(m_outputBuffer.size(), maxSize); - qMemCopy(data, m_outputBuffer.data(), size); + memcpy(data, m_outputBuffer.data(), size); m_outputBuffer.remove(0, size); return size; } @@ -158,15 +158,16 @@ qint64 JingleAudioDevice::writeData(const char *data, qint64 len) return len; } -static inline void init_factories(QList<JingleAudioCodecFactory*> &factories) +static QList<JingleAudioCodecFactory*> init_factories() { - Q_UNUSED(factories); + QList<JingleAudioCodecFactory*> factories; #ifdef JREEN_HAVE_SPEEX factories << new JingleSpeexCodecFactory; #endif + return factories; } -Q_GLOBAL_STATIC_WITH_INITIALIZER(QList<JingleAudioCodecFactory*>, factories, init_factories(*x)) +Q_GLOBAL_STATIC_WITH_ARGS(QList<JingleAudioCodecFactory*>, factories, (init_factories())) JingleAudioContent::JingleAudioContent(JingleSession *session) : JingleContent(session, *new JingleAudioContentPrivate(this)) @@ -260,7 +261,7 @@ void JingleAudioContentPrivate::send(int payload, const QByteArray &data) void JingleAudioContent::receive(int component, const QByteArray &receivedData) { if (component == JingleRTCP) { - Logger::debug() << Q_FUNC_INFO << receivedData.toHex(); + jreenDebug() << Q_FUNC_INFO << receivedData.toHex(); } if (component != JingleRTP) return; diff --git a/src/experimental/jingleaudiocontent.h b/src/experimental/jingleaudiocontent.h index 0ecdeec..cead45a 100644 --- a/src/experimental/jingleaudiocontent.h +++ b/src/experimental/jingleaudiocontent.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEAUDIOCONTENT_H -#define JINGLEAUDIOCONTENT_H +#ifndef JREEN_JINGLEAUDIOCONTENT_H +#define JREEN_JINGLEAUDIOCONTENT_H #include "jinglecontent.h" #include "jingleaudiopayload.h" @@ -82,4 +82,4 @@ public: Q_DECLARE_INTERFACE(Jreen::JingleAudioCodecFactory, "org.qutim.Jreen.Jingle.AudioCodecFactory") -#endif // JINGLEAUDIOCONTENT_H +#endif // JREEN_JINGLEAUDIOCONTENT_H diff --git a/src/experimental/jingleaudiocontent_p.h b/src/experimental/jingleaudiocontent_p.h index 65a3e05..d85a6cc 100644 --- a/src/experimental/jingleaudiocontent_p.h +++ b/src/experimental/jingleaudiocontent_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEAUDIOCONTENT_P_H -#define JINGLEAUDIOCONTENT_P_H +#ifndef JREEN_JINGLEAUDIOCONTENT_P_H +#define JREEN_JINGLEAUDIOCONTENT_P_H #include "jingleaudiocontent.h" #include "jingleaudiopayload_p.h" @@ -82,4 +82,4 @@ public: } -#endif // JINGLEAUDIOCONTENT_P_H +#endif // JREEN_JINGLEAUDIOCONTENT_P_H diff --git a/src/experimental/jingleaudiocontentfactory_p.h b/src/experimental/jingleaudiocontentfactory_p.h index 2a6332c..42515c9 100644 --- a/src/experimental/jingleaudiocontentfactory_p.h +++ b/src/experimental/jingleaudiocontentfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEAUDIOCONTENTFACTORY_P_H -#define JINGLEAUDIOCONTENTFACTORY_P_H +#ifndef JREEN_JINGLEAUDIOCONTENTFACTORY_P_H +#define JREEN_JINGLEAUDIOCONTENTFACTORY_P_H #include "jingleaudiocontent_p.h" #include "jingleaudiopayload.h" @@ -53,4 +53,4 @@ private: } -#endif // JINGLEAUDIOCONTENTFACTORY_P_H +#endif // JREEN_JINGLEAUDIOCONTENTFACTORY_P_H diff --git a/src/experimental/jingleaudiopayload.h b/src/experimental/jingleaudiopayload.h index 2c63ad7..0b25b0e 100644 --- a/src/experimental/jingleaudiopayload.h +++ b/src/experimental/jingleaudiopayload.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEAUDIOPAYLOAD_H -#define JINGLEAUDIOPAYLOAD_H +#ifndef JREEN_JINGLEAUDIOPAYLOAD_H +#define JREEN_JINGLEAUDIOPAYLOAD_H #include "../jreen.h" #include <QSharedDataPointer> @@ -67,4 +67,4 @@ private: } -#endif // JINGLEAUDIOPAYLOAD_H +#endif // JREEN_JINGLEAUDIOPAYLOAD_H diff --git a/src/experimental/jingleaudiopayload_p.h b/src/experimental/jingleaudiopayload_p.h index 9f44ef6..7d9b473 100644 --- a/src/experimental/jingleaudiopayload_p.h +++ b/src/experimental/jingleaudiopayload_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEAUDIOPAYLOAD_P_H -#define JINGLEAUDIOPAYLOAD_P_H +#ifndef JREEN_JINGLEAUDIOPAYLOAD_P_H +#define JREEN_JINGLEAUDIOPAYLOAD_P_H #include "jingleaudiopayload.h" #include <QMap> @@ -54,4 +54,4 @@ public: } -#endif // JINGLEAUDIOPAYLOAD_P_H +#endif // JREEN_JINGLEAUDIOPAYLOAD_P_H diff --git a/src/experimental/jinglecontent.cpp b/src/experimental/jinglecontent.cpp index a170377..a9c7fec 100644 --- a/src/experimental/jinglecontent.cpp +++ b/src/experimental/jinglecontent.cpp @@ -73,7 +73,7 @@ void JingleContentPrivate::_q_tryStateChanged(Jreen::JingleTransport::State stat void JingleContentPrivate::setTransport(JingleTransport *trueTransport) { transport = trueTransport; - Logger::debug() << Q_FUNC_INFO << transport; + jreenDebug() << Q_FUNC_INFO << transport; QObject::connect(transport, SIGNAL(received(int,QByteArray)), q_func(), SLOT(_q_received(int,QByteArray))); QObject::connect(transport, SIGNAL(stateChanged(Jreen::JingleTransport::State)), diff --git a/src/experimental/jinglecontent.h b/src/experimental/jinglecontent.h index 74fd70a..fd74312 100644 --- a/src/experimental/jinglecontent.h +++ b/src/experimental/jinglecontent.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLECONTENT_H -#define JINGLECONTENT_H +#ifndef JREEN_JINGLECONTENT_H +#define JREEN_JINGLECONTENT_H #include "../stanzaextension.h" #include "jingletransport.h" @@ -144,4 +144,4 @@ Q_INLINE_TEMPLATE bool JingleContentFactory<Extension>::canParse(const QStringRe } -#endif // JINGLECONTENT_H +#endif // JREEN_JINGLECONTENT_H diff --git a/src/experimental/jinglecontent_p.h b/src/experimental/jinglecontent_p.h index 78411af..d999d7e 100644 --- a/src/experimental/jinglecontent_p.h +++ b/src/experimental/jinglecontent_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLECONTENT_P_H -#define JINGLECONTENT_P_H +#ifndef JREEN_JINGLECONTENT_P_H +#define JREEN_JINGLECONTENT_P_H #include "jinglecontent.h" @@ -65,4 +65,4 @@ public: } -#endif // JINGLECONTENT_P_H +#endif // JREEN_JINGLECONTENT_P_H diff --git a/src/experimental/jinglefactory.cpp b/src/experimental/jinglefactory.cpp index 7d2c69d..43b2dbd 100644 --- a/src/experimental/jinglefactory.cpp +++ b/src/experimental/jinglefactory.cpp @@ -102,7 +102,7 @@ void JingleFactory::handleStartElement(const QStringRef &name, const QStringRef m_content->senders = Jingle::Both; } else if (m_depth == 3 && m_state == AtContent) { foreach (m_factory, m_client->factoriesByUri.values(uri.toString())) { - Logger::debug() << uri << Payload::payloadName(m_factory->payloadType()) + jreenDebug() << uri << Payload::payloadName(m_factory->payloadType()) << m_factory->canParse(name, uri, attributes); if (m_factory->canParse(name, uri, attributes)) break; @@ -115,7 +115,7 @@ void JingleFactory::handleStartElement(const QStringRef &name, const QStringRef m_state = AtDescription; else m_factory = 0; - Logger::debug() << name << uri << m_factory; + jreenDebug() << name << uri << m_factory; } if (m_factory) m_factory->handleStartElement(name, uri, attributes); @@ -174,7 +174,7 @@ void JingleFactory::serialize(Payload *obj, QXmlStreamWriter *writer) if (factory) factory->serialize(content.description.data(), writer); } else { - Logger::debug() << "No description"; + jreenDebug() << "No description"; } for (int j = 0; j < content.transports.size(); ++j) { Payload *payload = content.transports.at(j).data(); diff --git a/src/experimental/jinglefactory_p.h b/src/experimental/jinglefactory_p.h index df18735..82c8561 100644 --- a/src/experimental/jinglefactory_p.h +++ b/src/experimental/jinglefactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEFACTORY_P_H -#define JINGLEFACTORY_P_H +#ifndef JREEN_JINGLEFACTORY_P_H +#define JREEN_JINGLEFACTORY_P_H #include "jingle_p.h" #include "../client_p.h" @@ -59,4 +59,4 @@ private: } -#endif // JINGLEFACTORY_P_H +#endif // JREEN_JINGLEFACTORY_P_H diff --git a/src/experimental/jinglemanager.cpp b/src/experimental/jinglemanager.cpp index 7e9c915..d8d6ef7 100644 --- a/src/experimental/jinglemanager.cpp +++ b/src/experimental/jinglemanager.cpp @@ -65,7 +65,7 @@ void JingleManagerPrivate::_q_iqReceived(const Jreen::IQ &iq) Jingle::Ptr jingle = iq.payload<Jingle>(); if (!jingle) return; - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; iq.accept(); JingleSession *session = sessions.value(jingle->sid); if (session) { diff --git a/src/experimental/jinglemanager.h b/src/experimental/jinglemanager.h index 550ec06..fede95a 100644 --- a/src/experimental/jinglemanager.h +++ b/src/experimental/jinglemanager.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEMANAGER_H -#define JINGLEMANAGER_H +#ifndef JREEN_JINGLEMANAGER_H +#define JREEN_JINGLEMANAGER_H #include "../iq.h" @@ -60,4 +60,4 @@ protected: } -#endif // JINGLEMANAGER_H +#endif // JREEN_JINGLEMANAGER_H diff --git a/src/experimental/jinglemanager_p.h b/src/experimental/jinglemanager_p.h index 6206148..9f51f18 100644 --- a/src/experimental/jinglemanager_p.h +++ b/src/experimental/jinglemanager_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEMANAGER_P_H -#define JINGLEMANAGER_P_H +#ifndef JREEN_JINGLEMANAGER_P_H +#define JREEN_JINGLEMANAGER_P_H #include "jinglemanager.h" #include "jinglefactory_p.h" @@ -50,4 +50,4 @@ public: } -#endif // JINGLEMANAGER_P_H +#endif // JREEN_JINGLEMANAGER_P_H diff --git a/src/experimental/jinglesession.cpp b/src/experimental/jinglesession.cpp index 85e2476..44802a7 100644 --- a/src/experimental/jinglesession.cpp +++ b/src/experimental/jinglesession.cpp @@ -51,7 +51,7 @@ JingleSessionContent *JingleSessionPrivate::findContent(JingleContent *content) void JingleSessionPrivate::handle(const Jingle::Ptr &jingle) { - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; if (jingle->action == Jingle::SessionAccept) { foreach (const Jingle::Content &remoteContent, jingle->contents) { JingleSessionContent *content = findContent(remoteContent.name); diff --git a/src/experimental/jinglesession.h b/src/experimental/jinglesession.h index 50a9ec3..e92f20e 100644 --- a/src/experimental/jinglesession.h +++ b/src/experimental/jinglesession.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLESESSION_H -#define JINGLESESSION_H +#ifndef JREEN_JINGLESESSION_H +#define JREEN_JINGLESESSION_H #include "jinglecontent.h" #include "../stanzaextension.h" @@ -72,4 +72,4 @@ protected: } -#endif // JINGLESESSION_H +#endif // JREEN_JINGLESESSION_H diff --git a/src/experimental/jinglesession_p.h b/src/experimental/jinglesession_p.h index 93a3cf0..9197c3d 100644 --- a/src/experimental/jinglesession_p.h +++ b/src/experimental/jinglesession_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLESESSION_P_H -#define JINGLESESSION_P_H +#ifndef JREEN_JINGLESESSION_P_H +#define JREEN_JINGLESESSION_P_H #include "jinglesession.h" #include "jinglemanager_p.h" @@ -71,4 +71,4 @@ public: } -#endif // JINGLESESSION_P_H +#endif // JREEN_JINGLESESSION_P_H diff --git a/src/experimental/jinglespeexcodec_p.h b/src/experimental/jinglespeexcodec_p.h index 1b008ce..82693e4 100644 --- a/src/experimental/jinglespeexcodec_p.h +++ b/src/experimental/jinglespeexcodec_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#if !defined(JINGLESPEEXCODEC_P_H) && defined(JREEN_HAVE_SPEEX) -#define JINGLESPEEXCODEC_P_H +#if !defined(JREEN_JINGLESPEEXCODEC_P_H) && defined(JREEN_HAVE_SPEEX) +#define JREEN_JINGLESPEEXCODEC_P_H #include "jingleaudiocontent.h" #include <speex/speex.h> @@ -59,4 +59,4 @@ public: } -#endif // JINGLESPEEXCODEC_P_H +#endif // JREEN_JINGLESPEEXCODEC_P_H diff --git a/src/experimental/jingletransport.h b/src/experimental/jingletransport.h index 4269ab3..c3fd342 100644 --- a/src/experimental/jingletransport.h +++ b/src/experimental/jingletransport.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLETRANSPORT_H -#define JINGLETRANSPORT_H +#ifndef JREEN_JINGLETRANSPORT_H +#define JREEN_JINGLETRANSPORT_H #include "jinglemanager.h" #include "../stanzaextension.h" @@ -127,4 +127,4 @@ Q_INLINE_TEMPLATE bool JingleTransportFactory<Extension>::canParse(const QString } -#endif // JINGLETRANSPORT_H +#endif // JREEN_JINGLETRANSPORT_H diff --git a/src/experimental/jingletransportice.cpp b/src/experimental/jingletransportice.cpp index 3c78ed2..13e1b6c 100644 --- a/src/experimental/jingletransportice.cpp +++ b/src/experimental/jingletransportice.cpp @@ -130,7 +130,7 @@ void Transport::send(int component, const QByteArray &data) void Transport::setRemoteInfo(const JingleTransportInfo::Ptr &genericInfo, bool final) { Q_UNUSED(final); - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; TransportInfo::Ptr info = genericInfo.staticCast<TransportInfo>(); if (!info->ufrag.isEmpty()) m_ice->setPeerUfrag(info->ufrag); @@ -142,18 +142,18 @@ void Transport::setRemoteInfo(const JingleTransportInfo::Ptr &genericInfo, bool void Transport::onIceStarted() { - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; } void Transport::onIceError(XMPP::Ice176::Error error) { - Logger::debug() << Q_FUNC_INFO << error; + jreenDebug() << Q_FUNC_INFO << error; setState(Failed); } void Transport::onIceLocalCandidatesReady(const QList<XMPP::Ice176::Candidate> &candidates) { - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; TransportInfo::Ptr info = TransportInfo::Ptr::create(); info->candidates = candidates; info->ufrag = m_ice->localUfrag(); @@ -164,7 +164,7 @@ void Transport::onIceLocalCandidatesReady(const QList<XMPP::Ice176::Candidate> & void Transport::onIceComponentReady(int component) { m_ready.remove(component); - Logger::debug() << Q_FUNC_INFO << component; + jreenDebug() << Q_FUNC_INFO << component; if (m_ready.isEmpty()) setState(Connected); } @@ -261,8 +261,8 @@ void TransportFactory::serialize(Payload *obj, QXmlStreamWriter *writer) Payload::Ptr TransportFactory::createPayload() { - Logger::debug() << Q_FUNC_INFO << m_info->pwd << m_info->ufrag; - Logger::debug() << Q_FUNC_INFO << m_info->candidates.size(); + jreenDebug() << Q_FUNC_INFO << m_info->pwd << m_info->ufrag; + jreenDebug() << Q_FUNC_INFO << m_info->candidates.size(); Payload::Ptr result = m_info; m_info.clear(); return result; diff --git a/src/experimental/jingletransportice_p.h b/src/experimental/jingletransportice_p.h index e34b4fe..b1acfa6 100644 --- a/src/experimental/jingletransportice_p.h +++ b/src/experimental/jingletransportice_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JINGLEICE_H -#define JINGLEICE_H +#ifndef JREEN_JINGLETRANSPORTICE_P_H +#define JREEN_JINGLETRANSPORTICE_P_H #include "jingletransport.h" @@ -96,4 +96,4 @@ private: #endif // HAVE_IRISICE -#endif // JINGLEICE_H +#endif // JREEN_JINGLETRANSPORTICE_P_H diff --git a/src/iq.h b/src/iq.h index 589bb9b..0c148c9 100644 --- a/src/iq.h +++ b/src/iq.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef IQ_H -#define IQ_H +#ifndef JREEN_IQ_H +#define JREEN_IQ_H #include "stanza.h" @@ -62,4 +62,4 @@ public: } -#endif // IQ_H +#endif // JREEN_IQ_H diff --git a/src/iq_p.h b/src/iq_p.h index 6d921f6..53e71ae 100644 --- a/src/iq_p.h +++ b/src/iq_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef IQ_P_H -#define IQ_P_H +#ifndef JREEN_IQ_P_H +#define JREEN_IQ_P_H #include "iq.h" #include "stanza_p.h" @@ -56,4 +56,4 @@ public: }; } -#endif // IQ_P_H +#endif // JREEN_IQ_P_H diff --git a/src/iqfactory_p.h b/src/iqfactory_p.h index e5ea2a1..04e4d80 100644 --- a/src/iqfactory_p.h +++ b/src/iqfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef IQFACTORY_P_H -#define IQFACTORY_P_H +#ifndef JREEN_IQFACTORY_P_H +#define JREEN_IQFACTORY_P_H #include "stanzafactory_p.h" #include "iq.h" @@ -45,4 +45,4 @@ public: }; } -#endif // IQFACTORY_P_H +#endif // JREEN_IQFACTORY_P_H diff --git a/src/iqreply.h b/src/iqreply.h index 086cf11..ad8829c 100644 --- a/src/iqreply.h +++ b/src/iqreply.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef IQREPLY_H -#define IQREPLY_H +#ifndef JREEN_IQREPLY_H +#define JREEN_IQREPLY_H #include "jreen.h" @@ -56,4 +56,4 @@ protected: }; } -#endif // IQREPLY_H +#endif // JREEN_IQREPLY_H diff --git a/src/jid.h b/src/jid.h index b54c8aa..674960f 100644 --- a/src/jid.h +++ b/src/jid.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JID_H -#define JID_H +#ifndef JREEN_JID_H +#define JREEN_JID_H #include "jreen.h" #include <QSharedData> @@ -90,4 +90,4 @@ inline uint qHash(const Jreen::JID &jid) { return qHash(jid.full()); } Q_DECLARE_METATYPE(Jreen::JID) -#endif // JID_H +#endif // JREEN_JID_H diff --git a/src/jreen.h b/src/jreen.h index 3e1d670..35eaa8e 100644 --- a/src/jreen.h +++ b/src/jreen.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JREEN_H -#define JREEN_H +#ifndef JREEN_JREEN_H +#define JREEN_JREEN_H # ifndef __cplusplus # error "C++ is needed" @@ -55,6 +55,12 @@ # define JREEN_EXPORT # endif +#ifdef QT_DEPRECATED_SINCE +# define JREEN_QT_DEPRECATED_SINCE(a, b) QT_DEPRECATED_SINCE(a, b) +#else +# define QT_DEPRECATED_SINCE(a, b) false +#endif + # define J_PURE_SINGLETON(Class) \ public: \ @@ -116,4 +122,4 @@ namespace Jreen } -#endif // JREEN_H +#endif // JREEN_JREEN_H diff --git a/src/jstrings.h b/src/jstrings.h index c098396..8452adc 100644 --- a/src/jstrings.h +++ b/src/jstrings.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JSTRINGS_H -#define JSTRINGS_H +#ifndef JREEN_JSTRINGS_H +#define JREEN_JSTRINGS_H #include "jreen.h" @@ -85,4 +85,4 @@ Q_INLINE_TEMPLATE QString flagToStr(uint i, const char *(&strings)[N]) } -#endif // JSTRINGS_H +#endif // JREEN_JSTRINGS_H diff --git a/src/langmap.cpp b/src/langmap.cpp index cd6c2eb..d9fec60 100644 --- a/src/langmap.cpp +++ b/src/langmap.cpp @@ -30,7 +30,7 @@ namespace Jreen { -LangMapData LangMapData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), QString(), LangMapData::Base() }; +LangMapData LangMapData::shared_null = { 1, QString(), LangMapData::Base() }; void LangMapData::fillNode(QXmlStreamWriter *writer, const QString &name, const QString &uri) const { diff --git a/src/langmap.h b/src/langmap.h index 4fad840..87d3e2c 100644 --- a/src/langmap.h +++ b/src/langmap.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef LANGMAP_H -#define LANGMAP_H +#ifndef JREEN_LANGMAP_H +#define JREEN_LANGMAP_H #include <QStringList> #ifdef LANGMAP_USE_MAP @@ -45,7 +45,7 @@ struct JREEN_EXPORT LangMapData #else typedef QHash<QString,QString> Base; #endif - QBasicAtomicInt ref; + QAtomicInt ref; QString base; Base other; @@ -103,7 +103,11 @@ public: inline int size() const { return count(); } inline bool isEmpty() const { return count() == 0; } protected: - inline void detach() { if(d->ref != 1) detach_helper(); } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + inline void detach() { if (d->ref != 1) detach_helper(); } +#else + inline void detach() { if (d->ref.load() != 1) detach_helper(); } +#endif void detach_helper() { d->ref.deref(); @@ -197,4 +201,4 @@ inline int LangMap::count() const } -#endif // LANGMAP_H +#endif // JREEN_LANGMAP_H diff --git a/src/logger.cpp b/src/logger.cpp index c0f9706..c3b549d 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -28,6 +28,7 @@ namespace Jreen { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) || QT_DEPRECATED_SINCE(5, 0) Q_GLOBAL_STATIC(QList<QtMsgHandler>, handlers) Logger::Logger() @@ -59,5 +60,6 @@ void Logger::flushDebug(Debug::Stream *stream) foreach (QtMsgHandler handler, *handlers()) handler(stream->type, data); } +#endif } diff --git a/src/logger.h b/src/logger.h index 33b6847..466f6e5 100644 --- a/src/logger.h +++ b/src/logger.h @@ -23,16 +23,29 @@ ** ****************************************************************************/ -#ifndef LOGGER_H -#define LOGGER_H +#ifndef JREEN_LOGGER_H +#define JREEN_LOGGER_H -#include <QtCore/QDebug> +#include <QtDebug> #include "jreen.h" namespace Jreen { class Logger; +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +# define jreenDebug QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, "jreen").debug +# define jreenWarning QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, "jreen").warning +# define jreenCritical QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, "jreen").critical +# define jreenFatal QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, "jreen").critical +#else +# define jreenDebug Logger::debug +# define jreenWarning Logger::warning +# define jreenCritical Logger::critical +# define jreenFatal Logger::fatal +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) || QT_DEPRECATED_SINCE(5, 0) class JREEN_EXPORT Debug { struct Stream { @@ -66,6 +79,7 @@ public: static void addHandler(QtMsgHandler handler); static void removeHandler(QtMsgHandler handler); + static bool isNull(); private: @@ -100,7 +114,8 @@ Q_INLINE_TEMPLATE Debug &Debug::operator<<(T t) stream->debug << t; return *this; } +#endif } -#endif // LOGGER_H +#endif // JREEN_LOGGER_H diff --git a/src/message.h b/src/message.h index 78e8b16..e716a88 100644 --- a/src/message.h +++ b/src/message.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef MESSAGE_H -#define MESSAGE_H +#ifndef JREEN_MESSAGE_H +#define JREEN_MESSAGE_H #include "stanza.h" #include "delayeddelivery.h" @@ -70,4 +70,4 @@ public: } -#endif // MESSAGE_H +#endif // JREEN_MESSAGE_H diff --git a/src/message_p.h b/src/message_p.h index 904d143..97a48de 100644 --- a/src/message_p.h +++ b/src/message_p.h @@ -22,8 +22,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef MESSAGE_P_H -#define MESSAGE_P_H +#ifndef JREEN_MESSAGE_P_H +#define JREEN_MESSAGE_P_H #include "stanza_p.h" #include "langmap.h" @@ -44,4 +44,4 @@ public: } //namespace Jreen -#endif // MESSAGE_P_H +#endif // JREEN_MESSAGE_P_H diff --git a/src/messagefactory_p.h b/src/messagefactory_p.h index 62e72c3..86f4d86 100644 --- a/src/messagefactory_p.h +++ b/src/messagefactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef MESSAGEFACTORY_P_H -#define MESSAGEFACTORY_P_H +#ifndef JREEN_MESSAGEFACTORY_P_H +#define JREEN_MESSAGEFACTORY_P_H #include "stanzafactory_p.h" #include "message.h" @@ -49,4 +49,4 @@ private: } // namespace Jreen -#endif // MESSAGEFACTORY_P_H +#endif // JREEN_MESSAGEFACTORY_P_H diff --git a/src/messagesession.cpp b/src/messagesession.cpp index 1aa6b5b..059ec2f 100644 --- a/src/messagesession.cpp +++ b/src/messagesession.cpp @@ -202,9 +202,9 @@ MessageSession *MessageSessionManager::session(const JID &jid, Message::Type typ { Q_D(MessageSessionManager); QList<QPointer<MessageSession> > sessions = d->fullSessions.values(jid.full()); - Logger::debug() << "d->full_sessions" << d->fullSessions; + jreenDebug() << "d->full_sessions" << d->fullSessions; foreach(MessageSession *session, sessions) - Logger::debug() << "MessageSession" << (session ? session->jid() : JID()); + jreenDebug() << "MessageSession" << (session ? session->jid() : JID()); for(int i = 0; i < sessions.size(); i++) { if(sessions[i].isNull()) diff --git a/src/messagesession.h b/src/messagesession.h index a8b137f..f51ebcf 100644 --- a/src/messagesession.h +++ b/src/messagesession.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef MESSAGESESSION_H -#define MESSAGESESSION_H +#ifndef JREEN_MESSAGESESSION_H +#define JREEN_MESSAGESESSION_H #include "message.h" #include <QPointer> @@ -44,7 +44,7 @@ class Client; typedef QSharedPointer<Class> Ptr; \ static int staticFilterType() \ { \ - static QBasicAtomicInt filterType = Q_BASIC_ATOMIC_INITIALIZER(0); \ + static int filterType = 0; \ if (!filterType) { \ filterType = Jreen::Payload::registerPayloadType( #Class ); \ Class *useFullNameWithNamespaces = reinterpret_cast< ::Class* >(0); \ @@ -149,4 +149,4 @@ private: } -#endif // MESSAGESESSION_H +#endif // JREEN_MESSAGESESSION_H diff --git a/src/metacontactstorage.cpp b/src/metacontactstorage.cpp index 460c57f..04d083e 100644 --- a/src/metacontactstorage.cpp +++ b/src/metacontactstorage.cpp @@ -27,6 +27,7 @@ #include "metacontacts_p.h" #include "logger.h" #include "client.h" +#include <QPointer> namespace Jreen { @@ -117,7 +118,7 @@ class MetaContactStoragePrivate { public: Client *client; - QWeakPointer<PrivateXml> privateXml; + QPointer<PrivateXml> privateXml; }; MetaContactStorage::MetaContactStorage(Client *client) : @@ -157,10 +158,10 @@ void MetaContactStorage::storeMetaContacts(const MetaContactStorage::ItemList &i void MetaContactStorage::onResultReady(const Payload::Ptr &payload, PrivateXml::Result result, const Error::Ptr &error) { Q_UNUSED(error); - Logger::debug() << "onResultReady"; + jreenDebug() << "onResultReady"; if(result == PrivateXml::RequestOk) { MetaContacts *metacontacts = payload_cast<MetaContacts*>(payload.data()); - Logger::debug() << "received metacontacts" << metacontacts << payload.data(); + jreenDebug() << "received metacontacts" << metacontacts << payload.data(); if (metacontacts) emit metaContactsReceived(metacontacts->items); else diff --git a/src/mood.h b/src/mood.h index e28c02e..1af23ab 100644 --- a/src/mood.h +++ b/src/mood.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef MOOD_H -#define MOOD_H +#ifndef JREEN_MOOD_H +#define JREEN_MOOD_H #include "stanzaextension.h" namespace Jreen @@ -140,4 +140,4 @@ private: }; } // namespace Jreen -#endif // MOOD_H +#endif // JREEN_MOOD_H diff --git a/src/moodfactory_p.h b/src/moodfactory_p.h index 362421e..4ed2a88 100644 --- a/src/moodfactory_p.h +++ b/src/moodfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef MOODFACTORY_P_H -#define MOODFACTORY_P_H +#ifndef JREEN_MOODFACTORY_P_H +#define JREEN_MOODFACTORY_P_H #include "stanzaextension.h" #include "mood.h" #include "langmap.h" @@ -54,4 +54,4 @@ private: } // namespace Jreen -#endif // MOODFACTORY_P_H +#endif // JREEN_MOODFACTORY_P_H diff --git a/src/mucmessagesession_p.h b/src/mucmessagesession_p.h index e5a7bcb..31c09d9 100644 --- a/src/mucmessagesession_p.h +++ b/src/mucmessagesession_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef MUCMESSAGESESSION_P_H -#define MUCMESSAGESESSION_P_H +#ifndef JREEN_MUCMESSAGESESSION_P_H +#define JREEN_MUCMESSAGESESSION_P_H #include "messagesession.h" @@ -48,4 +48,4 @@ namespace Jreen }; } -#endif // MUCMESSAGESESSION_P_H +#endif // JREEN_MUCMESSAGESESSION_P_H diff --git a/src/mucroom.cpp b/src/mucroom.cpp index b2c136a..3247953 100644 --- a/src/mucroom.cpp +++ b/src/mucroom.cpp @@ -197,7 +197,7 @@ void MUCRoom::Item::setReason(const QString &reason) void MUCRoomPrivate::handlePresence(const Presence &pres) { Q_Q(MUCRoom); - Logger::debug() << "handle presence" << pres.from(); + jreenDebug() << "handle presence" << pres.from(); if (Error::Ptr e = pres.payload<Error>()) { startedJoining = false; emit q->error(e); @@ -390,7 +390,6 @@ void MUCRoom::leave(const QString &message) Q_D(MUCRoom); if (d->currentPresence.subtype() == Presence::Unavailable) return; - d->isJoined = false; Presence pres(Presence::Unavailable, d->jid, message); d->currentPresence = pres; d->client->send(pres); @@ -589,7 +588,7 @@ void MUCRoom::onDisconnected() { Q_D(MUCRoom); d->startedJoining = false; - if (d->currentPresence.subtype() != Presence::Unavailable) { + if (d->isJoined) { d->participantsHash.clear(); d->isJoined = false; emit leaved(); diff --git a/src/mucroom.h b/src/mucroom.h index 215816e..4789fbc 100644 --- a/src/mucroom.h +++ b/src/mucroom.h @@ -23,8 +23,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef MUCROOM_H -#define MUCROOM_H +#ifndef JREEN_MUCROOM_H +#define JREEN_MUCROOM_H #include <QObject> #include <QDateTime> @@ -174,4 +174,4 @@ protected: }; } -#endif // MUCROOM_H +#endif // JREEN_MUCROOM_H diff --git a/src/mucroom_p.h b/src/mucroom_p.h index 313992d..102a9c5 100644 --- a/src/mucroom_p.h +++ b/src/mucroom_p.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef MUCROOM_P_H -#define MUCROOM_P_H +#ifndef JREEN_MUCROOM_P_H +#define JREEN_MUCROOM_P_H #include "mucroom.h" #include "mucmessagesession_p.h" @@ -198,4 +198,4 @@ class MUCRoomOwnerQuery : public Payload }; } -#endif // MUCROOM_P_H +#endif // JREEN_MUCROOM_P_H diff --git a/src/mucroomfactory_p.h b/src/mucroomfactory_p.h index fa5a28b..0db47fc 100644 --- a/src/mucroomfactory_p.h +++ b/src/mucroomfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef MUCROOMFACTORY_P_H -#define MUCROOMFACTORY_P_H +#ifndef JREEN_MUCROOMFACTORY_P_H +#define JREEN_MUCROOMFACTORY_P_H #include "mucroom_p.h" #include "dataformfactory_p.h" @@ -120,4 +120,4 @@ private: QScopedPointer<MUCRoomOwnerQuery> m_query; }; } -#endif // MUCROOMFACTORY_P_H +#endif // JREEN_MUCROOMFACTORY_P_H diff --git a/src/nickname.h b/src/nickname.h index dc0a200..ec0530f 100644 --- a/src/nickname.h +++ b/src/nickname.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef NICKNAME_H -#define NICKNAME_H +#ifndef JREEN_NICKNAME_H +#define JREEN_NICKNAME_H #include "stanzaextension.h" @@ -47,4 +47,4 @@ private: } -#endif // NICKNAME_H +#endif // JREEN_NICKNAME_H diff --git a/src/nicknamefactory_p.h b/src/nicknamefactory_p.h index ba11e85..be5b544 100644 --- a/src/nicknamefactory_p.h +++ b/src/nicknamefactory_p.h @@ -22,8 +22,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef NICKNAMEFACTORY_H -#define NICKNAMEFACTORY_H +#ifndef JREEN_NICKNAMEFACTORY_P_H +#define JREEN_NICKNAMEFACTORY_P_H #include "stanzafactory_p.h" #include "nickname.h" @@ -49,4 +49,4 @@ private: } // namespace Jreen -#endif // NICKNAMEFACTORY_H +#endif // JREEN_NICKNAMEFACTORY_P_H diff --git a/src/nonsaslauth_p.h b/src/nonsaslauth_p.h index e371d49..85df774 100644 --- a/src/nonsaslauth_p.h +++ b/src/nonsaslauth_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef NONSASLAUTH_H -#define NONSASLAUTH_H +#ifndef JREEN_NONSASLAUTH_P_H +#define JREEN_NONSASLAUTH_P_H #include "streamfeature_p.h" #include "stanzaextension.h" @@ -76,4 +76,4 @@ private: } -#endif // NONSASLAUTH_H +#endif // JREEN_NONSASLAUTH_P_H diff --git a/src/parser.cpp b/src/parser.cpp index a59b891..a75cad4 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -248,7 +248,7 @@ void Parser::handleStartElement(const QStringRef &name, const QStringRef &uri, } foreach (XmlStreamParser *parser, d->parsers) parser->handleStartElement(name, uri, attributes); - // Logger::debug() << d->reader->tokenString() << d->depth << name; + // jreenDebug() << d->reader->tokenString() << d->depth << name; #ifdef PARSER_DEBUG_SPEED d->parsingTime += counter.elapsed(); #endif @@ -293,19 +293,19 @@ void Parser::handleEndElement(const QStringRef &name, const QStringRef &uri) d->totalParsingTime += d->parsingTime; int logicTime = counter.elapsed(); d->totalLogicTime += logicTime; - Logger::debug() << "Total parsing time:" << d->totalParsingTime << "ms"; - Logger::debug() << "Parsing time:" << d->parsingTime << "ms"; - Logger::debug() << "Total logic time:" << d->totalLogicTime << "ms"; - Logger::debug() << "Total IQ logic time:" << d->stanzaLogicTime[0] << "ms"; - Logger::debug() << "Total Presence logic time:" << d->stanzaLogicTime[1] << "ms"; - Logger::debug() << "Total Message logic time:" << d->stanzaLogicTime[2] << "ms"; - Logger::debug() << "Logic time:" << logicTime << "ms"; + jreenDebug() << "Total parsing time:" << d->totalParsingTime << "ms"; + jreenDebug() << "Parsing time:" << d->parsingTime << "ms"; + jreenDebug() << "Total logic time:" << d->totalLogicTime << "ms"; + jreenDebug() << "Total IQ logic time:" << d->stanzaLogicTime[0] << "ms"; + jreenDebug() << "Total Presence logic time:" << d->stanzaLogicTime[1] << "ms"; + jreenDebug() << "Total Message logic time:" << d->stanzaLogicTime[2] << "ms"; + jreenDebug() << "Logic time:" << logicTime << "ms"; #endif d->state = WaitingForStanza; } else if (d->depth == 0) { } d->parsers.resize(d->parsersCount.pop()); - // Logger::debug() << d->reader->tokenString() << d->depth << name; + // jreenDebug() << d->reader->tokenString() << d->depth << name; } void Parser::handleCharacterData(const QStringRef &text) @@ -355,10 +355,10 @@ void Parser::parseData() } } if (d->nullReader.error() == QXmlStreamReader::NotWellFormedError) { - Logger::warning() << "---------------------------------"; - Logger::warning() << "Broken stanza (" << d->nullReader.errorString() << ")"; - Logger::warning() << result; - Logger::warning() << "---------------------------------"; + jreenWarning() << "---------------------------------"; + jreenWarning() << "Broken stanza (" << d->nullReader.errorString() << ")"; + jreenWarning() << result; + jreenWarning() << "---------------------------------"; result.prepend("<!--"); result.append("-->"); foreach (XmlStreamHandler *handler, d->client->streamHandlers) diff --git a/src/parser.h b/src/parser.h index 5061efc..03a0584 100644 --- a/src/parser.h +++ b/src/parser.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PARSER_H -#define PARSER_H +#ifndef JREEN_PARSER_H +#define JREEN_PARSER_H #include "stanza.h" #include <QXmlStreamReader> diff --git a/src/parser_p.h b/src/parser_p.h index 0024a53..fa4b54b 100644 --- a/src/parser_p.h +++ b/src/parser_p.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef PARSER_P_H -#define PARSER_P_H +#ifndef JREEN_PARSER_P_H +#define JREEN_PARSER_P_H #include "jreen.h" #include "parser.h" @@ -70,4 +70,4 @@ public: }; } -#endif // PARSER_P_H +#endif // JREEN_PARSER_P_H diff --git a/src/pgpfactory_p.h b/src/pgpfactory_p.h index b184bfa..9a149f0 100644 --- a/src/pgpfactory_p.h +++ b/src/pgpfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef JREEN_PGPFACTORY_H -#define JREEN_PGPFACTORY_H +#ifndef JREEN_PGPFACTORY_P_H +#define JREEN_PGPFACTORY_P_H #include "pgpsigned.h" #include "pgpencrypted.h" @@ -65,4 +65,4 @@ private: } // namespace Jreen -#endif // JREEN_PGPFACTORY_H +#endif // JREEN_PGPFACTORY_P_H diff --git a/src/ping.h b/src/ping.h index 4bf25f6..8442984 100644 --- a/src/ping.h +++ b/src/ping.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PING_H -#define PING_H +#ifndef JREEN_PING_H +#define JREEN_PING_H #include "stanzaextension.h" #include "jid.h" @@ -47,4 +47,4 @@ private: } // namespace Jreen -#endif // PING_H +#endif // JREEN_PING_H diff --git a/src/pingfactory_p.h b/src/pingfactory_p.h index b4bcf9c..50a4f99 100644 --- a/src/pingfactory_p.h +++ b/src/pingfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PINGFACTORY_P_H -#define PINGFACTORY_P_H +#ifndef JREEN_PINGFACTORY_P_H +#define JREEN_PINGFACTORY_P_H #include "ping.h" namespace Jreen { @@ -46,4 +46,4 @@ public: } // namespace Jreen -#endif // PINGFACTORY_P_H +#endif // JREEN_PINGFACTORY_P_H diff --git a/src/prep.cpp b/src/prep.cpp index e5f04c1..8b7527e 100644 --- a/src/prep.cpp +++ b/src/prep.cpp @@ -45,9 +45,9 @@ namespace Jreen { typedef void Stringprep_profile; typedef int Stringprep_profile_flags; - static void *Jreen_idn_stringprep_nameprep = 0; - static void *Jreen_idn_stringprep_xmpp_nodeprep = 0; - static void *Jreen_idn_stringprep_xmpp_resourceprep = 0; + static Stringprep_profile *Jreen_idn_stringprep_nameprep = 0; + static Stringprep_profile *Jreen_idn_stringprep_xmpp_nodeprep = 0; + static Stringprep_profile *Jreen_idn_stringprep_xmpp_resourceprep = 0; typedef int (*Jreen_idn_stringprep_) (char *in, size_t maxlen, Stringprep_profile_flags flags, const Stringprep_profile *profile); static Jreen_idn_stringprep_ Jreen_idn_stringprep = 0; @@ -76,9 +76,12 @@ namespace Jreen #endif // Q_OS_WIN32 return false; } - Jreen_idn_stringprep_nameprep = lib.resolve("stringprep_nameprep"); - Jreen_idn_stringprep_xmpp_nodeprep = lib.resolve("stringprep_xmpp_nodeprep"); - Jreen_idn_stringprep_xmpp_resourceprep = lib.resolve("stringprep_xmpp_resourceprep"); + Jreen_idn_stringprep_nameprep + = reinterpret_cast<Stringprep_profile*>(lib.resolve("stringprep_nameprep")); + Jreen_idn_stringprep_xmpp_nodeprep + = reinterpret_cast<Stringprep_profile*>(lib.resolve("stringprep_xmpp_nodeprep")); + Jreen_idn_stringprep_xmpp_resourceprep + = reinterpret_cast<Stringprep_profile*>(lib.resolve("stringprep_xmpp_resourceprep")); Jreen_idn_stringprep = reinterpret_cast<Jreen_idn_stringprep_>(lib.resolve("stringprep")); return true; } diff --git a/src/prep_p.h b/src/prep_p.h index 632ea8b..b73091b 100644 --- a/src/prep_p.h +++ b/src/prep_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PREP_H -#define PREP_H +#ifndef JREEN_PREP_P_H +#define JREEN_PREP_P_H #include "jreen.h" @@ -42,4 +42,4 @@ public: } -#endif // PREP_H +#endif // JREEN_PREP_P_H diff --git a/src/presence.h b/src/presence.h index 335f4ca..7b65ab0 100644 --- a/src/presence.h +++ b/src/presence.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef PRESENCE_H -#define PRESENCE_H +#ifndef JREEN_PRESENCE_H +#define JREEN_PRESENCE_H #include "stanza.h" @@ -83,4 +83,4 @@ public: } -#endif // PRESENCE_H +#endif // JREEN_PRESENCE_H diff --git a/src/presence_p.h b/src/presence_p.h index 37f574d..69cfab2 100644 --- a/src/presence_p.h +++ b/src/presence_p.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef PRESENCE_P_H -#define PRESENCE_P_H +#ifndef JREEN_PRESENCE_P_H +#define JREEN_PRESENCE_P_H #include "stanza_p.h" #include "presence.h" @@ -46,4 +46,4 @@ public: }; } -#endif // PRESENCE_P_H +#endif // JREEN_PRESENCE_P_H diff --git a/src/presencefactory_p.h b/src/presencefactory_p.h index 973e250..54dc583 100644 --- a/src/presencefactory_p.h +++ b/src/presencefactory_p.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef PRESENCEFACTORY_P_H -#define PRESENCEFACTORY_P_H +#ifndef JREEN_PRESENCEFACTORY_P_H +#define JREEN_PRESENCEFACTORY_P_H #include "stanzafactory_p.h" #include "presence.h" @@ -51,4 +51,4 @@ private: }; } -#endif // PRESENCEFACTORY_P_H +#endif // JREEN_PRESENCEFACTORY_P_H diff --git a/src/privacymanager.cpp b/src/privacymanager.cpp index 3665b11..c3ce2d1 100644 --- a/src/privacymanager.cpp +++ b/src/privacymanager.cpp @@ -352,7 +352,7 @@ void PrivacyManager::handleIQ(const Jreen::IQ &iq, int context) d->lists = lists; d->defaultList = query->defaultList; d->activeList = query->activeList; - Logger::debug() << Q_FUNC_INFO << d->lists << d->defaultList << d->activeList; + jreenDebug() << Q_FUNC_INFO << d->lists << d->defaultList << d->activeList; if (d->activeList.isEmpty()) d->activeList = d->defaultList; emit listsReceived(); diff --git a/src/privacymanager.h b/src/privacymanager.h index f0a8b8a..1f74aa9 100644 --- a/src/privacymanager.h +++ b/src/privacymanager.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PRIVACYMANAGER_H -#define PRIVACYMANAGER_H +#ifndef JREEN_PRIVACYMANAGER_H +#define JREEN_PRIVACYMANAGER_H #include "jid.h" @@ -128,4 +128,4 @@ private: }; } -#endif // PRIVACYMANAGER_H +#endif // JREEN_PRIVACYMANAGER_H diff --git a/src/privacymanager_p.h b/src/privacymanager_p.h index 8c35745..8d9d35a 100644 --- a/src/privacymanager_p.h +++ b/src/privacymanager_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PRIVACYMANAGER_P_H -#define PRIVACYMANAGER_P_H +#ifndef JREEN_PRIVACYMANAGER_P_H +#define JREEN_PRIVACYMANAGER_P_H #include "privacymanager.h" #include "stanzaextension.h" @@ -83,4 +83,4 @@ public: }; } -#endif // PRIVACYMANAGER_P_H +#endif // JREEN_PRIVACYMANAGER_P_H diff --git a/src/privacyqueryfactory_p.h b/src/privacyqueryfactory_p.h index 4b9d18d..fb6063d 100644 --- a/src/privacyqueryfactory_p.h +++ b/src/privacyqueryfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PRIVACYQUERYFACTORY_P_H -#define PRIVACYQUERYFACTORY_P_H +#ifndef JREEN_PRIVACYQUERYFACTORY_P_H +#define JREEN_PRIVACYQUERYFACTORY_P_H #include "privacymanager_p.h" @@ -52,4 +52,4 @@ private: } // namespace Jreen -#endif // PRIVACYQUERYFACTORY_P_H +#endif // JREEN_PRIVACYQUERYFACTORY_P_H diff --git a/src/privatexml.h b/src/privatexml.h index 2f5a098..52d53ae 100644 --- a/src/privatexml.h +++ b/src/privatexml.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PRIVATEXML_H -#define PRIVATEXML_H +#ifndef JREEN_PRIVATEXML_H +#define JREEN_PRIVATEXML_H #include <QObject> #include "stanzaextension.h" @@ -64,4 +64,4 @@ private: } -#endif // PRIVATEXML_H +#endif // JREEN_PRIVATEXML_H diff --git a/src/privatexml_p.h b/src/privatexml_p.h index 70a8449..0a3f78c 100644 --- a/src/privatexml_p.h +++ b/src/privatexml_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PRIVATEXML_P_H -#define PRIVATEXML_P_H +#ifndef JREEN_PRIVATEXML_P_H +#define JREEN_PRIVATEXML_P_H #include "privatexml.h" #include "jstrings.h" @@ -113,4 +113,4 @@ enum PrivateXmlContext } -#endif // PRIVATEXML_P_H +#endif // JREEN_PRIVATEXML_P_H diff --git a/src/pubsubevent.h b/src/pubsubevent.h index 52b13ba..6bf7565 100644 --- a/src/pubsubevent.h +++ b/src/pubsubevent.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PUBSUBEVENT_H -#define PUBSUBEVENT_H +#ifndef JREEN_PUBSUBEVENT_H +#define JREEN_PUBSUBEVENT_H #include "stanzaextension.h" @@ -54,4 +54,4 @@ private: } } -#endif // PUBSUBEVENT_H +#endif // JREEN_PUBSUBEVENT_H diff --git a/src/pubsubeventfactory.cpp b/src/pubsubeventfactory.cpp index dc85269..855922e 100644 --- a/src/pubsubeventfactory.cpp +++ b/src/pubsubeventfactory.cpp @@ -111,7 +111,7 @@ void EventFactory::serialize(Payload *extension, QXmlStreamWriter *writer) node = factory ? factory->features().value(0) : QString(); } if (!factory || node.isEmpty()) { - Logger::warning() << "Invalid stanza extension at PubSub::Event"; + jreenWarning() << "Invalid stanza extension at PubSub::Event"; return; } writer->writeStartElement(QLatin1String("event")); diff --git a/src/pubsubeventfactory_p.h b/src/pubsubeventfactory_p.h index 1d8b631..a7775f7 100644 --- a/src/pubsubeventfactory_p.h +++ b/src/pubsubeventfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PUBSUBEVENTFACTORY_H -#define PUBSUBEVENTFACTORY_H +#ifndef JREEN_PUBSUBEVENTFACTORY_P_H +#define JREEN_PUBSUBEVENTFACTORY_P_H #include "pubsubevent.h" #include <QMap> @@ -58,4 +58,4 @@ private: } } -#endif // PUBSUBEVENTFACTORY_H +#endif // JREEN_PUBSUBEVENTFACTORY_P_H diff --git a/src/pubsubmanager.cpp b/src/pubsubmanager.cpp index c5e8564..80c2cff 100644 --- a/src/pubsubmanager.cpp +++ b/src/pubsubmanager.cpp @@ -136,7 +136,7 @@ void Manager::addEntityType(int type) Q_ASSERT(!node.isEmpty()); d->client->disco()->addFeature(node); d->client->disco()->addFeature(node + QLatin1String("+notify")); - Logger::debug() << Q_FUNC_INFO << d->factories.size() << node; + jreenDebug() << Q_FUNC_INFO << d->factories.size() << node; } void Manager::handleMessage(const Jreen::Message &message) diff --git a/src/pubsubmanager.h b/src/pubsubmanager.h index 1e1587b..1b445cf 100644 --- a/src/pubsubmanager.h +++ b/src/pubsubmanager.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PUBSUBMANAGER_H -#define PUBSUBMANAGER_H +#ifndef JREEN_PUBSUBMANAGER_H +#define JREEN_PUBSUBMANAGER_H #include "pubsubevent.h" @@ -87,4 +87,4 @@ private: } } -#endif // PUBSUBMANAGER_H +#endif // JREEN_PUBSUBMANAGER_H diff --git a/src/pubsubmanager_p.h b/src/pubsubmanager_p.h index 644093b..7b78c42 100644 --- a/src/pubsubmanager_p.h +++ b/src/pubsubmanager_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PUBSUBMANAGER_P_H -#define PUBSUBMANAGER_P_H +#ifndef JREEN_PUBSUBMANAGER_P_H +#define JREEN_PUBSUBMANAGER_P_H #include "pubsubmanager.h" #include "dataform.h" @@ -52,4 +52,4 @@ namespace Jreen }; } } -#endif // PUBSUBMANAGER_P_H +#endif // JREEN_PUBSUBMANAGER_P_H diff --git a/src/pubsubpublishfactory.cpp b/src/pubsubpublishfactory.cpp index ce20ff5..9900052 100644 --- a/src/pubsubpublishfactory.cpp +++ b/src/pubsubpublishfactory.cpp @@ -114,7 +114,7 @@ void PublishFactory::serialize(Payload *extension, QXmlStreamWriter *writer) node = factory ? factory->features().value(0) : QString(); } if (!factory || node.isEmpty()) { - Logger::warning() << "Invalid stanza extension at PubSub::Publish"; + jreenWarning() << "Invalid stanza extension at PubSub::Publish"; return; } writer->writeStartElement(QLatin1String("pubsub")); diff --git a/src/pubsubpublishfactory_p.h b/src/pubsubpublishfactory_p.h index 9684b97..56b4ed6 100644 --- a/src/pubsubpublishfactory_p.h +++ b/src/pubsubpublishfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef PUBSUBPUBLISHFACTORY_P_H -#define PUBSUBPUBLISHFACTORY_P_H +#ifndef JREEN_PUBSUBPUBLISHFACTORY_P_H +#define JREEN_PUBSUBPUBLISHFACTORY_P_H #include "pubsubmanager_p.h" #include "dataformfactory_p.h" @@ -59,4 +59,4 @@ private: } } -#endif // PUBSUBPUBLISHFACTORY_P_H +#endif // JREEN_PUBSUBPUBLISHFACTORY_P_H diff --git a/src/receipt.h b/src/receipt.h index 463f92e..33962a3 100644 --- a/src/receipt.h +++ b/src/receipt.h @@ -24,8 +24,8 @@ ** ****************************************************************************/ -#ifndef RECEIPT_H -#define RECEIPT_H +#ifndef JREEN_RECEIPT_H +#define JREEN_RECEIPT_H #include "stanzaextension.h" @@ -56,4 +56,4 @@ private: } -#endif // RECEIPT_H +#endif // JREEN_RECEIPT_H diff --git a/src/receiptfactory_p.h b/src/receiptfactory_p.h index b6fab19..ca777f3 100644 --- a/src/receiptfactory_p.h +++ b/src/receiptfactory_p.h @@ -22,8 +22,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef RECEIPTFACTORY_H -#define RECEIPTFACTORY_H +#ifndef JREEN_RECEIPTFACTORY_P_H +#define JREEN_RECEIPTFACTORY_P_H #include "receipt.h" namespace Jreen { @@ -48,4 +48,4 @@ private: } // namespace Jreen -#endif // RECEIPTFACTORY_H +#endif // JREEN_RECEIPTFACTORY_P_H diff --git a/src/registrationmanager.cpp b/src/registrationmanager.cpp index 0c1bcad..615f79d 100644 --- a/src/registrationmanager.cpp +++ b/src/registrationmanager.cpp @@ -122,7 +122,7 @@ bool RegistrationData::hasFields() const void RegistrationData::setFieldValue(RegistrationData::FieldType type, const QString &value) { if (d->values.size() <= type) { - Logger::warning() << "Unkown RegistrationData::ValueType:" << type; + jreenWarning() << "Unkown RegistrationData::ValueType:" << type; return; } d->valuesFlags |= (1 << type); diff --git a/src/registrationmanager.h b/src/registrationmanager.h index d7c8af4..5e34b73 100644 --- a/src/registrationmanager.h +++ b/src/registrationmanager.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef REGISTRATIONMANAGER_H -#define REGISTRATIONMANAGER_H +#ifndef JREEN_REGISTRATIONMANAGER_H +#define JREEN_REGISTRATIONMANAGER_H #include "dataform.h" #include "error.h" @@ -115,4 +115,4 @@ private: } -#endif // REGISTRATIONMANAGER_H +#endif // JREEN_REGISTRATIONMANAGER_H diff --git a/src/registrationmanager_p.h b/src/registrationmanager_p.h index bd8400d..dcdc218 100644 --- a/src/registrationmanager_p.h +++ b/src/registrationmanager_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef REGISTRATIONMANAGER_P_H -#define REGISTRATIONMANAGER_P_H +#ifndef JREEN_REGISTRATIONMANAGER_P_H +#define JREEN_REGISTRATIONMANAGER_P_H #include "registrationmanager.h" #include "client.h" @@ -87,4 +87,4 @@ public: } -#endif // REGISTRATIONMANAGER_P_H +#endif // JREEN_REGISTRATIONMANAGER_P_H diff --git a/src/saslfeature.cpp b/src/saslfeature.cpp index 1e361a4..a0e4ebf 100644 --- a/src/saslfeature.cpp +++ b/src/saslfeature.cpp @@ -29,60 +29,156 @@ #include <QCoreApplication> #include "logger.h" -#ifdef HAVE_SIMPLESASL -# include "../3rdparty/simplesasl/simplesasl.h" -#endif - #define NS_SASL QLatin1String("urn:ietf:params:xml:ns:xmpp-sasl") namespace Jreen { -SASLFeature::SASLFeature() : StreamFeature(SASL) +#ifdef USE_GSASL +static Gsasl *sasl_context = NULL; + +static int callback_function(Gsasl *context, Gsasl_session *session, Gsasl_property prop) { - QCA::init(); - QCA::setAppName(QCoreApplication::applicationName()); - m_depth = 0; - m_isSupported = QCA::isSupported("sasl"); -#ifdef HAVE_SIMPLESASL - if (!m_isSupported) { - QCA::insertProvider(XMPP::createProviderSimpleSASL()); - m_isSupported = true; + StreamInfo *info = reinterpret_cast<StreamInfo*>(gsasl_session_hook_get(session)); + if (!info) { + jreenDebug() << Q_FUNC_INFO << context << session << prop; + return GSASL_NO_CALLBACK; + } + Q_ASSERT(info); + switch (prop) { + case GSASL_SERVICE: + gsasl_property_set(session, GSASL_SERVICE, "xmpp"); + return GSASL_OK; + case GSASL_HOSTNAME: + gsasl_property_set(session, GSASL_HOSTNAME, QUrl::toAce(info->jid().domain())); + return GSASL_OK; + case GSASL_REALM: + gsasl_property_set(session, GSASL_REALM, info->jid().domain().toUtf8()); + return GSASL_OK; + case GSASL_AUTHID: + gsasl_property_set(session, GSASL_AUTHID, info->jid().node().toUtf8()); + return GSASL_OK; +// case GSASL_AUTHZID: +// gsasl_property_set(session, GSASL_AUTHZID, info->jid().bare().toUtf8()); +// return GSASL_OK; + case GSASL_PASSWORD: + gsasl_property_set(session, GSASL_PASSWORD, info->password().toUtf8()); + return GSASL_OK; + default: + jreenWarning() << "SASL property request unhandled:" << prop; + return GSASL_NO_CALLBACK; } +} + +static void destroy_sasl_context() +{ + gsasl_done(sasl_context); +} + +#else + +static sasl_callback_t sasl_callbacks[] = { + { SASL_CB_GETREALM, NULL, NULL }, + { SASL_CB_USER, NULL, NULL }, + { SASL_CB_AUTHNAME, NULL, NULL }, + { SASL_CB_PASS, NULL, NULL }, + { SASL_CB_LIST_END, NULL, NULL } +}; #endif + +static bool sasl_inited_successfully = false; +static bool sasl_tried_to_init = false; + +SASLFeature::SASLFeature() : StreamFeature(SASL), m_session(NULL) +{ + m_depth = 0; + if (!sasl_tried_to_init) { + sasl_tried_to_init = true; +#ifdef USE_GSASL + int error = gsasl_init(&sasl_context); + if (error != GSASL_OK) { + sasl_context = NULL; + jreenWarning() << "Cannot initialize libgsasl:" << error << ": " << gsasl_strerror (error); + return; + } else { + sasl_inited_successfully = true; + gsasl_callback_set(sasl_context, callback_function); + qAddPostRoutine(destroy_sasl_context); + } +#else + int error = sasl_client_init(sasl_callbacks); + if (error == SASL_OK) { + sasl_inited_successfully = true; + qAddPostRoutine(sasl_done); + } else { + jreenWarning() << "Cannot initialize sasl2:" << error << ": " << sasl_errstring(error, NULL, NULL); + } +#endif + } } -void SASLFeature::init() +#ifndef USE_GSASL +void SASLFeature::getParameters() { - if (!m_isSupported) - return; - Q_ASSERT(!m_sasl); - m_sasl.reset(new QCA::SASL(this)); - m_sasl->setConstraints(QCA::SASL::AllowPlain); - connect(m_sasl.data(), SIGNAL(clientStarted(bool,QByteArray)), - this, SLOT(onClientStarted(bool,QByteArray))); - connect(m_sasl.data(), SIGNAL(nextStep(QByteArray)), - this, SLOT(onNextStep(QByteArray))); - connect(m_sasl.data(), SIGNAL(needParams(QCA::SASL::Params)), - this, SLOT(onNeedParams(QCA::SASL::Params))); - connect(m_sasl.data(), SIGNAL(authCheck(QString,QString)), - this, SLOT(onAuthCheck(QString,QString))); - // Don't listen it for sure -// connect(m_sasl.data(), SIGNAL(error()), this, SLOT(onError())); + const int *maybe_sff; + int result_ssf = 0; + if (SASL_OK == sasl_getprop(m_session, SASL_SSF, reinterpret_cast<const void **>(&maybe_sff))) + result_ssf = *maybe_sff; + + const int *maybe_maxoutbuf; + int maxoutbuf = 0; + if (SASL_OK == sasl_getprop(m_session, SASL_MAXOUTBUF, reinterpret_cast<const void **>(&maybe_maxoutbuf))) + maxoutbuf = *maybe_maxoutbuf; + + jreenWarning() << "getParameters" << result_ssf << maybe_sff << maxoutbuf << maybe_maxoutbuf; +} + +void SASLFeature::interactWithInfo(sasl_interact_t *interacts) +{ + for (size_t i = 0; interacts[i].id != SASL_CB_LIST_END; ++i) { + sasl_interact *interact = &interacts[i]; + switch (interact->id) { + case SASL_CB_AUTHNAME: + setInteractionResult(interact, m_info->jid().node().toUtf8()); + break; + case SASL_CB_GETREALM: + setInteractionResult(interact, m_info->jid().domain().toUtf8()); + break; + case SASL_CB_USER: +// setInteractionResult(interact, m_info->jid().bare().toUtf8()); + break; + case SASL_CB_PASS: + setInteractionResult(interact, m_info->password().toUtf8()); + break; + } + } } +void SASLFeature::setInteractionResult(sasl_interact_t *interact, const QByteArray &value) +{ + m_interact << value; + interact->result = value.constData(); +} + +#endif + void SASLFeature::reset() { - if (!m_isSupported) + if (!sasl_inited_successfully) return; m_depth = 0; m_mechs.clear(); - m_sasl.reset(0); +#ifdef USE_GSASL + m_session.reset(); +#else + sasl_dispose(&m_session); + m_interact.clear(); +#endif } bool SASLFeature::canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes) { - if (!m_isSupported) + if (!sasl_inited_successfully) return false; Q_UNUSED(name); Q_UNUSED(attributes); @@ -91,7 +187,7 @@ bool SASLFeature::canParse(const QStringRef &name, const QStringRef &uri, const void SASLFeature::handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes) { - Q_ASSERT(m_isSupported); + Q_ASSERT(sasl_inited_successfully); Q_UNUSED(uri); Q_UNUSED(attributes); m_depth++; @@ -109,7 +205,7 @@ void SASLFeature::handleStartElement(const QStringRef &name, const QStringRef &u void SASLFeature::handleEndElement(const QStringRef &name, const QStringRef &uri) { - Q_ASSERT(m_isSupported); + Q_ASSERT(sasl_inited_successfully); Q_UNUSED(uri); if (m_depth == 2 && m_state == AtMechanism) m_state = AtMechanisms; @@ -118,81 +214,166 @@ void SASLFeature::handleEndElement(const QStringRef &name, const QStringRef &uri if (name == QLatin1String("success")) m_info->completed(StreamInfo::Authorized | StreamInfo::ResendHeader); if (name == QLatin1String("failure")) - onError(); + m_info->completed(StreamInfo::AuthorizationFailed); } m_depth--; } void SASLFeature::handleCharacterData(const QStringRef &text) { - Q_ASSERT(m_isSupported); + Q_ASSERT(sasl_inited_successfully); if (m_state == AtMechanism) { m_mechs.append(text.toString()); } else if (m_state == AtChallenge) { - m_sasl->putStep(QByteArray::fromBase64(text.toString().toLatin1())); +#ifdef USE_GSASL + char *result; + int error = gsasl_step64(m_session.data(), text.toString().toLatin1(), &result); + if (error == GSASL_NEEDS_MORE || error == GSASL_OK) { + QXmlStreamWriter *writer = m_info->writer(); + writer->writeStartElement(QLatin1String("response")); + writer->writeDefaultNamespace(NS_SASL); + writer->writeCharacters(QString::fromLatin1(result)); + writer->writeEndElement(); + gsasl_free(result); + } else { + jreenWarning() << "SASL next step:" << error << ":" << gsasl_strerror(error); + m_info->completed(StreamInfo::AuthorizationFailed); + m_session.reset(); + } +#else + QByteArray input = QByteArray::fromBase64(text.toLatin1()); + sasl_interact_t *interacts = NULL; + const char *result; + unsigned result_length; + int error; + + do { + + error = sasl_client_step(m_session, + input, + input.size(), + &interacts, + &result, + &result_length); + + if (error == SASL_INTERACT) { + interactWithInfo(interacts); + } + + + } while (error == SASL_INTERACT); + + if (error != SASL_CONTINUE && error != SASL_OK) { + jreenWarning() << "Cannot do step:" << error << ":" << sasl_errstring(error, NULL, NULL); + sasl_dispose(&m_session); + m_info->completed(StreamInfo::AuthorizationFailed); + return; + } + + getParameters(); + + QXmlStreamWriter *writer = m_info->writer(); + writer->writeStartElement(QLatin1String("response")); + writer->writeDefaultNamespace(NS_SASL); + writer->writeCharacters(QString::fromLatin1( + QByteArray::fromRawData(result, result_length) + .toBase64())); + writer->writeEndElement(); +#endif } } bool SASLFeature::isActivatable() { - return m_isSupported && !m_mechs.isEmpty(); + return sasl_inited_successfully && !m_mechs.isEmpty(); } bool SASLFeature::activate() { - if (!m_isSupported) + if (!sasl_inited_successfully) return false; - init(); - m_sasl->setConstraints(QCA::SASL::AllowPlain); - m_sasl->startClient("xmpp", QUrl::toAce(m_info->jid().domain()), m_mechs, QCA::SASL::AllowClientSendFirst); - return true; -} -void SASLFeature::onClientStarted(bool init, const QByteArray &data) -{ - QXmlStreamWriter *writer = m_info->writer(); - writer->writeStartElement(QLatin1String("auth")); - writer->writeDefaultNamespace(NS_SASL); - writer->writeAttribute(QLatin1String("mechanism"), m_sasl->mechanism()); - if (init) - writer->writeCharacters(QString::fromLatin1(data.toBase64())); - writer->writeEndElement(); -} +#ifdef USE_GSASL + Gsasl_session *session; + QByteArray mechs = m_mechs.join(QLatin1String(":")).toLatin1(); + const char *mech = gsasl_client_suggest_mechanism(sasl_context, mechs.data()); + int error = gsasl_client_start(sasl_context, mech, &session); + if (error != GSASL_OK) { + jreenWarning() << "SASL Cannot initialize client:" << error << ":" << gsasl_strerror(error); + return false; + } + m_session.reset(session); + gsasl_session_hook_set(session, m_info); -void SASLFeature::onNextStep(const QByteArray &data) -{ - QXmlStreamWriter *writer = m_info->writer(); - writer->writeStartElement(QLatin1String("response")); - writer->writeDefaultNamespace(NS_SASL); - writer->writeCharacters(QString::fromLatin1(data.toBase64())); - writer->writeEndElement(); -} + char *result; + error = gsasl_step64(session, "", &result); + if (error == GSASL_NEEDS_MORE || error == GSASL_OK) { + QXmlStreamWriter *writer = m_info->writer(); + writer->writeStartElement(QLatin1String("auth")); + writer->writeDefaultNamespace(NS_SASL); + writer->writeAttribute(QLatin1String("mechanism"), QString::fromUtf8(mech)); + if (result && *result) + writer->writeCharacters(QString::fromLatin1(result)); + writer->writeEndElement(); + gsasl_free(result); + } else { + jreenWarning() << "SASL activate:" << error << ":" << gsasl_strerror(error); + m_info->completed(StreamInfo::AuthorizationFailed); + m_session.reset(); + return false; + } +#else + int error = sasl_client_new("xmpp", + QUrl::toAce(m_info->jid().domain()), + NULL, NULL, // local and remote ip + NULL, // session-specific callbacks + 0, // security flags + &m_session); -void SASLFeature::onNeedParams(const QCA::SASL::Params ¶ms) -{ - if (params.needPassword()) - m_sasl->setPassword(QCA::SecureArray(m_info->password().toUtf8())); - if (params.needUsername()) - m_sasl->setUsername(m_info->jid().node()); - if (params.canSendRealm()) - m_sasl->setRealm(m_info->jid().domain()); - // ??? - // Why SASL tells me that I can send Authzid? - /*if (params.canSendAuthzid() && m_info->jid().domain() != QLatin1String("chat.facebook.com")) - m_sasl->setAuthzid(m_info->jid().bare());*/ - m_sasl->continueAfterParams(); -} + if (error != SASL_OK) { + jreenWarning() << "Cannot initialize client:" << error + << ":" << sasl_errstring(error, NULL, NULL); + return false; + } -void SASLFeature::onAuthCheck(const QString &user, const QString &authzid) -{ - Q_UNUSED(user); - Q_UNUSED(authzid); - m_sasl->continueAfterAuthCheck(); -} + QByteArray mechlist = m_mechs.join(QLatin1String(" ")).toLatin1(); + sasl_interact_t *interacts = NULL; + const char *result, *mechusing; + unsigned result_length; -void SASLFeature::onError() -{ - m_info->completed(StreamInfo::AuthorizationFailed); - Logger::debug() << Q_FUNC_INFO << (m_sasl ? m_sasl->errorCode() : -1); + do { + + error = sasl_client_start(m_session, + mechlist, + &interacts, + &result, + &result_length, + &mechusing); + + if (error == SASL_INTERACT) { + interactWithInfo(interacts); + } + + + } while (error == SASL_INTERACT); + + if (error != SASL_CONTINUE) { + jreenWarning() << "Cannot start client:" << error << ":" << sasl_errstring(error, NULL, NULL); + sasl_dispose(&m_session); + m_info->completed(StreamInfo::AuthorizationFailed); + return false; + } + getParameters(); + + QXmlStreamWriter *writer = m_info->writer(); + writer->writeStartElement(QLatin1String("auth")); + writer->writeDefaultNamespace(NS_SASL); + writer->writeAttribute(QLatin1String("mechanism"), QString::fromUtf8(mechusing)); + writer->writeCharacters(QString::fromLatin1( + QByteArray::fromRawData(result, result_length) + .toBase64())); + writer->writeEndElement(); +#endif + return true; } } diff --git a/src/saslfeature_p.h b/src/saslfeature_p.h index f1f05b7..d18082b 100644 --- a/src/saslfeature_p.h +++ b/src/saslfeature_p.h @@ -23,12 +23,22 @@ ** ****************************************************************************/ -#ifndef SASLFEATURE_H -#define SASLFEATURE_H +#ifndef JREEN_SASLFEATURE_P_H +#define JREEN_SASLFEATURE_P_H #include "streamfeature_p.h" #include <QStringList> -#include <QtCrypto> + +#define USE_GSASL + +#ifdef USE_GSASL +# include <gsasl.h> +#else +extern "C" +{ +# include <sasl/sasl.h> +} +#endif namespace Jreen { @@ -54,24 +64,26 @@ namespace Jreen void handleCharacterData(const QStringRef &text); bool isActivatable(); bool activate(); - public slots: - void onClientStarted(bool init, const QByteArray &data); - void onNextStep(const QByteArray &data); - void onNeedParams(const QCA::SASL::Params ¶ms); - void onAuthCheck(const QString &user, const QString &authzid); - void onError(); private: - void init(); - - bool m_isSupported; +#ifndef USE_GSASL + void getParameters(); + void interactWithInfo(sasl_interact_t *interacts); + void setInteractionResult(sasl_interact_t *interact, const QByteArray &value); +#endif + int m_depth; State m_state; QStringList m_mechs; - struct ScopedPointerEventDeleter +#ifdef USE_GSASL + struct SessionCleanup { - static inline void cleanup(QObject *pointer) { if (pointer) pointer->deleteLater(); } + static inline void cleanup(Gsasl_session *pointer) { if (pointer) gsasl_finish(pointer); } }; - QScopedPointer<QCA::SASL, ScopedPointerEventDeleter> m_sasl; + QScopedPointer<Gsasl_session, SessionCleanup> m_session; +#else + sasl_conn_t *m_session; + QList<QByteArray> m_interact; +#endif }; } -#endif // SASLFEATURE_H +#endif // JREEN_SASLFEATURE_P_H diff --git a/src/sessionfeature.cpp b/src/sessionfeature.cpp index b1af149..205d0d6 100644 --- a/src/sessionfeature.cpp +++ b/src/sessionfeature.cpp @@ -110,7 +110,7 @@ void SessionFeature::reset() bool SessionFeature::canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes) { Q_UNUSED(attributes); - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; return name == QLatin1String("session") && uri == NS_SESSION; } @@ -119,7 +119,7 @@ void SessionFeature::handleStartElement(const QStringRef &name, const QStringRef Q_UNUSED(name); Q_UNUSED(uri); Q_UNUSED(attributes); - Logger::debug() << Q_FUNC_INFO; + jreenDebug() << Q_FUNC_INFO; m_hasFeature = true; } diff --git a/src/sessionfeature_p.h b/src/sessionfeature_p.h index 1146054..f99d2fb 100644 --- a/src/sessionfeature_p.h +++ b/src/sessionfeature_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef SESSIONFEATURE_P_H -#define SESSIONFEATURE_P_H +#ifndef JREEN_SESSIONFEATURE_P_H +#define JREEN_SESSIONFEATURE_P_H #include "streamfeature_p.h" @@ -54,4 +54,4 @@ namespace Jreen }; } -#endif // SESSIONFEATURE_P_H +#endif // JREEN_SESSIONFEATURE_P_H diff --git a/src/sjdns.cpp b/src/sjdns.cpp index f0779de..1c18e9d 100644 --- a/src/sjdns.cpp +++ b/src/sjdns.cpp @@ -71,7 +71,7 @@ bool SJDns::isValid() void SJDns::doLookup(const QString &host, QObject *receiver, const char *member) { Q_ASSERT(m_valid); - int id = m_qjdns->queryStart("_xmpp-client._tcp." + QUrl::toAce(host), QJDns::Srv); + int id = m_qjdns->queryStart(host.toLatin1(), QJDns::Srv); Action *action = new Action(this); action->setData(host); connect(action, SIGNAL(triggered()), receiver, member); @@ -92,7 +92,7 @@ void SJDns::resultsReady(int id, const QJDns::Response &results) Action *action = m_actions.value(id, 0); Q_ASSERT(action); foreach(const QJDns::Record &record, results.answerRecords) - Logger::debug() << record.name << record.port << record.priority << record.weight; + jreenDebug() << action->data() << record.name << record.port << record.priority << record.weight; m_results.insert(action->data().toString(), results); action->trigger(); } @@ -115,18 +115,73 @@ void SJDns::error(int id, QJDns::Error e) action->trigger(); switch (e) { case QJDns::ErrorGeneric: - Logger::critical() << "error Generic" << id; + jreenCritical() << "error Generic" << id; break; case QJDns::ErrorNXDomain: - Logger::critical() << "error NXDomain" << id; + jreenCritical() << "error NXDomain" << id; break; case QJDns::ErrorTimeout: - Logger::critical() << "error Timeout" << id; + jreenCritical() << "error Timeout" << id; break; case QJDns::ErrorConflict: - Logger::critical() << "error Conflict" << id; + jreenCritical() << "error Conflict" << id; break; } } +DnsLookup::DnsLookup(QObject *parent) + : QObject(parent), m_type(QJDns::Any), m_response(NULL) +{ +} + +DnsLookup::~DnsLookup() +{ +} + +void DnsLookup::setType(DnsLookup::Type type) +{ + m_type = static_cast<QJDns::Type>(type); +} + +void DnsLookup::setName(const QString &name) +{ + m_name = name; +} + +void DnsLookup::lookup() +{ + if (SJDns::instance().isValid()) + SJDns::instance().doLookup(m_name, this, SLOT(onResultReady())); + else + emit finished(); +} + +QList<DnsServiceRecord> DnsLookup::serviceRecords() const +{ + QList<DnsServiceRecord> result; + if (!m_response) + return result; + + foreach(const QJDns::Record &qrecord, m_response->answerRecords) { + DnsServiceRecord record; + record.m_target = QUrl::fromAce(qrecord.name); + record.m_port = qrecord.port; + record.m_weight = qrecord.weight; + record.m_priority = qrecord.priority; + result << record; + } + return result; +} + +DnsLookup::Error DnsLookup::error() const +{ + return m_response ? NoError : SomeError; +} + +void DnsLookup::onResultReady() +{ + m_response = SJDns::instance().servers(m_name); + emit finished(); +} + } diff --git a/src/sjdns_p.h b/src/sjdns_p.h index 227d974..f04e8b3 100644 --- a/src/sjdns_p.h +++ b/src/sjdns_p.h @@ -23,10 +23,15 @@ ** ****************************************************************************/ -#ifndef QJDNS_P_H -#define QJDNS_P_H +#ifndef JREEN_SJDNS_P_H +#define JREEN_SJDNS_P_H + +#include <qglobal.h> + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +# error Check build scripts +#endif -//#include <QAction> #include <jdns/qjdns.h> #include <QUrl> #include "action_p.h" @@ -34,15 +39,9 @@ namespace Jreen { -//class JAction; - -// TODO: Make DNS API shared - -class SJDns : QObject +class SJDns : public QObject { Q_OBJECT - QJDns *m_qjdns; - bool m_valid; SJDns() {} ~SJDns() {} public: @@ -56,10 +55,66 @@ private slots: void published(int id); void error(int id, QJDns::Error e); private: + QJDns *m_qjdns; + bool m_valid; QMap<int, Action *> m_actions; QHash<QString, QJDns::Response> m_results; }; +class DnsServiceRecord +{ +public: + inline QString target() const { return m_target; } + inline quint16 port() const { return m_port; } + inline quint16 priority() const { return m_priority; } + inline quint16 weight() const { return m_weight; } + + QString m_target; + quint16 m_port; + quint16 m_priority; + quint16 m_weight; +}; + +class DnsLookup : public QObject +{ + Q_OBJECT +public: + enum Error { + NoError, + SomeError + }; + + enum Type { + Invalid = -1, + SRV = QJDns::Srv + }; + + DnsLookup(QObject *parent); + ~DnsLookup(); + + void setType(Type type); + void setName(const QString &name); + void lookup(); + + QList<DnsServiceRecord> serviceRecords() const; + Error error() const; + +signals: + void finished(); + +private slots: + void onResultReady(); + +private: + QJDns::Type m_type; + QString m_name; + const QJDns::Response *m_response; +}; + +typedef DnsLookup QDnsLookup; +typedef DnsServiceRecord QDnsServiceRecord; +//#endif + } -#endif // QJDNS_P_H +#endif // JREEN_SJDNS_P_H diff --git a/src/softwareversion.h b/src/softwareversion.h index 8147e16..42cb4e9 100644 --- a/src/softwareversion.h +++ b/src/softwareversion.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef SOFTWAREVERSION_H -#define SOFTWAREVERSION_H +#ifndef JREEN_SOFTWAREVERSION_H +#define JREEN_SOFTWAREVERSION_H #include "stanzaextension.h" @@ -58,4 +58,4 @@ private: } -#endif // SOFTWAREVERSION_H +#endif // JREEN_SOFTWAREVERSION_H diff --git a/src/softwareversionfactory_p.h b/src/softwareversionfactory_p.h index 40ab864..2a573d6 100644 --- a/src/softwareversionfactory_p.h +++ b/src/softwareversionfactory_p.h @@ -22,8 +22,8 @@ ** $JREEN_END_LICENSE$ ** ****************************************************************************/ -#ifndef SOFTWAREVERSIONFACTORY_H -#define SOFTWAREVERSIONFACTORY_H +#ifndef JREEN_SOFTWAREVERSIONFACTORY_P_H +#define JREEN_SOFTWAREVERSIONFACTORY_P_H #include "softwareversion.h" namespace Jreen { @@ -48,4 +48,4 @@ private: } // namespace Jreen -#endif // SOFTWAREVERSIONFACTORY_H +#endif // JREEN_SOFTWAREVERSIONFACTORY_P_H diff --git a/src/src.qbs b/src/src.qbs index 33f315c..78f0980 100644 --- a/src/src.qbs +++ b/src/src.qbs @@ -1,3 +1,7 @@ +import qbs +import qbs.FileInfo +import qbs.TextFile + Product { name: "jreen" @@ -6,8 +10,9 @@ Product { property string versionMinor: '1' property string versionRelease: '1' property string version: versionMajor+'.'+versionMinor+'.'+versionRelease + property bool useIrisIce: false - destination: { + destinationDirectory: { if (qbs.targetOS === 'windows') return "bin"; else @@ -19,11 +24,7 @@ Product { //Depends { name: "headers" } Depends { name: "Qt.core" } Depends { name: "Qt.network" } - Depends { name: "qca" } - Depends { name: "zlib" } - Depends { name: "speex"; required: false } - Depends { name: "windows.ws2_32"; condition: qbs.targetOS === 'windows' } - Depends { name: "windows.advapi32"; condition: qbs.targetOS === 'windows' } +// Depends { name: "zlib" } //cpp.warningLevel: "all" cpp.includePaths: [ @@ -35,25 +36,35 @@ Product { ".", "experimental" ] - cpp.defines: ["J_BUILD_LIBRARY"] + cpp.defines: [ + "J_BUILD_LIBRARY", + "QT_DISABLE_DEPRECATED_BEFORE=0" + ] cpp.positionIndependentCode: true cpp.visibility: ["hidden"] + cpp.dynamicLibraries: ["gsasl", "z"] Properties { condition: useSimpleSasl cpp.defines: outer.concat("HAVE_SIMPLESASL") } Properties { + condition: useIrisIce + cpp.defines: outer.concat("HAVE_IRISICE") + } + Properties { condition: false //speex.found cpp.defines: outer.concat("JREEN_HAVE_SPEEX=1") } files: [ - "*.cpp" + "*.cpp", + "*_p.h" ] + excludeFiles: Qt.core.versionMajor < 5 ? undefined : "sjdns*" Group { - //jdns files + condition: Qt.core.versionMajor < 5 prefix: "../3rdparty/jdns/" files: [ "*.h", @@ -62,7 +73,7 @@ Product { ] } Group { - //ice files + condition: useIrisIce prefix: "../3rdparty/icesupport/" files: [ "*.h", @@ -71,15 +82,6 @@ Product { ] } Group { - //simple sasl files - condition: useSimpleSasl - prefix: "../3rdparty/simplesasl/" - files: [ - "*.h", - "*.cpp", - ] - } - Group { //experimental jingle support prefix: "experimental/" files: [ @@ -89,22 +91,39 @@ Product { } Group { - //public headers - qbs.installDir: "include/jreen" + files: "*.h" + excludeFiles: "*_p.h" + fileTags: ["hpp", "devheader"] overrideTags: false - fileTags: ["install"] - files: [ - "*[^_][a-z].h", - ] } - Group { - //private headers - files: "*_p.h" + Export { + Depends { name: "cpp" } + cpp.includePaths: [ + product.buildDirectory + "/GeneratedFiles/jreen/include", + product.buildDirectory + "/GeneratedFiles/jreen/include/jreen" + ] } - ProductModule { - Depends { name: "cpp" } - cpp.includePaths: product.buildDirectory + "/include/vreen" + Rule { + inputs: [ "devheader" ] + Artifact { + fileTags: [ "hpp" ] + fileName: "GeneratedFiles/jreen/include/jreen/" + input.fileName + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.sourceCode = function() { + var inputFile = new TextFile(input.fileName, TextFile.ReadOnly); + var file = new TextFile(output.fileName, TextFile.WriteOnly); + file.truncate(); + file.write("#include \"" + input.fileName + "\"\n"); + file.close(); + } + cmd.description = "generating " + FileInfo.fileName(output.fileName); + cmd.highlight = "filegen"; + return cmd; + } } } diff --git a/src/stanza.h b/src/stanza.h index fc7948a..f809d01 100644 --- a/src/stanza.h +++ b/src/stanza.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef STANZA_H -#define STANZA_H +#ifndef JREEN_STANZA_H +#define JREEN_STANZA_H #include "stanzaextension.h" #include "error.h" @@ -84,4 +84,4 @@ protected: } -#endif // STANZA_H +#endif // JREEN_STANZA_H diff --git a/src/stanza_p.h b/src/stanza_p.h index 0e3fda5..eb0aa04 100644 --- a/src/stanza_p.h +++ b/src/stanza_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef STANZA_P_H -#define STANZA_P_H +#ifndef JREEN_STANZA_P_H +#define JREEN_STANZA_P_H #include <QHash> #include <QMap> @@ -87,7 +87,7 @@ public: { ref = 1; } - ~StanzaPrivate() + virtual ~StanzaPrivate() { qDeleteAll(tokens); } @@ -122,4 +122,4 @@ public: } -#endif // STANZA_P_H +#endif // JREEN_STANZA_P_H diff --git a/src/stanzaextension.h b/src/stanzaextension.h index 842221b..525ce24 100644 --- a/src/stanzaextension.h +++ b/src/stanzaextension.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef STANZAEXTENSION_H -#define STANZAEXTENSION_H +#ifndef JREEN_STANZAEXTENSION_H +#define JREEN_STANZAEXTENSION_H #include <QObject> #include <QSharedPointer> @@ -129,7 +129,7 @@ Q_INLINE_TEMPLATE T se_cast(Payload *se) typedef QSharedPointer<Class> Ptr; \ static int staticPayloadType() \ { \ - static QBasicAtomicInt payloadType = Q_BASIC_ATOMIC_INITIALIZER(0); \ + static int payloadType = 0; \ if (!payloadType) { \ payloadType = Payload::registerPayloadType( #Class ); \ Class *useFullNameWithNamespaces = reinterpret_cast< ::Class* >(0); \ @@ -144,4 +144,4 @@ Q_INLINE_TEMPLATE T se_cast(Payload *se) } \ private: -#endif // STANZAEXTENSION_H +#endif // JREEN_STANZAEXTENSION_H diff --git a/src/stanzafactory.cpp b/src/stanzafactory.cpp index 28c5ac0..2dadbba 100644 --- a/src/stanzafactory.cpp +++ b/src/stanzafactory.cpp @@ -139,7 +139,7 @@ void StanzaFactory::writePayloads(Stanza *stanza, QXmlStreamWriter *writer) if(factory) factory->serialize(extension.data(),writer); else - Logger::debug() << "Invalid stanza extesion" << extension->payloadType(); + jreenDebug() << "Invalid stanza extesion" << extension->payloadType(); } } diff --git a/src/stanzafactory_p.h b/src/stanzafactory_p.h index 9e15b12..53b811a 100644 --- a/src/stanzafactory_p.h +++ b/src/stanzafactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef STANZAFACTORY_H -#define STANZAFACTORY_H +#ifndef JREEN_STANZAFACTORY_P_H +#define JREEN_STANZAFACTORY_P_H #include "stanza_p.h" #include "langmap.h" @@ -59,4 +59,4 @@ protected: }; } -#endif // STANZAFACTORY_H +#endif // JREEN_STANZAFACTORY_P_H diff --git a/src/streamfeature_p.h b/src/streamfeature_p.h index ed3bede..1766c5a 100644 --- a/src/streamfeature_p.h +++ b/src/streamfeature_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef STREAMFEATURE_H -#define STREAMFEATURE_H +#ifndef JREEN_STREAMFEATURE_P_H +#define JREEN_STREAMFEATURE_P_H #include <QObject> #include "jid.h" @@ -99,4 +99,4 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(Jreen::StreamInfo::CompletedFlags) Q_DECLARE_INTERFACE(Jreen::StreamFeature, "org.qutim.Jreen.StreamFeature") -#endif // STREAMFEATURE_H +#endif // JREEN_STREAMFEATURE_P_H diff --git a/src/streamprocessor.h b/src/streamprocessor.h index 69bfe9b..6ba2126 100644 --- a/src/streamprocessor.h +++ b/src/streamprocessor.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef STREAMPROCESSOR_H -#define STREAMPROCESSOR_H +#ifndef JREEN_STREAMPROCESSOR_H +#define JREEN_STREAMPROCESSOR_H #include "jreen.h" #include <QObject> @@ -49,4 +49,4 @@ public: Q_DECLARE_INTERFACE(Jreen::StreamProcessor, "org.qutim.Jreen.StreamProcessor") -#endif // STREAMPROCESSOR_H +#endif // JREEN_STREAMPROCESSOR_H diff --git a/src/subscription.h b/src/subscription.h index 3193763..9aafbad 100644 --- a/src/subscription.h +++ b/src/subscription.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef SUBSCRIPTION_H -#define SUBSCRIPTION_H +#ifndef JREEN_SUBSCRIPTION_H +#define JREEN_SUBSCRIPTION_H #include "stanza.h" @@ -56,4 +56,4 @@ namespace Jreen } -#endif // SUBSCRIPTION_H +#endif // JREEN_SUBSCRIPTION_H diff --git a/src/tcpconnection.cpp b/src/tcpconnection.cpp index adaad12..d8c72a4 100644 --- a/src/tcpconnection.cpp +++ b/src/tcpconnection.cpp @@ -24,18 +24,18 @@ ****************************************************************************/ #include "tcpconnection.h" -#include <QTcpSocket> +#include <QSslSocket> namespace Jreen { TcpConnection::TcpConnection(const QString &host_name, qint16 port) - : DirectConnection(new QTcpSocket, host_name, port) + : DirectConnection(new QSslSocket, host_name, port) { } TcpConnection::TcpConnection(const QHostAddress &address, qint16 port) - : DirectConnection(new QTcpSocket, address, port) + : DirectConnection(new QSslSocket, address, port) { } diff --git a/src/tcpconnection.h b/src/tcpconnection.h index 9d5cc5d..6cc0ef7 100644 --- a/src/tcpconnection.h +++ b/src/tcpconnection.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef TCPCONNECTION_H -#define TCPCONNECTION_H +#ifndef JREEN_TCPCONNECTION_H +#define JREEN_TCPCONNECTION_H #include "directconnection.h" @@ -41,4 +41,4 @@ public: } -#endif // TCPCONNECTION_H +#endif // JREEN_TCPCONNECTION_H diff --git a/src/tlsdatastream.cpp b/src/tlsdatastream.cpp deleted file mode 100644 index 7d15c18..0000000 --- a/src/tlsdatastream.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Jreen -** -** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> -** -***************************************************************************** -** -** $JREEN_BEGIN_LICENSE$ -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** This program 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see http://www.gnu.org/licenses/. -** $JREEN_END_LICENSE$ -** -****************************************************************************/ - -#include "tlsdatastream_p.h" -#include "logger.h" - -namespace Jreen -{ -TLSDataStream::TLSDataStream(QCA::TLS *tls) : m_tls(tls) -{ - connect(m_tls.data(), SIGNAL(readyRead()), SLOT(onReadyRead())); - connect(m_tls.data(), SIGNAL(readyReadOutgoing()), SLOT(onReadyReadOutgoing())); - m_offset = 0; -} - -TLSDataStream::~TLSDataStream() -{ -} - -qint64 TLSDataStream::bytesAvailable() const -{ - return m_buffer.size() - m_offset; -} - -bool TLSDataStream::open(OpenMode mode) -{ - return QIODevice::open(mode); -} - -void TLSDataStream::close() -{ - QIODevice::close(); -} - -void TLSDataStream::incomingDataReady() -{ - if (m_tls) - m_tls.data()->writeIncoming(device()->readAll()); -} - -qint64 TLSDataStream::writeData(const char *data, qint64 len) -{ - if (m_tls) - m_tls.data()->write(QByteArray(data, len)); - return len; -} - -qint64 TLSDataStream::readData(char *data, qint64 maxlen) -{ - if (maxlen >= m_buffer.size() - m_offset) { - int len = m_buffer.size() - m_offset; - qMemCopy(data, m_buffer.constData() + m_offset, len); - m_buffer.clear(); - m_offset = 0; - return len; - } - qMemCopy(data, m_buffer.constData() + m_offset, maxlen); - m_offset += maxlen; - return maxlen; -} - -void TLSDataStream::onReadyRead() -{ - if (!m_tls) - return; - m_buffer.append(m_tls.data()->read()); - emit readyRead(); -} - -void TLSDataStream::onReadyReadOutgoing() -{ - if (!m_tls) - return; - device()->write(m_tls.data()->readOutgoing()); -} -} diff --git a/src/tlsdatastream_p.h b/src/tlsdatastream_p.h deleted file mode 100644 index bfc522c..0000000 --- a/src/tlsdatastream_p.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Jreen -** -** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> -** -***************************************************************************** -** -** $JREEN_BEGIN_LICENSE$ -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** This program 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see http://www.gnu.org/licenses/. -** $JREEN_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TLSDATASTREAM_H -#define TLSDATASTREAM_H - -#include "datastream.h" -#include <QtCrypto> - -namespace Jreen -{ - class TLSDataStream : public DataStream - { - Q_OBJECT - public: - TLSDataStream(QCA::TLS *tls); - ~TLSDataStream(); - - qint64 bytesAvailable() const; - bool open(OpenMode mode); - void close(); - protected: - void incomingDataReady(); - qint64 writeData(const char *data, qint64 len); - qint64 readData(char *data, qint64 maxlen); - private slots: - void onReadyRead(); - void onReadyReadOutgoing(); - private: - QWeakPointer<QCA::TLS> m_tls; - QByteArray m_buffer; - int m_offset; - }; -} - -#endif // TLSDATASTREAM_H diff --git a/src/tlsfeature.cpp b/src/tlsfeature.cpp index a73d76e..6470cce 100644 --- a/src/tlsfeature.cpp +++ b/src/tlsfeature.cpp @@ -2,7 +2,7 @@ ** ** Jreen ** -** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> +** Copyright © 2013 Ruslan Nigmatullin <euroelessar@yandex.ru> ** Copyright © 2011 Aleksey Sidorov <gorthauer87@yandex.ru> ** ***************************************************************************** @@ -25,11 +25,12 @@ ****************************************************************************/ #include "tlsfeature_p.h" -#include "tlsdatastream_p.h" #include "client.h" -#include <QXmlStreamWriter> #include "logger.h" +#include "directconnection.h" +#include <QXmlStreamWriter> #include <QCoreApplication> +#include <QSslSocket> #define NS_TLS QLatin1String("urn:ietf:params:xml:ns:xmpp-tls") @@ -38,24 +39,14 @@ namespace Jreen TLSFeature::TLSFeature() : StreamFeature(SecurityLayer) { - QCA::init(); - QCA::setAppName(QCoreApplication::applicationName()); m_required = false; m_available = false; - m_hasTls = QCA::isSupported("tls"); - if (!m_hasTls) - Logger::warning() << "Jreen: TLS is not provided by QCA"; + if (!QSslSocket::supportsSsl()) + jreenWarning() << "Jreen: TLS is not provided by QtNetwork"; } void TLSFeature::init() { - Q_ASSERT(m_hasTls); - Q_ASSERT(!m_tls); - m_tls.reset(new QCA::TLS(this)); - m_tls->setTrustedCertificates(QCA::systemStore()); - connect(m_tls.data(), SIGNAL(handshaken()), SLOT(onHandshaken())); - connect(m_tls.data(), SIGNAL(closed()), SLOT(onClosed())); - connect(m_tls.data(), SIGNAL(error()), SLOT(onError())); } void TLSFeature::setStreamInfo(StreamInfo *info) @@ -75,14 +66,18 @@ void TLSFeature::reset() bool TLSFeature::canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes) { - // All other methods shouldn't be called is canParse returnes false - if (!m_hasTls) - return false; Q_UNUSED(uri); Q_UNUSED(name); Q_UNUSED(attributes); - Logger::debug() << Q_FUNC_INFO << name << uri; - return uri == NS_TLS; + // All other methods shouldn't be called is canParse returnes false + if (!QSslSocket::supportsSsl()) + return false; + + if (DirectConnection *connection = qobject_cast<DirectConnection*>(m_client->connection())) { + if (qobject_cast<QSslSocket*>(connection->socket())) + return uri == NS_TLS; + } + return false; } void TLSFeature::handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes) @@ -93,58 +88,37 @@ void TLSFeature::handleStartElement(const QStringRef &name, const QStringRef &ur m_available = true; else if (name == QLatin1String("required")) m_required = true; - // Q_UNUSED(uri); - // m_depth++; - // Logger::debug() << Q_FUNC_INFO << m_depth << name; - // if (m_depth == 1) { - // if (name == QLatin1String("mechanisms")) { - // m_state = AtMechanisms; - // m_mechs.clear(); - // } else if (name == QLatin1String("challenge")) { - // m_state = AtChallenge; - // } - // } else if (m_depth == 2 && name == QLatin1String("mechanism")) { - // m_state = AtMechanism; - // } } void TLSFeature::handleEndElement(const QStringRef &name, const QStringRef &uri) { Q_UNUSED(uri); if (name == QLatin1String("proceed")) { - Logger::debug() << Q_FUNC_INFO; - m_info->addDataStream(new TLSDataStream(m_tls.data())); - m_tls->startClient(m_info->jid().domain()); + DirectConnection *connection = qobject_cast<DirectConnection*>(m_client->connection()); + Q_ASSERT(connection); + QSslSocket *socket = qobject_cast<QSslSocket*>(connection->socket()); + Q_ASSERT(socket); + m_socket = socket; + + socket->setProtocol(QSsl::TlsV1); + socket->setPeerVerifyMode(QSslSocket::VerifyNone); + + connect(socket, SIGNAL(encrypted()), this, SLOT(onHandshaken())); + connect(socket, SIGNAL(disconnected()), this, SLOT(onDisconnected())); + connect(socket, SIGNAL(peerVerifyError(QSslError)), SLOT(onPeerVerifyError(QSslError))); + + socket->startClientEncryption(); } - // if (m_depth == 2 && m_state == AtMechanism) - // m_state = AtMechanisms; - // else if (m_depth == 1) { - // Logger::debug() << Q_FUNC_INFO << m_mechs; - // m_state = AtStart; - // if (name == QLatin1String("success")) - // m_info->completed(StreamInfo::Authorized); - // } - // m_depth--; } void TLSFeature::handleCharacterData(const QStringRef &text) { Q_UNUSED(text); - // if (m_state == AtMechanism) { - // Logger::debug() << Q_FUNC_INFO << "mechanism" << text; - // m_mechs.append(text.toString()); - // } else if (m_state == AtChallenge) { - // Logger::debug() << Q_FUNC_INFO << "challenge" << text; - // // if (m_firstStep) - // // m_tls->putServerFirstStep("DIGEST-MD5"); - // m_tls->putStep(QByteArray::fromBase64(text.toString().toLatin1())); - // m_firstStep = false; - // } } bool TLSFeature::isActivatable() { - return m_hasTls && m_available; + return QSslSocket::supportsSsl() && m_available; } bool TLSFeature::activate() @@ -154,39 +128,26 @@ bool TLSFeature::activate() writer->writeEmptyElement(QLatin1String("starttls")); writer->writeDefaultNamespace(NS_TLS); writer->writeCharacters(QString()); - // Logger::debug() << Q_FUNC_INFO << m_info->password(); - // m_tls->setPassword(QCA::SecureArray(m_info->password().toUtf8())); - // m_tls->setUsername(m_info->jid().node()); - // m_tls->setRealm(m_info->jid().domain()); - // m_tls->setAuthzid(m_info->jid().bare()); - // m_tls->startClient("xmpp", QUrl::toAce(m_info->jid().domain()), m_mechs, QCA::TLS::AllowClientSendFirst); return true; } void TLSFeature::onHandshaken() { - Logger::debug() << Q_FUNC_INFO; - m_tls->continueAfterStep(); m_info->completed(); } -void TLSFeature::onClosed() -{ - Logger::debug() << Q_FUNC_INFO; - reset(); -} - -void TLSFeature::onError() +void TLSFeature::onPeerVerifyError(const QSslError &error) { - Logger::debug() << Q_FUNC_INFO; - reset(); - m_client->disconnectFromServer(true); + QSslSocket *socket = qobject_cast<QSslSocket*>(sender()); + Q_ASSERT(socket); + socket->ignoreSslErrors(QList<QSslError>() << error); } void TLSFeature::onDisconnected() { - m_tls.reset(0); - Logger::debug() << Q_FUNC_INFO; + if (m_socket) + disconnect(m_socket, 0, this, 0); + m_socket = NULL; } } //namespace Jreen diff --git a/src/tlsfeature_p.h b/src/tlsfeature_p.h index cbacf43..89e22d5 100644 --- a/src/tlsfeature_p.h +++ b/src/tlsfeature_p.h @@ -2,7 +2,7 @@ ** ** Jreen ** -** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> +** Copyright © 2013 Ruslan Nigmatullin <euroelessar@yandex.ru> ** ***************************************************************************** ** @@ -23,11 +23,14 @@ ** ****************************************************************************/ -#ifndef TLSFEATURE_H -#define TLSFEATURE_H +#ifndef JREEN_TLSFEATURE_P_H +#define JREEN_TLSFEATURE_P_H #include "streamfeature_p.h" -#include <QtCrypto> +#include <QPointer> + +class QSslError; +class QSslSocket; namespace Jreen { @@ -43,7 +46,6 @@ public: }; TLSFeature(); int priority() { return 10; } -// void setStreamInfo(StreamInfo *info); void reset(); bool canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes); void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes); @@ -54,21 +56,15 @@ public: bool activate(); private slots: void onHandshaken(); - void onClosed(); - void onError(); + void onPeerVerifyError(const QSslError &error); void onDisconnected(); private: void init(); - - struct ScopedPointerEventDeleter - { - static inline void cleanup(QObject *pointer) { if (pointer) pointer->deleteLater(); } - }; - QScopedPointer<QCA::TLS, ScopedPointerEventDeleter> m_tls; - bool m_hasTls; + + QPointer<QSslSocket> m_socket; bool m_required; bool m_available; }; } -#endif // TLSFEATURE_H +#endif // JREEN_TLSFEATURE_P_H diff --git a/src/tune.h b/src/tune.h index 6d720fa..7207e62 100644 --- a/src/tune.h +++ b/src/tune.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef TUNE_H -#define TUNE_H +#ifndef JREEN_TUNE_H +#define JREEN_TUNE_H #include "stanzaextension.h" @@ -58,4 +58,4 @@ namespace Jreen }; } -#endif // TUNE_H +#endif // JREEN_TUNE_H diff --git a/src/tunefactory_p.h b/src/tunefactory_p.h index e2e0bba..80dd17f 100644 --- a/src/tunefactory_p.h +++ b/src/tunefactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef TUNEFACTORY_P_H -#define TUNEFACTORY_P_H +#ifndef JREEN_TUNEFACTORY_P_H +#define JREEN_TUNEFACTORY_P_H #include "tune.h" #include <QVector> @@ -49,4 +49,4 @@ namespace Jreen }; } -#endif // TUNEFACTORY_P_H +#endif // JREEN_TUNEFACTORY_P_H diff --git a/src/udpconnection.h b/src/udpconnection.h index d61e2a0..d6acaf7 100644 --- a/src/udpconnection.h +++ b/src/udpconnection.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef UDPCONNECTION_H -#define UDPCONNECTION_H +#ifndef JREEN_UDPCONNECTION_H +#define JREEN_UDPCONNECTION_H #include "directconnection.h" @@ -41,4 +41,4 @@ public: } -#endif // UDPCONNECTION_H +#endif // JREEN_UDPCONNECTION_H diff --git a/src/util.h b/src/util.h index 05a782a..bfd117b 100644 --- a/src/util.h +++ b/src/util.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef UTIL_H -#define UTIL_H +#ifndef JREEN_UTIL_H +#define JREEN_UTIL_H #include "jreen.h" #include <QDateTime> @@ -67,4 +67,4 @@ inline void writeTextElement(QXmlStreamWriter *writer, } -#endif // UTIL_H +#endif // JREEN_UTIL_H diff --git a/src/vcard.h b/src/vcard.h index 9732a9f..0b1d616 100644 --- a/src/vcard.h +++ b/src/vcard.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef VCARD_H -#define VCARD_H +#ifndef JREEN_VCARD_H +#define JREEN_VCARD_H #include "stanzaextension.h" #include "nickname.h" #include <QDateTime> @@ -407,4 +407,4 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(Jreen::VCard::Telephone::Types) -#endif // VCARD_H +#endif // JREEN_VCARD_H diff --git a/src/vcard_p.h b/src/vcard_p.h index 8bbaf97..12856ce 100644 --- a/src/vcard_p.h +++ b/src/vcard_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef VCARD_P_H -#define VCARD_P_H +#ifndef JREEN_VCARD_P_H +#define JREEN_VCARD_P_H #include "vcard.h" #include "jid.h" @@ -147,4 +147,4 @@ public: }; } -#endif // VCARD_P_H +#endif // JREEN_VCARD_P_H diff --git a/src/vcardfactory_p.h b/src/vcardfactory_p.h index 0501e35..8e9100f 100644 --- a/src/vcardfactory_p.h +++ b/src/vcardfactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef VCARDFACTORY_P_H -#define VCARDFACTORY_P_H +#ifndef JREEN_VCARDFACTORY_P_H +#define JREEN_VCARDFACTORY_P_H #include "vcard_p.h" #include "stanzaextension.h" #include <QPair> @@ -127,4 +127,4 @@ private: } // namespace Jreen -#endif // VCARDFACTORY_P_H +#endif // JREEN_VCARDFACTORY_P_H diff --git a/src/vcardmanager.cpp b/src/vcardmanager.cpp index 29a59e5..ac03c0d 100644 --- a/src/vcardmanager.cpp +++ b/src/vcardmanager.cpp @@ -28,6 +28,7 @@ #include "iq.h" #include "client.h" #include "vcardupdate.h" +#include <QPointer> namespace Jreen { @@ -102,7 +103,7 @@ public: void _q_received(const Jreen::IQ &iq); VCardReply *q_ptr; - QWeakPointer<VCardManager> manager; + QPointer<VCardManager> manager; JID jid; VCard::Ptr vcard; Error::Ptr error; diff --git a/src/vcardmanager.h b/src/vcardmanager.h index a2577e1..f9e22cd 100644 --- a/src/vcardmanager.h +++ b/src/vcardmanager.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef VCARDMANAGER_H -#define VCARDMANAGER_H +#ifndef JREEN_VCARDMANAGER_H +#define JREEN_VCARDMANAGER_H #include "vcard.h" #include "vcardupdate.h" @@ -86,4 +86,4 @@ private: }; } -#endif // VCARDMANAGER_H +#endif // JREEN_VCARDMANAGER_H diff --git a/src/vcardupdate.h b/src/vcardupdate.h index 5272d74..c69fccd 100644 --- a/src/vcardupdate.h +++ b/src/vcardupdate.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef VCARDUPDATE_H -#define VCARDUPDATE_H +#ifndef JREEN_VCARDUPDATE_H +#define JREEN_VCARDUPDATE_H #include "stanzaextension.h" namespace Jreen @@ -54,4 +54,4 @@ private: } // namespace Jreen -#endif // VCARDUPDATE_H +#endif // JREEN_VCARDUPDATE_H diff --git a/src/vcardupdatefactory_p.h b/src/vcardupdatefactory_p.h index 093fff2..bf7d7c9 100644 --- a/src/vcardupdatefactory_p.h +++ b/src/vcardupdatefactory_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef VCARDUPDATEFACTORY_P_H -#define VCARDUPDATEFACTORY_P_H +#ifndef JREEN_VCARDUPDATEFACTORY_P_H +#define JREEN_VCARDUPDATEFACTORY_P_H #include "vcardupdate.h" namespace Jreen { @@ -50,4 +50,4 @@ private: } // namespace Jreen -#endif // VCARDUPDATEFACTORY_P_H +#endif // JREEN_VCARDUPDATEFACTORY_P_H diff --git a/src/xmlentity_p.h b/src/xmlentity_p.h index a955fa1..6385e27 100644 --- a/src/xmlentity_p.h +++ b/src/xmlentity_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef XMLENTITY_H -#define XMLENTITY_H +#ifndef JREEN_XMLENTITY_P_H +#define JREEN_XMLENTITY_P_H #include "jreen.h" #include <QSharedPointer> @@ -59,7 +59,7 @@ namespace Jreen typedef QSharedPointer<Class> Ptr; \ static int staticXmlEntityType() \ { \ - static QBasicAtomicInt entityType = Q_BASIC_ATOMIC_INITIALIZER(0); \ + static int entityType = 0; \ if (!entityType) { \ entityType = XmlEntity::registerXmlEntityType( #Class ); \ Class *useFullNameWithNamespaces = reinterpret_cast< ::Class* >(0); \ @@ -74,4 +74,4 @@ namespace Jreen } \ private: -#endif // XMLENTITY_H +#endif // JREEN_XMLENTITY_P_H diff --git a/src/zlibcompressionfeature_p.h b/src/zlibcompressionfeature_p.h index c0f2df8..2bafeb0 100644 --- a/src/zlibcompressionfeature_p.h +++ b/src/zlibcompressionfeature_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ZLIBCOMPRESSIONFEATURE_H -#define ZLIBCOMPRESSIONFEATURE_H +#ifndef JREEN_ZLIBCOMPRESSIONFEATURE_P_H +#define JREEN_ZLIBCOMPRESSIONFEATURE_P_H #include "streamfeature_p.h" #include <QStringList> @@ -56,4 +56,4 @@ namespace Jreen }; } -#endif // ZLIBCOMPRESSIONFEATURE_H +#endif // JREEN_ZLIBCOMPRESSIONFEATURE_P_H diff --git a/src/zlibdatastream.cpp b/src/zlibdatastream.cpp index fc26870..8e2245a 100644 --- a/src/zlibdatastream.cpp +++ b/src/zlibdatastream.cpp @@ -129,7 +129,7 @@ qint64 ZLibDataStream::readData(char *data, qint64 maxlen) { Q_D(ZLibDataStream); int len = qMin<int>(maxlen, d->len); - qMemCopy(data, d->buffer.data() + d->offset, len); + memcpy(data, d->buffer.data() + d->offset, len); if (maxlen < d->len) { d->len -= maxlen; d->offset += maxlen; diff --git a/src/zlibdatastream_p.h b/src/zlibdatastream_p.h index 9728768..cc2c80a 100644 --- a/src/zlibdatastream_p.h +++ b/src/zlibdatastream_p.h @@ -23,8 +23,8 @@ ** ****************************************************************************/ -#ifndef ZLIBDATASTREAM_H -#define ZLIBDATASTREAM_H +#ifndef JREEN_ZLIBDATASTREAM_P_H +#define JREEN_ZLIBDATASTREAM_P_H #include "datastream.h" @@ -51,4 +51,4 @@ namespace Jreen }; } -#endif // ZLIBDATASTREAM_H +#endif // JREEN_ZLIBDATASTREAM_P_H
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor