diff --git a/backends/libpurple/spectrumeventloop.cpp b/backends/libpurple/spectrumeventloop.cpp deleted file mode 100644 index 7948c9661fcbe0d6504064d3555e2940624d4d47..0000000000000000000000000000000000000000 --- a/backends/libpurple/spectrumeventloop.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/** - * XMPP - libpurple transport - * - * Copyright (C) 2009, Jan Kaluza - * - * 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 - -#ifdef WITH_LIBEVENT -#include -#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(bool libev) : m_isRunning(false) { - m_loop = NULL; - loop = this; -#ifdef WITH_LIBEVENT - 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); -}