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 40 insertions and 18 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
cmake_minimum_required(VERSION 2.6)
 
project(libtransport)
 

	
 
set(CMAKE_MODULE_PATH "cmake_modules")
 

	
 
set(cppunit_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(cppunit)
 

	
 
set(sqlite3_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(sqlite3)
 

	
 
set(mysql_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(mysql)
 

	
 
set(purple_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(purple)
 

	
 
set(glib_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(glib)
 

	
 
set(popt_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(popt)
 

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

	
 
set(Swiften_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(Swiften REQUIRED)
 

	
 
set(Boost_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
find_package(Boost COMPONENTS date_time system filesystem regex thread signals REQUIRED)
 
message( STATUS "Found Boost: ${Boost_LIBRARIES}, ${Boost_INCLUDE_DIR}")
 

	
 
set(Protobuf_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
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})
 
ADD_DEFINITIONS(-DSUPPORT_LEGACY_CAPS)
 
ADD_DEFINITIONS(-DBOOST_FILESYSTEM_VERSION=2)
 

	
 
message("  Supported features")
 
message("-----------------------")
 
if (SQLITE3_FOUND)
 
	ADD_DEFINITIONS(-DWITH_SQLITE)
 
	include_directories(${SQLITE3_INCLUDE_DIR})
 
	message("SQLite3           : yes")
 
else (SQLITE3_FOUND)
 
	set(SQLITE3_LIBRARIES "")
 
	message("SQLite3           : no")
 
endif (SQLITE3_FOUND)
 

	
 
if (MYSQL_FOUND)
 
	ADD_DEFINITIONS(-DWITH_MYSQL)
 
	include_directories(${MYSQL_INCLUDE_DIR})
 
	message("MySQL             : yes")
 
else (MYSQL_FOUND)
 
	set(MYSQL_LIBRARIES "")
 
	message("MySQL             : no (install mysql-devel)")
 
endif (MYSQL_FOUND)
 

	
 
if (PROTOBUF_FOUND)
 
	ADD_DEFINITIONS(-DWITH_PROTOBUF)
 
	include_directories(${PROTOBUF_INCLUDE_DIRS})
 
	message("Network plugins   : yes")
 

	
 
	if(PURPLE_LIBRARY AND PURPLE_INCLUDE_DIR)
 
		message("Libpurple plugin  : yes")
 
		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()
 
		message("IRC plugin        : no (install libircclient-qt and libprotobuf-dev)")
 
	endif()
 

	
 
	message("Frotz plugin      : yes")
 

	
 
else()
 
	message("Network plugins   : no (install libprotobuf-dev)")
 
	message("Libpurple plugin  : no (install libpurple and libprotobuf-dev)")
 
	message("IRC plugin        : no (install libircclient-qt and libprotobuf-dev)")
 
	message("Frotz plugin      : no (install libprotobuf-dev)")
 
endif()
 

	
 
if (LOG4CXX_FOUND)
 
	message("Logging           : yes")
 
	include_directories(${LOG4CXX_INCLUDE_DIR})
 
else()
 
	message(FATAL_ERROR "Logging           : no (install log4cxx-devel)")
 
endif()
 

	
 
if(CMAKE_BUILD_TYPE MATCHES Debug)
 
	ADD_DEFINITIONS(-O3)
 
	ADD_DEFINITIONS(-ggdb)
 
	ADD_DEFINITIONS(-DDEBUG)
 
	ADD_DEFINITIONS(-Wall)
 
	ADD_DEFINITIONS(-W)
 
	ADD_DEFINITIONS(-Wcast-align)
 
	ADD_DEFINITIONS(-Wextra -Wno-sign-compare -Wno-unused-parameter)
 
	ADD_DEFINITIONS(-Winit-self)
 
	ADD_DEFINITIONS(-Wmissing-declarations)
 
	ADD_DEFINITIONS(-Wpointer-arith)
 
	ADD_DEFINITIONS(-Wreorder)
 
	ADD_DEFINITIONS(-Woverloaded-virtual)
 
	ADD_DEFINITIONS(-Wsign-promo)
 
	ADD_DEFINITIONS(-Wundef -Wunused)
 
	message("Debug             : yes")
 
else(CMAKE_BUILD_TYPE MATCHES Debug)
 
	message("Debug             : no (run \"cmake . -DCMAKE_BUILD_TYPE=Debug\")")
 
endif(CMAKE_BUILD_TYPE MATCHES Debug)
 

	
 

	
 
SET(TRANSPORT_VERSION 2.0)
 
SET(PROJECT_VERSION 2.0)
backends/libpurple/geventloop.cpp
Show inline comments
 
@@ -194,56 +194,61 @@ static guint event_input_add(gint fd,
 
	
 
	int *f = (int *) g_malloc(sizeof(int));
 
	*f = id;
 
	id++;
 
	g_hash_table_replace(events, f, closure);
 
	
 
	return *f;
 
}
 

	
 
static guint event_timeout_add (guint interval, GSourceFunc function, gpointer data) {
 
	struct timeval timeout;
 
	PurpleIOClosure *closure = g_new0(PurpleIOClosure, 1);
 
	closure->function2 = function;
 
	closure->data = data;
 
	
 
	timeout.tv_sec = interval/1000;
 
	timeout.tv_usec = (interval%1000)*1000;
 
	evtimer_set(&closure->evfifo, event_io_invoke, closure);
 
	evtimer_add(&closure->evfifo, &timeout);
 
	closure->timeout = timeout;
 
	
 
	guint *f = (guint *) g_malloc(sizeof(guint));
 
	*f = id;
 
	id++;
 
	g_hash_table_replace(events, f, closure);
 
	return *f;
 
}
 

	
 
static PurpleEventLoopUiOps libEventLoopOps =
 
{
 
	event_timeout_add,
 
	event_input_remove,
 
	event_input_add,
 
	event_input_remove,
 
	NULL,
 
// #if GLIB_CHECK_VERSION(2,14,0)
 
// 	g_timeout_add_seconds,
 
// #else
 
	NULL,
 
// #endif
 

	
 
	NULL,
 
	NULL,
 
	NULL
 
};
 

	
 
#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;
 
}
backends/libpurple/geventloop.h
Show inline comments
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
 
 *
 
 * This program is free software; you can redistribute it and/or modify
 
 * it under the terms of the GNU General Public License as published by
 
 * the Free Software Foundation; either version 2 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#ifndef _HI_EVENTLOOP_H
 
#define _HI_EVENTLOOP_H
 

	
 
#include <glib.h>
 
#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
 
@@ -1542,97 +1542,100 @@ static PurpleDebugUiOps debugUiOps =
 
	NULL,
 
	NULL
 
};
 

	
 
static void buddyTyping(PurpleAccount *account, const char *who, gpointer null) {
 
	std::string w = purple_normalize(account, who);
 
	size_t pos = w.find("/");
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleBuddyTyping(np->m_accounts[account], w);
 
}
 

	
 
static void buddyTyped(PurpleAccount *account, const char *who, gpointer null) {
 
	std::string w = purple_normalize(account, who);
 
	size_t pos = w.find("/");
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleBuddyTyped(np->m_accounts[account], w);
 
}
 

	
 
static void buddyTypingStopped(PurpleAccount *account, const char *who, gpointer null){
 
	std::string w = purple_normalize(account, who);
 
	size_t pos = w.find("/");
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleBuddyStoppedTyping(np->m_accounts[account], w);
 
}
 

	
 
static void gotAttention(PurpleAccount *account, const char *who, PurpleConversation *conv, guint type) {
 
	std::string w = purple_normalize(account, who);
 
	size_t pos = w.find("/");
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleAttention(np->m_accounts[account], w, "");
 
}
 

	
 
static bool initPurple(Config &cfg) {
 
	bool ret;
 

	
 
	purple_util_set_user_dir("./");
 
	remove("./accounts.xml");
 
	remove("./blist.xml");
 

	
 
// 	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;
 

	
 
		purple_set_blist(purple_blist_new());
 
		purple_blist_load();
 

	
 
		purple_prefs_load();
 

	
 
		/* Good default preferences */
 
		/* The combination of these two settings mean that libpurple will never
 
		 * (of its own accord) set all the user accounts idle.
 
		 */
 
		purple_prefs_set_bool("/purple/away/away_when_idle", false);
 
		/*
 
		 * This must be set to something not "none" for idle reporting to work
 
		 * for, e.g., the OSCAR prpl. We don't implement the UI ops, so this is
 
		 * okay for now.
 
		 */
 
		purple_prefs_set_string("/purple/away/idle_reporting", "system");
 

	
 
		/* Disable all logging */
 
		purple_prefs_set_bool("/purple/logging/log_ims", false);
 
		purple_prefs_set_bool("/purple/logging/log_chats", false);
 
		purple_prefs_set_bool("/purple/logging/log_system", false);
 

	
 

	
 
// 		purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", &conversation_handle, PURPLE_CALLBACK(newMessageReceived), NULL);
 
		purple_signal_connect(purple_conversations_get_handle(), "buddy-typing", &conversation_handle, PURPLE_CALLBACK(buddyTyping), NULL);
 
		purple_signal_connect(purple_conversations_get_handle(), "buddy-typed", &conversation_handle, PURPLE_CALLBACK(buddyTyped), NULL);
 
		purple_signal_connect(purple_conversations_get_handle(), "buddy-typing-stopped", &conversation_handle, PURPLE_CALLBACK(buddyTypingStopped), NULL);
 
		purple_signal_connect(purple_blist_get_handle(), "buddy-privacy-changed", &conversation_handle, PURPLE_CALLBACK(buddyPrivacyChanged), NULL);
 
		purple_signal_connect(purple_conversations_get_handle(), "got-attention", &conversation_handle, PURPLE_CALLBACK(gotAttention), NULL);
 
		purple_signal_connect(purple_connections_get_handle(), "signed-on", &blist_handle,PURPLE_CALLBACK(signed_on), NULL);
 
// 		purple_signal_connect(purple_blist_get_handle(), "buddy-removed", &blist_handle,PURPLE_CALLBACK(buddyRemoved), NULL);
 
// 		purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", &blist_handle,PURPLE_CALLBACK(buddySignedOn), NULL);
 
// 		purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", &blist_handle,PURPLE_CALLBACK(buddySignedOff), NULL);
 
// 		purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed", &blist_handle,PURPLE_CALLBACK(buddyStatusChanged), NULL);
 
		purple_signal_connect(purple_blist_get_handle(), "blist-node-removed", &blist_handle,PURPLE_CALLBACK(NodeRemoved), NULL);
 
// 		purple_signal_connect(purple_conversations_get_handle(), "chat-topic-changed", &conversation_handle, PURPLE_CALLBACK(conv_chat_topic_changed), NULL);
 
		static int xfer_handle;
 
		purple_signal_connect(purple_xfers_get_handle(), "file-send-start", &xfer_handle, PURPLE_CALLBACK(fileSendStart), NULL);
 
		purple_signal_connect(purple_xfers_get_handle(), "file-recv-start", &xfer_handle, PURPLE_CALLBACK(fileRecvStart), NULL);
 
		purple_signal_connect(purple_xfers_get_handle(), "file-recv-request", &xfer_handle, PURPLE_CALLBACK(newXfer), NULL);
 
		purple_signal_connect(purple_xfers_get_handle(), "file-recv-complete", &xfer_handle, PURPLE_CALLBACK(XferReceiveComplete), NULL);
 
		purple_signal_connect(purple_xfers_get_handle(), "file-send-complete", &xfer_handle, PURPLE_CALLBACK(XferSendComplete), NULL);
 
@@ -1699,55 +1702,56 @@ int main(int argc, char **argv) {
 
			std::cout << "SIGCHLD handler can't be set\n";
 
			g_option_context_free(context);
 
			return -1;
 
		}
 
// 
 
// 		if (signal(SIGINT, spectrum_sigint_handler) == SIG_ERR) {
 
// 			std::cout << "SIGINT handler can't be set\n";
 
// 			g_option_context_free(context);
 
// 			return -1;
 
// 		}
 
// 
 
// 		if (signal(SIGTERM, spectrum_sigterm_handler) == SIG_ERR) {
 
// 			std::cout << "SIGTERM handler can't be set\n";
 
// 			g_option_context_free(context);
 
// 			return -1;
 
// 		}
 
// 
 
// 		struct sigaction sa;
 
// 		memset(&sa, 0, sizeof(sa)); 
 
// 		sa.sa_handler = spectrum_sighup_handler;
 
// 		if (sigaction(SIGHUP, &sa, NULL)) {
 
// 			std::cout << "SIGHUP handler can't be set\n";
 
// 			g_option_context_free(context);
 
// 			return -1;
 
//		}
 
#endif
 
		Config config;
 
		if (!config.load(argv[1])) {
 
			std::cout << "Can't open " << argv[1] << " configuration file.\n";
 
			return 1;
 
		}
 

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

	
 
			p.load(istream);
 
			p.setProperty("pid", boost::lexical_cast<std::string>(getpid()));
 
			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
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
 
 *
 
 * This program is free software; you can redistribute it and/or modify
 
 * it under the terms of the GNU General Public License as published by
 
 * the Free Software Foundation; either version 2 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#include "spectrumeventloop.h"
 
#include "purple.h"
 

	
 
#include <iostream>
 

	
 
#ifdef WITH_LIBEVENT
 
#include <event.h>
 
#endif
 

	
 
#include "log4cxx/logger.h"
 

	
 
using namespace log4cxx;
 

	
 
static LoggerPtr logger = Logger::getLogger("SpectrumEventLoop");
 

	
 
using namespace Swift;
 

	
 
static SpectrumEventLoop *loop;
 

	
 
// Fires the event's callback and frees the event
 
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();
 
}
 

	
 
void SpectrumEventLoop::run() {
 
	m_isRunning = true;
 
	if (m_loop) {
 
		g_main_loop_run(m_loop);
 
	}
 
#ifdef WITH_LIBEVENT
 
	else {
 
		event_loop(0);
 
	}
 
#endif
 
}
 

	
 
void SpectrumEventLoop::handle(Swift::Event *event) {
 
	handleEvent(*event);
 
	delete event;
 
}
 

	
 
void SpectrumEventLoop::stop() {
 
	std::cout << "stopped loop\n";
 
	if (!m_isRunning)
 
		return;
 
	if (m_loop) {
 
		g_main_loop_quit(m_loop);
 
		g_main_loop_unref(m_loop);
 
		m_loop = NULL;
 
	}
 
#ifdef WITH_LIBEVENT
 
	else {
 
		event_loopexit(NULL);
 
	}
 
#endif
 
}
 

	
 
void SpectrumEventLoop::post(const Event& event) {
 
	// pass copy of event to main thread
 
	Event *ev = new Event(event);
 
	LOG4CXX_INFO(logger, "posting event to main thread " << ev);
 
// 	g_main_context_invoke(g_main_loop_get_context(m_loop), processEvent, ev);
 
	purple_timeout_add(100, processEvent, ev);
 
}
backends/libpurple/spectrumeventloop.h
Show inline comments
 
/**
 
 * XMPP - libpurple transport
 
 *
 
 * Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
 
 *
 
 * This program is free software; you can redistribute it and/or modify
 
 * it under the terms of the GNU General Public License as published by
 
 * the Free Software Foundation; either version 2 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#ifndef SPECTRUM_EVENT_LOOP_H
 
#define SPECTRUM_EVENT_LOOP_H
 

	
 
#include <vector>
 
#include "Swiften/EventLoop/EventLoop.h"
 
#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.
 
		void stop();
 

	
 
		void handle(Swift::Event *event);
 

	
 
		// Posts new Swift::Event to main thread.
 
		virtual void post(const Swift::Event& event);
 

	
 
	private:
 
		bool m_isRunning;
 
		GMainLoop *m_loop;
 
};
 

	
 
#endif
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)
 
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
 
/*
 
 * Copyright (c) 2010 Remko Tronçon
 
 * Licensed under the GNU General Public License v3.
 
 * See Documentation/Licenses/GPLv3.txt for more information.
 
 */
 

	
 
#pragma once
 

	
 
#include <Swiften/Network/NetworkFactories.h>
 

	
 
namespace Swift {
 
	class EventLoop;
 

	
 
	class DummyNetworkFactories : public NetworkFactories {
 
		public:
 
			DummyNetworkFactories(EventLoop *eventLoop);
 
			~DummyNetworkFactories();
 

	
 
			virtual TimerFactory* getTimerFactory() const {
 
				return timerFactory;
 
			}
 

	
 
			virtual ConnectionFactory* getConnectionFactory() const {
 
				return connectionFactory;
 
			}
 

	
 
			DomainNameResolver* getDomainNameResolver() const {
 
				return domainNameResolver;
 
			}
 

	
 
			ConnectionServerFactory* getConnectionServerFactory() const {
 
				return connectionServerFactory;
 
			}
 

	
 
			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)