27 namespace SignonDaemonNS {
29 static QList<SignonDisposable *> disposableObjects;
30 static QPointer<QTimer> notifyTimer = 0;
31 static QPointer<QTimer> disposeTimer = 0;
35 maxInactivity(maxInactivity),
38 disposableObjects.append(
this);
40 if (disposeTimer != 0) {
41 int interval = (maxInactivity + 2) * 1000;
42 if (interval > disposeTimer->interval())
43 disposeTimer->setInterval(interval);
44 QObject::connect(disposeTimer, SIGNAL(timeout()),
54 disposableObjects.removeOne(
this);
61 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
62 qWarning(
"Couldn't get time from monotonic clock");
65 lastActivity = ts.tv_sec;
67 if (notifyTimer != 0) {
70 if (disposeTimer != 0) {
71 disposeTimer->start();
82 QObject *
object,
const char *member)
84 notifyTimer =
new QTimer(
object);
85 notifyTimer->setSingleShot(
true);
86 notifyTimer->setInterval(maxInactivity * 1000);
87 QObject::connect(notifyTimer, SIGNAL(timeout()),
95 disposeTimer =
new QTimer(
object);
96 disposeTimer->setSingleShot(
true);
97 int disposableMaxInactivity = 0;
99 QObject::connect(disposeTimer, SIGNAL(timeout()),
101 if (disposableMaxInactivity < disposable->maxInactivity)
102 disposableMaxInactivity = disposable->maxInactivity;
106 disposeTimer->setInterval((disposableMaxInactivity + 2) * 1000);
113 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
114 qWarning(
"Couldn't get time from monotonic clock");
119 if (object->autoDestruct &&
120 (ts.tv_sec - object->lastActivity > object->maxInactivity)) {
121 TRACE() <<
"Object unused, deleting: " << object;
123 disposableObjects.removeOne(
object);
127 if (disposableObjects.isEmpty() && notifyTimer != 0) {
128 TRACE() <<
"No disposable objects, starting notification timer";
129 notifyTimer->start();