summaryrefslogtreecommitdiffstats
path: root/k9devices/k9dbusdispatch.h
blob: d9d210e0399028c43fbdb2c24476df968eaecce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// C++ Interface: k9dbusdispatch
//
// Description: the main goal of this class is to dispatch dbus messages so that libhal can
//              detect changes on devices.
//              This code is based on TQDBusConnectionPrivate from the new TQt DBus bindings
//
//
// Author: Jean-Michel PETIT <[email protected]>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef K9DBUSDISPATCH_H
#define K9DBUSDISPATCH_H
#include "k9common.h"

#ifdef Q_MOC_RUN
#define HAVE_HAL
#endif // Q_MOC_RUN

#ifdef HAVE_HAL

#include <tqobject.h>
#include <tqtimer.h>
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus.h>
#include <tqsocketnotifier.h>
#include <tqvaluelist.h>
#include <tqmap.h>

/**
	@author Jean-Michel PETIT <[email protected]>
*/

class k9Watcher {
public:
    k9Watcher() { read=write=0; watch=0;};
    DBusWatch *watch;
    TQSocketNotifier *read,*write;
};

class K9DBusDispatch : public TQObject
{
Q_OBJECT
  TQ_OBJECT
public:
    K9DBusDispatch(TQObject *tqparent = 0, const char *name = 0);

    ~K9DBusDispatch();
    void setConnection(DBusConnection* _value);
    typedef TQValueList<k9Watcher> WatcherList;
    WatcherList removedWatches;
    typedef TQMap<int, WatcherList> WatcherHash;
    WatcherHash watchers;    

private:
    TQTimer *m_dispatcher;
    DBusConnection *m_connection;

    void purgeRemovedWatches();
    void scheduleDispatch();
private slots:
    void socketRead(int fd);
    void socketWrite(int fd);
    void dispatch();
    

};
#endif
#endif