diff --git a/CMakeLists.txt b/CMakeLists.txt index 261af42c..e798a842 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,9 @@ find_package(event) set(pqxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules") find_package(pqxx) +set(dbus_DIR "${CMAKE_SOURCE_DIR}/cmake_modules") +find_package(dbus) + find_package(Doxygen) INCLUDE(FindQt4) @@ -146,12 +149,21 @@ if (PROTOBUF_FOUND) endif() message("Frotz plugin : yes") + message("SMSTools3 plugin : yes") + + if(${LIBDBUSGLIB_FOUND}) + message("Skype plugin : yes") + include_directories(${LIBDBUSGLIB_INCLUDE_DIRS}) + else() + message("Skype plugin : no (install dbus-glib-devel)") + endif() 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)") + message("SMSTools3 plugin : no (install libprotobuf-dev)") endif() if (LOG4CXX_FOUND) diff --git a/backends/CMakeLists.txt b/backends/CMakeLists.txt index be7163c5..2bb2c447 100644 --- a/backends/CMakeLists.txt +++ b/backends/CMakeLists.txt @@ -11,7 +11,7 @@ if (PROTOBUF_FOUND) if (NOT WIN32) ADD_SUBDIRECTORY(frotz) -# ADD_SUBDIRECTORY(skype) + ADD_SUBDIRECTORY(skype) endif() endif() diff --git a/backends/skype/CMakeLists.txt b/backends/skype/CMakeLists.txt index fa6e9266..4e611208 100644 --- a/backends/skype/CMakeLists.txt +++ b/backends/skype/CMakeLists.txt @@ -1,13 +1,9 @@ cmake_minimum_required(VERSION 2.6) FILE(GLOB SRC *.cpp) - -include_directories(/usr/include/dbus-1.0/) -include_directories(/usr/lib/dbus-1.0/include/) -include_directories(/usr/lib64/dbus-1.0/include/) ADD_EXECUTABLE(spectrum2_skype_backend ${SRC}) -target_link_libraries(spectrum2_skype_backend ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport pthread dbus-glib-1 dbus-1 gobject-2.0 transport-plugin) +target_link_libraries(spectrum2_skype_backend ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport pthread ${LIBDBUSGLIB_LIBRARIES} transport-plugin) INSTALL(TARGETS spectrum2_skype_backend RUNTIME DESTINATION bin) diff --git a/backends/skype/geventloop.cpp b/backends/skype/geventloop.cpp deleted file mode 100644 index d00d7a56..00000000 --- a/backends/skype/geventloop.cpp +++ /dev/null @@ -1,248 +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 "geventloop.h" -#ifdef _WIN32 -#include "win32/win32dep.h" -#endif -#ifdef WITH_LIBEVENT -#include "event.h" -#endif - -typedef struct _PurpleIOClosure { - PurpleInputFunction function; - guint result; - gpointer data; -#ifdef WITH_LIBEVENT - GSourceFunc function2; - struct timeval timeout; - struct event evfifo; -#endif -} PurpleIOClosure; - -static gboolean io_invoke(GIOChannel *source, - GIOCondition condition, - gpointer data) -{ - PurpleIOClosure *closure = (PurpleIOClosure* )data; - PurpleInputCondition purple_cond = (PurpleInputCondition)0; - - int tmp = 0; - if (condition & READ_COND) - { - tmp |= PURPLE_INPUT_READ; - purple_cond = (PurpleInputCondition)tmp; - } - if (condition & WRITE_COND) - { - tmp |= PURPLE_INPUT_WRITE; - purple_cond = (PurpleInputCondition)tmp; - } - - closure->function(closure->data, g_io_channel_unix_get_fd(source), purple_cond); - - return TRUE; -} - -static void io_destroy(gpointer data) -{ - g_free(data); -} - -static guint input_add(gint fd, - PurpleInputCondition condition, - PurpleInputFunction function, - gpointer data) -{ - PurpleIOClosure *closure = g_new0(PurpleIOClosure, 1); - GIOChannel *channel; - GIOCondition cond = (GIOCondition)0; - closure->function = function; - closure->data = data; - - int tmp = 0; - if (condition & PURPLE_INPUT_READ) - { - tmp |= READ_COND; - cond = (GIOCondition)tmp; - } - if (condition & PURPLE_INPUT_WRITE) - { - tmp |= WRITE_COND; - cond = (GIOCondition)tmp; - } - -#ifdef WIN32 - channel = wpurple_g_io_channel_win32_new_socket(fd); -#else - channel = g_io_channel_unix_new(fd); -#endif - closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, - io_invoke, closure, io_destroy); - - g_io_channel_unref(channel); - return closure->result; -} - -static PurpleEventLoopUiOps eventLoopOps = -{ - g_timeout_add, - g_source_remove, - input_add, - g_source_remove, - NULL, -#if GLIB_CHECK_VERSION(2,14,0) - g_timeout_add_seconds, -#else - NULL, -#endif - - NULL, - NULL, - NULL -}; - -#ifdef WITH_LIBEVENT - -static GHashTable *events = NULL; -static unsigned long id = 0; - -static void event_io_destroy(gpointer data) -{ - PurpleIOClosure *closure = (PurpleIOClosure* )data; - event_del(&closure->evfifo); - g_free(data); -} - -static void event_io_invoke(int fd, short event, void *data) -{ - PurpleIOClosure *closure = (PurpleIOClosure* )data; - PurpleInputCondition purple_cond = (PurpleInputCondition)0; - int tmp = 0; - if (event & EV_READ) - { - tmp |= PURPLE_INPUT_READ; - purple_cond = (PurpleInputCondition)tmp; - } - if (event & EV_WRITE) - { - tmp |= PURPLE_INPUT_WRITE; - purple_cond = (PurpleInputCondition)tmp; - } - if (event & EV_TIMEOUT) - { -// tmp |= PURPLE_INPUT_WRITE; -// purple_cond = (PurpleInputCondition)tmp; - if (closure->function2(closure->data)) - evtimer_add(&closure->evfifo, &closure->timeout); -// else -// event_io_destroy(data); - return; - } - - closure->function(closure->data, fd, purple_cond); -} - -static gboolean event_input_remove(guint handle) -{ - PurpleIOClosure *closure = (PurpleIOClosure *) g_hash_table_lookup(events, &handle); - if (closure) - event_io_destroy(closure); - return TRUE; -} - -static guint event_input_add(gint fd, - PurpleInputCondition condition, - PurpleInputFunction function, - gpointer data) -{ - PurpleIOClosure *closure = g_new0(PurpleIOClosure, 1); - GIOChannel *channel; - GIOCondition cond = (GIOCondition)0; - closure->function = function; - closure->data = data; - - int tmp = EV_PERSIST; - if (condition & PURPLE_INPUT_READ) - { - tmp |= EV_READ; - } - if (condition & PURPLE_INPUT_WRITE) - { - tmp |= EV_WRITE; - } - - event_set(&closure->evfifo, fd, tmp, event_io_invoke, closure); - event_add(&closure->evfifo, NULL); - - 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; -#ifdef WITH_LIBEVENT - events = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL); - return &libEventLoopOps; -#endif -} diff --git a/backends/skype/geventloop.h b/backends/skype/geventloop.h deleted file mode 100644 index 3febd65e..00000000 --- a/backends/skype/geventloop.h +++ /dev/null @@ -1,33 +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 - */ - -#ifndef _HI_EVENTLOOP_H -#define _HI_EVENTLOOP_H - -#include -#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); - -#endif diff --git a/backends/skype/main.cpp b/backends/skype/main.cpp index 5a135410..17f10bd9 100644 --- a/backends/skype/main.cpp +++ b/backends/skype/main.cpp @@ -12,9 +12,7 @@ #include "transport/rostermanager.h" #include "transport/conversation.h" #include "transport/networkplugin.h" -#include "spectrumeventloop.h" #include -#include "geventloop.h" #include "log4cxx/logger.h" #include "log4cxx/consoleappender.h" #include "log4cxx/patternlayout.h" @@ -773,7 +771,7 @@ int main(int argc, char **argv) { GIOChannel *channel; - GIOCondition cond = (GIOCondition) READ_COND; + GIOCondition cond = (GIOCondition) G_IO_IN; channel = g_io_channel_unix_new(m_sock); g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, transportDataReceived, NULL, io_destroy); diff --git a/backends/skype/spectrumeventloop.cpp b/backends/skype/spectrumeventloop.cpp deleted file mode 100644 index 20286e58..00000000 --- a/backends/skype/spectrumeventloop.cpp +++ /dev/null @@ -1,90 +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 "glib.h" - -#include - -#ifdef WITH_LIBEVENT -#include -#endif - - -using namespace Swift; - -// Fires the event's callback and frees the event -static gboolean processEvent(void *data) { - Event *ev = (Event *) data; - ev->callback(); - delete ev; - return FALSE; -} - -SpectrumEventLoop::SpectrumEventLoop() : m_isRunning(false) { - m_loop = NULL; - if (true) { - m_loop = g_main_loop_new(NULL, FALSE); - } -#ifdef WITH_LIBEVENT - else { - /*struct event_base *base = (struct event_base *)*/ - event_init(); - } -#endif -} - -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::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.owner, event.callback); - g_timeout_add(0, processEvent, ev); -} diff --git a/backends/skype/spectrumeventloop.h b/backends/skype/spectrumeventloop.h deleted file mode 100644 index 7e811c89..00000000 --- a/backends/skype/spectrumeventloop.h +++ /dev/null @@ -1,49 +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 - */ - -#ifndef SPECTRUM_EVENT_LOOP_H -#define SPECTRUM_EVENT_LOOP_H - -#include -#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(); - - // Executes the eventloop. - void run(); - - // Stops tht eventloop. - void stop(); - - // Posts new Swift::Event to main thread. - virtual void post(const Swift::Event& event); - - private: - bool m_isRunning; - GMainLoop *m_loop; -}; - -#endif diff --git a/cmake_modules/dbusConfig.cmake b/cmake_modules/dbusConfig.cmake new file mode 100644 index 00000000..532e37da --- /dev/null +++ b/cmake_modules/dbusConfig.cmake @@ -0,0 +1,53 @@ +# - Try to find LIBDBUS GLIB Bindings +# Find LIBDBUSGLIB headers, libraries and the answer to all questions. +# +# LIBDBUSGLIB_FOUND True if libdbus-glib got found +# LIBDBUSGLIB_INCLUDE_DIRS Location of libdbus-glib headers +# LIBDBUSGLIB_LIBRARIES List of libraries to use libdbus-glib +# +# Copyright (c) 2008 Bjoern Ricks +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +INCLUDE( FindPkgConfig ) + +IF ( LibDbusGlib_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "REQUIRED" ) +ELSE( LibDbusGlib_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "" ) +ENDIF ( LibDbusGlib_FIND_REQUIRED ) + +IF ( LIBDBUSGLIB_MIN_VERSION ) + PKG_SEARCH_MODULE( LIBDBUSGLIB ${_pkgconfig_REQUIRED} dbus-glib-1>=${LIBDBUSGLIB_MIN_VERSION} ) +ELSE ( LIBDBUSGLIB_MIN_VERSION ) + PKG_SEARCH_MODULE( LIBDBUSGLIB ${_pkgconfig_REQUIRED} dbus-glib-1 ) +ENDIF ( LIBDBUSGLIB_MIN_VERSION ) + + +IF( NOT LIBDBUSGLIB_FOUND AND NOT PKG_CONFIG_FOUND ) + FIND_PATH( LIBDBUSGLIB_INCLUDE_DIRS dbus/dbus-glib.h PATH_SUFFIXES dbus-1.0 dbus ) + FIND_LIBRARY( LIBDBUSGLIB_LIBRARIES dbus-glib dbus-glib-1) + + # Report results + IF ( LIBDBUSGLIB_LIBRARIES AND LIBDBUSGLIB_INCLUDE_DIRS ) + SET( LIBDBUSGLIB_FOUND 1 ) + IF ( NOT LIBDBUSGLIB_FIND_QUIETLY ) + MESSAGE( STATUS "Found libdbus-glib: ${LIBDBUSGLIB_LIBRARIES} ${LIBDBUSGLIB_INCLUDE_DIRS}" ) + ENDIF ( NOT LIBDBUSGLIB_FIND_QUIETLY ) + ELSE ( LIBDBUSGLIB_LIBRARIES AND LIBDBUSGLIB_INCLUDE_DIRS ) + IF ( LIBDBUSGLIB_FIND_REQUIRED ) + MESSAGE( SEND_ERROR "Could NOT find libdbus-glib" ) + ELSE ( LIBDBUSGLIB_FIND_REQUIRED ) + IF ( NOT LIBDBUSGLIB_FIND_QUIETLY ) + MESSAGE( STATUS "Could NOT find libdbus-glib" ) + ENDIF ( NOT LIBDBUSGLIB_FIND_QUIETLY ) + ENDIF ( LIBDBUSGLIB_FIND_REQUIRED ) + ENDIF ( LIBDBUSGLIB_LIBRARIES AND LIBDBUSGLIB_INCLUDE_DIRS ) +else() + MESSAGE( STATUS "Found libdbus-glib: ${LIBDBUSGLIB_LIBRARIES} ${LIBDBUSGLIB_INCLUDE_DIRS}" ) +ENDIF() + +MARK_AS_ADVANCED( LIBDBUSGLIB_LIBRARIES LIBDBUSGLIB_INCLUDE_DIRS ) \ No newline at end of file