working service.eventloop=libev config to run libpurple with eventloop
This commit is contained in:
parent
0f1f6f50f0
commit
14ff0a11d6
8 changed files with 40 additions and 18 deletions
|
@ -40,6 +40,9 @@ 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)
|
||||
|
@ -82,6 +85,14 @@ if (PROTOBUF_FOUND)
|
|||
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")
|
||||
|
|
|
@ -239,11 +239,16 @@ static PurpleEventLoopUiOps libEventLoopOps =
|
|||
|
||||
#endif /* WITH_LIBEVENT*/
|
||||
|
||||
PurpleEventLoopUiOps * getEventLoopUiOps(void){
|
||||
return &eventLoopOps;
|
||||
PurpleEventLoopUiOps * getEventLoopUiOps(bool libev){
|
||||
#ifdef WITH_LIBEVENT
|
||||
std::cout << "EPOLL\n";
|
||||
events = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
|
||||
return &libEventLoopOps;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,6 @@
|
|||
#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
|
||||
|
|
|
@ -1587,7 +1587,10 @@ static bool initPurple(Config &cfg) {
|
|||
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) {
|
||||
|
@ -1744,7 +1747,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -45,18 +45,16 @@ static gboolean processEvent(void *data) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
SpectrumEventLoop::SpectrumEventLoop() : m_isRunning(false) {
|
||||
SpectrumEventLoop::SpectrumEventLoop(bool libev) : m_isRunning(false) {
|
||||
m_loop = NULL;
|
||||
loop = this;
|
||||
if (true) {
|
||||
#ifdef WITH_LIBEVENT
|
||||
if (!libev) {
|
||||
m_loop = g_main_loop_new(NULL, FALSE);
|
||||
}
|
||||
#ifdef WITH_LIBEVENT
|
||||
else {
|
||||
/*struct event_base *base = (struct event_base *)*/
|
||||
event_init();
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
m_loop = g_main_loop_new(NULL, FALSE);
|
||||
}
|
||||
|
||||
SpectrumEventLoop::~SpectrumEventLoop() {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
class SpectrumEventLoop : public Swift::EventLoop {
|
||||
public:
|
||||
// Creates event loop according to CONFIG().eventloop settings.
|
||||
SpectrumEventLoop();
|
||||
SpectrumEventLoop(bool libev);
|
||||
~SpectrumEventLoop();
|
||||
|
||||
// Executes the eventloop.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
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)
|
||||
|
@ -12,5 +12,5 @@ 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)
|
||||
|
|
|
@ -36,6 +36,10 @@ namespace Swift {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Swift::XMLParserFactory* getXMLParserFactory() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
TimerFactory* timerFactory;
|
||||
ConnectionFactory* connectionFactory;
|
||||
|
|
Loading…
Add table
Reference in a new issue