2003-11-24 05:21:12 +00:00
|
|
|
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
|
|
|
|
/* integrator.h: integrates D-BUS into Qt event loop
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 Zack Rusin <zack@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Academic Free License version 1.2
|
|
|
|
|
*
|
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#ifndef DBUS_QT_INTEGRATOR_H
|
|
|
|
|
#define DBUS_QT_INTEGRATOR_H
|
|
|
|
|
|
|
|
|
|
#include <qobject.h>
|
|
|
|
|
|
|
|
|
|
#include <qintdict.h>
|
2003-11-24 19:11:55 +00:00
|
|
|
#include <qptrdict.h>
|
2003-11-24 05:21:12 +00:00
|
|
|
|
|
|
|
|
#include "dbus/dbus.h"
|
|
|
|
|
|
2003-11-24 19:11:55 +00:00
|
|
|
class QTimer;
|
|
|
|
|
|
2003-11-24 05:21:12 +00:00
|
|
|
namespace DBusQt
|
|
|
|
|
{
|
|
|
|
|
class Connection;
|
|
|
|
|
|
|
|
|
|
namespace Internal
|
|
|
|
|
{
|
2003-11-24 19:11:55 +00:00
|
|
|
struct Watch;
|
|
|
|
|
|
|
|
|
|
class Timeout : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
Timeout( QObject *parent, DBusTimeout *t );
|
|
|
|
|
public:
|
|
|
|
|
void start();
|
|
|
|
|
signals:
|
|
|
|
|
void timeout( DBusTimeout* );
|
|
|
|
|
protected slots:
|
|
|
|
|
void slotTimeout();
|
|
|
|
|
private:
|
|
|
|
|
QTimer *m_timer;
|
|
|
|
|
DBusTimeout *m_timeout;
|
|
|
|
|
};
|
|
|
|
|
|
2003-11-24 05:21:12 +00:00
|
|
|
class Integrator : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2003-11-25 15:30:03 +00:00
|
|
|
Integrator( DBusConnection *connection, QObject *parent );
|
|
|
|
|
Integrator( DBusServer *server, QObject *parent );
|
2003-11-24 05:21:12 +00:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void readReady();
|
2003-11-25 15:30:03 +00:00
|
|
|
void newConnection( Connection* );
|
2003-11-24 05:21:12 +00:00
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
|
void slotRead( int );
|
|
|
|
|
void slotWrite( int );
|
2003-11-24 19:11:55 +00:00
|
|
|
void slotTimeout( DBusTimeout *timeout );
|
2003-11-24 05:21:12 +00:00
|
|
|
|
2003-11-24 19:11:55 +00:00
|
|
|
public:
|
2003-11-24 05:21:12 +00:00
|
|
|
void addWatch( DBusWatch* );
|
|
|
|
|
void removeWatch( DBusWatch* );
|
|
|
|
|
|
|
|
|
|
void addTimeout( DBusTimeout* );
|
|
|
|
|
void removeTimeout( DBusTimeout* );
|
2003-11-25 15:30:03 +00:00
|
|
|
|
|
|
|
|
void handleConnection( DBusConnection* );
|
2003-11-24 05:21:12 +00:00
|
|
|
private:
|
2003-11-24 19:11:55 +00:00
|
|
|
QIntDict<Watch> m_watches;
|
|
|
|
|
QPtrDict<Timeout> m_timeouts;
|
2003-11-25 15:30:03 +00:00
|
|
|
DBusConnection *m_connection;
|
|
|
|
|
DBusServer *m_server;
|
2003-11-24 05:21:12 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|