File indexing completed on 2024-04-28 15:25:35

0001 /* This file is part of the KDE libraries
0002  * SPDX-FileCopyrightText: 2009 Dario Freddi <drf at kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #ifndef MACPOLLER_H
0008 #define MACPOLLER_H
0009 
0010 #include "abstractsystempoller.h"
0011 
0012 #include <Carbon/Carbon.h>
0013 
0014 class MacPoller : public AbstractSystemPoller
0015 {
0016     Q_OBJECT
0017     Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "osx.json")
0018     Q_INTERFACES(AbstractSystemPoller)
0019 
0020 public:
0021     MacPoller(QObject *parent = 0);
0022     virtual ~MacPoller();
0023 
0024     bool isAvailable();
0025     bool setUpPoller();
0026     void unloadPoller();
0027 
0028     static pascal void IdleTimerAction(EventLoopTimerRef, EventLoopIdleTimerMessage inState, void *inUserData);
0029 
0030 public Q_SLOTS:
0031     void addTimeout(int nextTimeout);
0032     void removeTimeout(int nextTimeout);
0033     QList<int> timeouts() const;
0034     int forcePollRequest();
0035     void catchIdleEvent();
0036     void stopCatchingIdleEvents();
0037     void simulateUserActivity();
0038     void triggerResume();
0039 
0040 private Q_SLOTS:
0041     int poll();
0042 
0043 private:
0044     QList<int> m_timeouts;
0045     EventLoopTimerRef m_timerRef;
0046     int m_secondsIdle;
0047     bool m_catch;
0048 };
0049 
0050 #endif /* MACPOLLER_H */