From a18cea60f0df4dca1e3b5ba4984c327d2e6be619 Mon Sep 17 00:00:00 2001 From: Jonne Lehtinen Date: Sat, 27 May 2006 13:24:00 +0300 Subject: [PATCH] OTHER: Make the mainloop inherit Xmms::MainloopInterface. Also made it orphan (Xmms::Client deletes it properly). This should be added as a shared library compiled with the bindings if QT libraries are available. --- XMMSHandler.cpp | 2 +- XmmsQT4.cpp | 21 ++++++++++++++------- XmmsQT4.h | 11 +++++------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/XMMSHandler.cpp b/XMMSHandler.cpp index 3a2c8ff..f4deccd 100644 --- a/XMMSHandler.cpp +++ b/XMMSHandler.cpp @@ -47,7 +47,7 @@ XMMSHandler::connect (const char *path) delete err; return false; } - m_qt4 = new XmmsQT4 (m_client.getConnection (), qApp); + m_client.setMainloop (new XmmsQT4 (m_client.getConnection ())); using Xmms::bind; m_client.playlist.list (bind (&XMMSHandler::playlist_list, this)); diff --git a/XmmsQT4.cpp b/XmmsQT4.cpp index 7a7d76c..5d9a288 100644 --- a/XmmsQT4.cpp +++ b/XmmsQT4.cpp @@ -1,11 +1,17 @@ +#include +#include #include "XmmsQT4.h" +#include +#include +#include + static void CheckWrite (int i, void *userdata); -XmmsQT4::XmmsQT4 (xmmsc_connection_t *xmmsc, QObject *parent) : QObject (parent) +XmmsQT4::XmmsQT4 (xmmsc_connection_t *xmmsc) : + QObject (), Xmms::MainloopInterface (xmmsc), + m_fd (0), m_rsock (0), m_wsock (0), m_xmmsc (xmmsc) { - m_xmmsc = xmmsc; - m_fd = xmmsc_io_fd_get (xmmsc); xmmsc_io_need_out_callback_set (xmmsc, CheckWrite, this); @@ -25,6 +31,9 @@ XmmsQT4::~XmmsQT4 () delete m_wsock; } +void XmmsQT4::run () +{ +} xmmsc_connection_t *XmmsQT4::GetXmmsConnection () { @@ -54,13 +63,11 @@ void XmmsQT4::ToggleWrite (bool toggle) static void CheckWrite (int i, void *userdata) { - XmmsQT4 *obj = (XmmsQT4 *) userdata; - xmmsc_connection_t *xmmsc = obj->GetXmmsConnection(); + XmmsQT4 *obj = static_cast< XmmsQT4* > (userdata); - if (xmmsc_io_want_out (xmmsc)) { + if (xmmsc_io_want_out (obj->GetXmmsConnection ())) { obj->ToggleWrite (true); } else { obj->ToggleWrite (false); } } - diff --git a/XmmsQT4.h b/XmmsQT4.h index 6377e01..4b2339d 100644 --- a/XmmsQT4.h +++ b/XmmsQT4.h @@ -1,22 +1,21 @@ #ifndef __XMMSQT4_H__ #define __XMMSQT4_H__ -#include +#include #include #include #include -#include - - -class XmmsQT4 : public QObject +class XmmsQT4 : public QObject, public Xmms::MainloopInterface { Q_OBJECT public: - XmmsQT4(xmmsc_connection_t *xmmsc = 0, QObject *parent = 0); + XmmsQT4(xmmsc_connection_t *xmmsc); ~XmmsQT4(); + void run (); + void ToggleWrite(bool toggle); xmmsc_connection_t *GetXmmsConnection();