Changeset - d363189d97b8
[Not reviewed]
0 4 0
Vitaly Takmazov - 8 years ago 2017-06-14 18:40:45
vitalyster@gmail.com
MSVC compatibility fixes
4 files changed with 9 insertions and 4 deletions:
0 comments (0 inline, 0 general)
cmake_modules/SwiftenConfig.cmake
Show inline comments
 
FIND_LIBRARY(SWIFTEN_LIBRARY NAMES Swiften Swiften3 HINTS ../lib)
 
FIND_LIBRARY(SWIFTEN_LIBRARY NAMES Swiften Swiften3 Swiften4 HINTS ../lib)
 
FIND_PATH(SWIFTEN_INCLUDE_DIR NAMES "Swiften/Swiften.h" PATH_SUFFIXES libSwiften Swiften HINTS ../include)
 

	
 
if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
 
	find_program(SWIFTEN_CONFIG_EXECUTABLE NAMES swiften-config DOC "swiften-config executable" HINTS ../bin)
 
	set( SWIFTEN_CFLAGS "" )
 
	if (SWIFTEN_CONFIG_EXECUTABLE)
 
		# Libs
 
		execute_process(
 
			COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --libs
 
			OUTPUT_VARIABLE SWIFTEN_LIB)
 
		string(REGEX REPLACE "[\r\n]"                  " " SWIFTEN_LIB "${SWIFTEN_LIB}")
 
		string(REGEX REPLACE " +$"                     ""  SWIFTEN_LIB "${SWIFTEN_LIB}")
 
		set(SWIFTEN_LIBRARY "")
 
		if (APPLE)
 
			string(REGEX MATCHALL "-framework [A-Za-z]+" APPLE_FRAMEWORKS "${SWIFTEN_LIB}")
 
			foreach(framework ${APPLE_FRAMEWORKS})
 
				list(APPEND SWIFTEN_LIBRARY ${framework} )
 
			endforeach(framework)
 
			string(REGEX REPLACE "-framework [A-Za-z]+" "" SWIFTEN_LIB "${SWIFTEN_LIB}")
 
		endif(APPLE)
 
		string(REGEX REPLACE " " ";" SWIFTEN_LIB "${SWIFTEN_LIB}")
 
		foreach(f ${SWIFTEN_LIB})
 
			STRING(SUBSTRING ${f} 0 2 f_out)
 
			STRING(COMPARE EQUAL ${f_out} "/L" IS_PATH)
 
			if(${IS_PATH})
 
				string(REGEX REPLACE "/LIBPATH:" ""  f_replaced "${f}")
 
				message("Added link directory: ${f_replaced}")
 
				link_directories(${f_replaced})
 
			else()
 
				list(APPEND SWIFTEN_LIBRARY ${f})
 
			endif()
 
		endforeach(f)
 
		
 
		# Version
 
		execute_process(
 
			COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --version
 
			OUTPUT_VARIABLE SWIFTEN_VERSION)
 
		string(REGEX REPLACE "[\r\n]"                  " " SWIFTEN_VERSION "${SWIFTEN_VERSION}")
 
		string(REGEX REPLACE " +$"                     ""  SWIFTEN_VERSION "${SWIFTEN_VERSION}")
 
		string(REGEX REPLACE "swiften-config "          ""  SWIFTEN_VERSION "${SWIFTEN_VERSION}")
 

	
 
		if("${SWIFTEN_VERSION}" STRGREATER "4")
 
		if("${SWIFTEN_VERSION}" STRGREATER "4" AND NOT MSVC)
 
			message( STATUS "Found Swiften > 4 requesting C++11")
 
			add_definitions(-std=c++11)
 
		endif()
 
		
 
		set( SWIFTEN_FOUND 1 )
 
	else()
 
		message( STATUS "Could NOT find swiften-config" )
 
	endif()
 

	
 
	if (SWIFTEN_FOUND)
 
		set( SWIFTEN_INCLUDE_DIR ${SWIFTEN_INCLUDE_DIR} )
 
		message( STATUS "Found libSwiften: ${SWIFTEN_LIBRARY}, ${SWIFTEN_INCLUDE_DIR}")
 
	endif()
 

	
 
else( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
 
    message( STATUS "Could NOT find libSwiften" )
 
endif( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
include/Swiften/TLS/Schannel/SchannelServerContext.h
Show inline comments
 
/*
 
 * Copyright (c) 2011 Soren Dreijer
 
 * Licensed under the simplified BSD license.
 
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 
 */
 

	
 
#pragma once
 

	
 
#include "Swiften/TLS/TLSServerContext.h"
 
#include "Swiften/TLS/Schannel/SchannelUtil.h"
 
#include <Swiften/TLS/CertificateWithKey.h>
 
#include "Swiften/Base/ByteArray.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
#define SECURITY_WIN32
 
#include <Windows.h>
 
#include <Schannel.h>
 
#include <security.h>
 
#include <schnlsp.h>
 

	
 
#include <boost/noncopyable.hpp>
 

	
 
namespace Swift 
 
{	
 
	class SchannelServerContext : public TLSServerContext, boost::noncopyable 
 
	{
 
	public:
 
		typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SchannelServerContext> sp_t;
 

	
 
	public:
 
		SchannelServerContext();
 

	
 
		~SchannelServerContext();
 

	
 
		//
 
		// TLSContext
 
		//
tests/libtransport/HTTPRequest.cpp
Show inline comments
 
#include <cppunit/TestFixture.h>
 
#include <cppunit/extensions/HelperMacros.h>
 
#include <Swiften/Swiften.h>
 
#include <Swiften/EventLoop/DummyEventLoop.h>
 
#include <Swiften/Server/Server.h>
 
#include <Swiften/Network/DummyNetworkFactories.h>
 
#include <Swiften/Network/DummyConnectionServer.h>
 
#include <Swiften/Elements/VCardUpdate.h>
 
#include "Swiften/Server/ServerStanzaChannel.h"
 
#include "Swiften/Server/ServerFromClientSession.h"
 
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
 
#include "basictest.h"
 

	
 
#include "transport/ThreadPool.h"
 
#include "transport/HTTPRequest.h"
 

	
 
using namespace Transport;
 

	
 
#if !HAVE_SWIFTEN_3
 
#define get_value_or(X) substr()
 
#endif
 

	
 
#ifdef _MSC_VER
 
#define sleep Sleep
 
#endif
 

	
 
class HTTPRequestTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
	CPPUNIT_TEST_SUITE(HTTPRequestTest);
 
	CPPUNIT_TEST(GETThreadPool);
 
	CPPUNIT_TEST_SUITE_END();
 

	
 
	public:
 
		ThreadPool *tp;
 
		bool result;
 

	
 
		void setUp (void) {
 
			setMeUp();
 
			tp = new ThreadPool(loop, 10);
 
			result = false;
 
		}
 

	
 
		void tearDown (void) {
 
			tearMeDown();
 
			delete tp;
 
		}
 

	
 
	void handleResult(HTTPRequest *req, bool ok, rapidjson::Document &resp, const std::string &data) {
 
		result = true;
 
	}
 

	
tests/libtransport/main.cpp
Show inline comments
 
#include "main.h"
 
#include <cppunit/CompilerOutputter.h>
 
#include <cppunit/extensions/TestFactoryRegistry.h>
 
#include <cppunit/TestResult.h>
 
#include <cppunit/TestResultCollector.h>
 
#include <cppunit/TestRunner.h>
 
#include <cppunit/BriefTestProgressListener.h>
 
#ifdef WITH_LOG4CXX
 
#include "log4cxx/logger.h"
 
#include "log4cxx/fileappender.h"
 
#include "log4cxx/patternlayout.h"
 
#include "log4cxx/propertyconfigurator.h"
 
using namespace log4cxx;
 
#endif
 

	
 
#include "transport/protocol.pb.h"
 
#include "transport/HTTPRequest.h"
 

	
 
using namespace log4cxx;
 
#endif
 

	
 

	
 
int main (int argc, char* argv[])
 
{
 
#ifdef WITH_LOG4CXX
 
	LoggerPtr root = Logger::getRootLogger();
 
#ifndef _MSC_VER
 
	root->addAppender(new FileAppender(new PatternLayout("%d %-5p %c: %m%n"), "libtransport_test.log", false));
 
#else
 
	root->addAppender(new FileAppender(new PatternLayout(L"%d %-5p %c: %m%n"), L"libtransport_test.log", false));
 
#endif
 
#endif
 

	
 
	std::vector<std::string> testsToRun;
 
	for (int i = 1; i < argc; ++i) {
 
		std::string param(argv[i]);
 
		testsToRun.push_back(param);
 
	}
 

	
 
	if (testsToRun.empty()) {
 
		testsToRun.push_back("");
 
	}
 

	
 
	Transport::HTTPRequest::globalInit();
0 comments (0 inline, 0 general)