Changeset - 14ff0a11d657
[Not reviewed]
0 8 0
HanzZ - 14 years ago 2011-10-11 19:27:22
hanzz.k@gmail.com
working service.eventloop=libev config to run libpurple with eventloop
8 files changed with 38 insertions and 16 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -37,12 +37,15 @@ find_package(Protobuf REQUIRED)
 
set(IRCClientQt_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(IRCClientQt)
 

	
 
set(log4cxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(log4cxx)
 

	
 
set(event_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(event)
 

	
 
find_package(Doxygen)
 

	
 
INCLUDE(FindQt4)
 
FIND_PACKAGE(Qt4 COMPONENTS QtCore)
 

	
 
# ADD_DEFINITIONS(${SWIFTEN_CFLAGS})
 
@@ -79,12 +82,20 @@ if (PROTOBUF_FOUND)
 
		include_directories(${PURPLE_INCLUDE_DIR})
 
		include_directories(${GLIB2_INCLUDE_DIR})
 
	else()
 
		message("Libpurple plugin  : no (install libpurple)")
 
	endif()
 

	
 
	if (HAVE_EVENT)
 
		ADD_DEFINITIONS(-DWITH_LIBEVENT)
 
		include_directories(${EVENT_INCLUDE_DIRS})
 
		message("  libev eventloop : yes")
 
	else()
 
		message("  libev eventloop : no (install libev-devel)")
 
	endif()
 

	
 
	if(IRC_FOUND)
 
		ADD_DEFINITIONS(-DIRC_SHARED)
 
		message("IRC plugin        : yes")
 
		include_directories(${IRC_INCLUDE_DIR})
 
		include(${QT_USE_FILE})
 
	else()
backends/libpurple/geventloop.cpp
Show inline comments
 
@@ -236,14 +236,19 @@ static PurpleEventLoopUiOps libEventLoopOps =
 
	NULL,
 
	NULL
 
};
 

	
 
#endif /* WITH_LIBEVENT*/
 

	
 
PurpleEventLoopUiOps * getEventLoopUiOps(void){
 
	return &eventLoopOps;
 
PurpleEventLoopUiOps * getEventLoopUiOps(bool libev){
 
#ifdef WITH_LIBEVENT
 
	std::cout << "EPOLL\n";
 
	if (libev) {
 
		event_init();
 
		events = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
 
		return &libEventLoopOps;
 
	}
 
	else {
 
		return &eventLoopOps;
 
	}
 
#endif
 
	return &eventLoopOps;
 
}
backends/libpurple/geventloop.h
Show inline comments
 
@@ -25,9 +25,9 @@
 
#include "purple.h"
 
#include "eventloop.h"
 

	
 
#define READ_COND  (G_IO_IN | G_IO_HUP | G_IO_ERR)
 
#define WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
 

	
 
PurpleEventLoopUiOps * getEventLoopUiOps(void);
 
PurpleEventLoopUiOps * getEventLoopUiOps(bool libev);
 

	
 
#endif
backends/libpurple/main.cpp
Show inline comments
 
@@ -1584,13 +1584,16 @@ static bool initPurple(Config &cfg) {
 

	
 
// 	if (m_configuration.logAreas & LOG_AREA_PURPLE)
 
		purple_debug_set_ui_ops(&debugUiOps);
 
		purple_debug_set_verbose(true);
 

	
 
	purple_core_set_ui_ops(&coreUiOps);
 
	purple_eventloop_set_ui_ops(getEventLoopUiOps());
 
	std::map<std::string, std::string> unregistered = cfg.getUnregistered();
 
	if (unregistered.find("service.eventloop") != unregistered.end()) {
 
		purple_eventloop_set_ui_ops(getEventLoopUiOps(unregistered["service.eventloop"] == "libev"));
 
	}
 

	
 
	ret = purple_core_init("spectrum");
 
	if (ret) {
 
		static int blist_handle;
 
		static int conversation_handle;
 

	
 
@@ -1741,13 +1744,14 @@ int main(int argc, char **argv) {
 
			p.setProperty("jid", CONFIG_STRING(&config, "service.jid"));
 
			log4cxx::PropertyConfigurator::configure(p);
 
		}
 

	
 
		initPurple(config);
 

	
 
		SpectrumEventLoop eventLoop;
 
		std::map<std::string, std::string> unregistered = config.getUnregistered();
 
		SpectrumEventLoop eventLoop(unregistered["service.eventloop"] == "libev");
 
		np = new SpectrumNetworkPlugin(&config, &eventLoop, host, port);
 
		eventLoop.run();
 
	}
 

	
 
	g_option_context_free(context);
 
}
backends/libpurple/spectrumeventloop.cpp
Show inline comments
 
@@ -42,24 +42,22 @@ static gboolean processEvent(void *data) {
 
	Event *ev = (Event *) data;
 
	LOG4CXX_INFO(logger, "got event in main thread " << ev);
 
	loop->handle(ev);
 
	return FALSE;
 
}
 

	
 
SpectrumEventLoop::SpectrumEventLoop() : m_isRunning(false) {
 
SpectrumEventLoop::SpectrumEventLoop(bool libev) : m_isRunning(false) {
 
	m_loop = NULL;
 
	loop = this;
 
	if (true) {
 
		m_loop = g_main_loop_new(NULL, FALSE);
 
	}
 
#ifdef WITH_LIBEVENT
 
	else {
 
		/*struct event_base *base = (struct event_base *)*/
 
		event_init();
 
	if (!libev) {
 
		m_loop = g_main_loop_new(NULL, FALSE);
 
	}
 
	return;
 
#endif
 
	m_loop = g_main_loop_new(NULL, FALSE);
 
}
 

	
 
SpectrumEventLoop::~SpectrumEventLoop() {
 
	stop();
 
}
 

	
backends/libpurple/spectrumeventloop.h
Show inline comments
 
@@ -26,13 +26,13 @@
 
#include "glib.h"
 

	
 
// Event loop implementation for Spectrum
 
class SpectrumEventLoop : public Swift::EventLoop {
 
	public:
 
		// Creates event loop according to CONFIG().eventloop settings.
 
		SpectrumEventLoop();
 
		SpectrumEventLoop(bool libev);
 
		~SpectrumEventLoop();
 

	
 
		// Executes the eventloop.
 
		void run();
 

	
 
		// Stops tht eventloop.
cmake_modules/eventConfig.cmake
Show inline comments
 
FIND_PATH(EVENT_INCLUDE_DIRS libev/event.h)
 
FIND_PATH(EVENT_INCLUDE_DIRS event.h PATH_SUFFIXES libev)
 

	
 
SET(EVENT_NAMES ${EVENT_NAMES} ev libev)
 
FIND_LIBRARY(EVENT_LIBRARIES NAMES ${EVENT_NAMES} PATH)
 

	
 
IF(EVENT_INCLUDE_DIRS AND EVENT_LIBRARIES)
 
SET(HAVE_EVENT TRUE)
 
@@ -9,8 +9,8 @@ file(APPEND src/transport_config.h "#define WITH_LIBEVENT 1\n")
 
ELSE(EVENT_INCLUDE_DIRS AND EVENT_LIBRARIES)
 
SET (EVENT_INCLUDE_DIRS "")
 
SET (EVENT_LIBRARIES "")
 
ENDIF(EVENT_INCLUDE_DIRS AND EVENT_LIBRARIES)
 

	
 
IF(HAVE_EVENT)
 
MESSAGE(STATUS "Found Event: ${EVENT_LIBRARIES}")
 
MESSAGE(STATUS "Found Event: ${EVENT_LIBRARIES} ${EVENT_INCLUDE_DIRS}")
 
ENDIF(HAVE_EVENT)
include/Swiften/Network/DummyNetworkFactories.h
Show inline comments
 
@@ -33,12 +33,16 @@ namespace Swift {
 
			}
 

	
 
			virtual Swift::NATTraverser* getNATTraverser() const {
 
				return 0;
 
			}
 

	
 
			Swift::XMLParserFactory* getXMLParserFactory() const {
 
				return 0;
 
			}
 

	
 
		private:
 
			TimerFactory* timerFactory;
 
			ConnectionFactory* connectionFactory;
 
			DomainNameResolver* domainNameResolver;
 
			ConnectionServerFactory* connectionServerFactory;
 
	};
0 comments (0 inline, 0 general)