Changeset - 81beee07a288
[Not reviewed]
0 6 0
HanzZ - 14 years ago 2011-10-23 13:07:26
hanzz.k@gmail.com
Libpurple backend compiles on Windows, yay! thanks _vt
6 files changed with 54 insertions and 16 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/CMakeLists.txt
Show inline comments
 
@@ -3,7 +3,11 @@ FILE(GLOB SRC *.cpp)
 
 
ADD_EXECUTABLE(spectrum2_libpurple_backend ${SRC})
 
 
if(NOT WIN32)
 
target_link_libraries(spectrum2_libpurple_backend ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin pthread)
 
else()
 
target_link_libraries(spectrum2_libpurple_backend ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin)
 
endif()
 
 
INSTALL(TARGETS spectrum2_libpurple_backend RUNTIME DESTINATION bin)
 
backends/libpurple/geventloop.cpp
Show inline comments
 
@@ -21,6 +21,8 @@
 
#include "geventloop.h"
 
#ifdef _WIN32
 
#include "win32/win32dep.h"
 
#undef read
 
#undef write
 
#endif
 
#ifdef WITH_LIBEVENT
 
#include "event.h"
backends/libpurple/main.cpp
Show inline comments
 
#include "glib.h"
 
#include "purple.h"
 
#include <algorithm>
 
#include <iostream>
 

	
 
#include "transport/networkplugin.h"
 
@@ -10,13 +11,10 @@
 
#include "log4cxx/propertyconfigurator.h"
 
#include "log4cxx/helpers/properties.h"
 
#include "log4cxx/helpers/fileinputstream.h"
 
#include "log4cxx/helpers/transcoder.h"
 
#ifndef WIN32 
 
#include "sys/wait.h"
 
#include "sys/signal.h"
 
// #include "valgrind/memcheck.h"
 
#include "malloc.h"
 
#include <algorithm>
 
#include "errno.h"
 

	
 
#include <netinet/if_ether.h>
 
#include <netinet/ip.h>
 
#include <netinet/ip6.h>
 
@@ -27,6 +25,16 @@
 
#include <netdb.h>
 
#include <unistd.h>
 
#include <fcntl.h>
 
#else 
 
#include <process.h>
 
#define getpid _getpid 
 
#define ssize_t SSIZE_T
 
#include "win32/win32dep.h"
 
#endif
 
// #include "valgrind/memcheck.h"
 
#include "malloc.h"
 
#include <algorithm>
 
#include "errno.h"
 

	
 
#ifdef WITH_LIBEVENT
 
#include <event.h>
 
@@ -650,7 +658,9 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 
// 
 
// 				purple_account_destroy(account);
 
				// force returning of memory chunks allocated by libxml2 to kernel
 
#ifndef WIN32
 
				malloc_trim(0);
 
#endif
 
// 				VALGRIND_DO_LEAK_CHECK;
 
			}
 
		}
 
@@ -1210,7 +1220,7 @@ static PurpleConnectionUiOps conn_ui_ops =
 
static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotifyUserInfo *user_info) {
 
	PurpleAccount *account = purple_connection_get_account(gc);
 
	std::string name(purple_normalize(account, who));
 
	std::transform(name.begin(), name.end(), name.begin(),(int(*)(int)) std::tolower);
 
	std::transform(name.begin(), name.end(), name.begin(), ::tolower);
 

	
 
	size_t pos = name.find("/");
 
	if (pos != std::string::npos)
 
@@ -1544,8 +1554,10 @@ static PurpleCoreUiOps coreUiOps =
 
static void signed_on(PurpleConnection *gc, gpointer unused) {
 
	PurpleAccount *account = purple_connection_get_account(gc);
 
	np->handleConnected(np->m_accounts[account]);
 
#ifndef WIN32
 
	// force returning of memory chunks allocated by libxml2 to kernel
 
	malloc_trim(0);
 
#endif
 
}
 

	
 
static void printDebug(PurpleDebugLevel level, const char *category, const char *arg_s) {
 
@@ -1680,7 +1692,7 @@ static bool initPurple() {
 
	}
 
	return ret;
 
}
 

	
 
#ifndef WIN32
 
static void spectrum_sigchld_handler(int sig)
 
{
 
	int status;
 
@@ -1696,6 +1708,7 @@ static void spectrum_sigchld_handler(int sig)
 
		perror(errmsg);
 
	}
 
}
 
#endif
 

	
 
static int create_socket(char *host, int portno) {
 
	struct sockaddr_in serv_addr;
 
@@ -1811,15 +1824,26 @@ int main(int argc, char **argv) {
 

	
 
		if (KEYFILE_STRING("logging", "backend_config").empty()) {
 
			LoggerPtr root = log4cxx::Logger::getRootLogger();
 
#ifndef _MSC_VER
 
			root->addAppender(new ConsoleAppender(new PatternLayout("%d %-5p %c: %m%n")));
 
#else
 
			root->addAppender(new ConsoleAppender(new PatternLayout(L"%d %-5p %c: %m%n")));
 
#endif
 
		}
 
		else {
 
			log4cxx::helpers::Properties p;
 
			log4cxx::helpers::FileInputStream *istream = new log4cxx::helpers::FileInputStream(KEYFILE_STRING("logging", "backend_config"));
 

	
 
			p.load(istream);
 
			p.setProperty("pid", stringOf(getpid()));
 
			p.setProperty("jid", KEYFILE_STRING("service", "jid"));
 
			LogString pid, jid;
 
			log4cxx::helpers::Transcoder::decode(stringOf(getpid()), pid);
 
			log4cxx::helpers::Transcoder::decode(KEYFILE_STRING("service", "service.jid"), jid);
 
#ifdef _MSC_VER
 
			p.setProperty(L"pid", pid);
 
			p.setProperty(L"jid", jid);
 
#else
 
			p.setProperty("pid", pid);
 
			p.setProperty("jid", jid);
 
#endif
 
			log4cxx::PropertyConfigurator::configure(p);
 
		}
 

	
cmake_modules/SwiftenConfig.cmake
Show inline comments
 
@@ -16,8 +16,8 @@ if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
 
			STRING(SUBSTRING ${f} 0 2 f_out)
 
			STRING(COMPARE EQUAL ${f_out} "/L" IS_PATH)
 
			if(${IS_PATH})
 
				message(${f})
 
				string(REGEX REPLACE "/LIBPATH:" ""  f_replaced ${f})
 
				string(REGEX REPLACE "/LIBPATH:" ""  f_replaced "${f}")
 
				message("Added link directory: ${f_replaced}")
 
				link_directories(${f_replaced})
 
			else()
 
				list(APPEND SWIFTEN_LIBRARY ${f})
cmake_modules/glibConfig.cmake
Show inline comments
 
@@ -22,13 +22,19 @@ find_library(GLIB2_LIBRARIES
 
find_library(GLIB2_THREAD
 
             NAMES gthread-2.0
 
             PATHS ${PKG_GLIB_LIBRARY_DIRS} )
 
find_library(GLIB2_OBJECT
 
             NAMES gobject-2.0
 
             PATHS ${PKG_GLIB_LIBRARY_DIRS} )
 
find_library(GLIB2_MODULE
 
             NAMES gmodule-2.0
 
             PATHS ${PKG_GLIB_LIBRARY_DIRS} )
 

	
 
find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
 
          PATH_SUFFIXES glib-2.0/include
 
          PATHS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_LIBRARIES} ${CMAKE_SYSTEM_LIBRARY_PATH})
 

	
 
if(GLIB2_THREAD)
 
	set(GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${GLIB2_THREAD})
 
	set(GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${GLIB2_THREAD} ${GLIB2_MODULE} ${GLIB2_OBJECT})
 
else(GLIB2_THREAD)
 
	message( STATUS "Could NOT find gthread-2.0" )
 
endif(GLIB2_THREAD)
plugin/src/CMakeLists.txt
Show inline comments
 
@@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 2.6)
 
FILE(GLOB SRC *.cpp *.h)
 
FILE(GLOB HEADERS ../include/transport/*.h)
 
 
ADD_LIBRARY(transport-plugin SHARED ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ../../src/memoryusage.cpp ${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc)
 
if (NOT WIN32)
 
	ADD_LIBRARY(transport-plugin SHARED ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ../../src/memoryusage.cpp ${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc)
 
else()
 
	ADD_LIBRARY(transport-plugin STATIC ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ../../src/memoryusage.cpp ${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc)
 
endif()
 
ADD_DEPENDENCIES(transport-plugin pb)
 
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc PROPERTIES GENERATED 1)
 
 
@@ -16,8 +20,6 @@ else()
 
	TARGET_LINK_LIBRARIES(transport-plugin ${PROTOBUF_LIBRARIES} ${LOG4CXX_LIBRARIES} ws2_32.lib)
 
endif() 
 
 
TARGET_LINK_LIBRARIES(transport-plugin ${PROTOBUF_LIBRARIES} ${LOG4CXX_LIBRARIES})
 
 
SET_TARGET_PROPERTIES(transport-plugin PROPERTIES
 
      VERSION ${TRANSPORT_VERSION} SOVERSION ${TRANSPORT_VERSION}
 
)
0 comments (0 inline, 0 general)