libpurple-backend win32 fix

This commit is contained in:
Vitaly Takmazov 2011-10-21 17:41:20 +04:00
parent 959846374f
commit 544cac803e
5 changed files with 48 additions and 18 deletions

View file

@ -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)

View file

@ -21,6 +21,8 @@
#include "geventloop.h"
#ifdef _WIN32
#include "win32/win32dep.h"
#undef read
#undef write
#endif
#ifdef WITH_LIBEVENT
#include "event.h"

View file

@ -1,5 +1,6 @@
#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);
}

View file

@ -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)

View file

@ -2,7 +2,7 @@ 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)
ADD_LIBRARY(transport-plugin STATIC ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ../../src/memoryusage.cpp ${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc)
ADD_DEPENDENCIES(transport-plugin pb)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc PROPERTIES GENERATED 1)
@ -16,12 +16,6 @@ else()
TARGET_LINK_LIBRARIES(transport-plugin ${PROTOBUF_LIBRARIES} ${LOG4CXX_LIBRARIES} ws2_32.lib)
endif()
if (NOT WIN32)
TARGET_LINK_LIBRARIES(transport-plugin ${PROTOBUF_LIBRARIES} ${LOG4CXX_LIBRARIES})
else()
TARGET_LINK_LIBRARIES(transport-plugin ${PROTOBUF_LIBRARIES} ${LOG4CXX_LIBRARIES} ws2_32.lib)
endif()
SET_TARGET_PROPERTIES(transport-plugin PROPERTIES
VERSION ${TRANSPORT_VERSION} SOVERSION ${TRANSPORT_VERSION}
)