| 1 | /* |
| 2 | * Copyright (C) 2013-2015 Canonical Ltd. |
| 3 | * |
| 4 | * Contact: Alberto Mardegan <[email protected]> |
| 5 | * |
| 6 | * This file is part of lomiri-online-accounts-service |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 3, as published |
| 10 | * by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "inactivity-timer.h"cxx . . $ `<file>/online-accounts-service/src/inactivity-timer.h`/ |
| 22 | |
| 23 | #include <online-accounts-common/debug.h>cxx . . $ `<file>/online-accounts-common/debug.h`/ |
| 24 | |
| 25 | using namespace OnlineAccountsUi; |
| 26 | |
| 27 | InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer#::InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer#InactivityTimer(1ee1e1ac455d3e6e).(int interval, QObjectcxx . . $ QObject# *parent): |
| 28 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent), |
| 29 | m_intervalcxx . . $ OnlineAccountsUi/InactivityTimer#m_interval.(interval) |
| 30 | { |
| 31 | m_timercxx . . $ OnlineAccountsUi/InactivityTimer#m_timer..setSingleShotcxx . . $ QTimer#setSingleShot(b45ddcbc8423892c).(true); |
| 32 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(&m_timercxx . . $ OnlineAccountsUi/InactivityTimer#m_timer., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout()), |
| 33 | this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onTimeout())); |
| 34 | } |
| 35 | |
| 36 | void InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer#::watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *object) |
| 37 | { |
| 38 | connectcxx . . $ QObject#connect(f4332061c7e4ca89).(object, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(isIdleChanged()), SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onIdleChanged())); |
| 39 | m_watchedObjectscxx . . $ OnlineAccountsUi/InactivityTimer#m_watchedObjects..appendcxx . . $ QList#append(77d9f17553126ecb).(object); |
| 40 | |
| 41 | /* Force an initial check */ |
| 42 | onIdleChangedcxx . . $ OnlineAccountsUi/InactivityTimer#onIdleChanged(49f6e7a06ebc5aa8).(); |
| 43 | } |
| 44 | |
| 45 | void InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer#::onIdleChangedcxx . . $ OnlineAccountsUi/InactivityTimer#onIdleChanged(49f6e7a06ebc5aa8).() |
| 46 | { |
| 47 | if (allObjectsAreIdlecxx . . $ OnlineAccountsUi/InactivityTimer#allObjectsAreIdle(50ce9a9e25b4a850).()) { |
| 48 | m_timercxx . . $ OnlineAccountsUi/InactivityTimer#m_timer..startcxx . . $ QTimer#start(d4f767463ce0a6b3).(m_intervalcxx . . $ OnlineAccountsUi/InactivityTimer#m_interval.); |
| 49 | } else { |
| 50 | m_timercxx . . $ OnlineAccountsUi/InactivityTimer#m_timer..stopcxx . . $ QTimer#stop(49f6e7a06ebc5aa8).(); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | void InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer#::onTimeoutcxx . . $ OnlineAccountsUi/InactivityTimer#onTimeout(49f6e7a06ebc5aa8).() |
| 55 | { |
| 56 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!(); |
| 57 | if (allObjectsAreIdlecxx . . $ OnlineAccountsUi/InactivityTimer#allObjectsAreIdle(50ce9a9e25b4a850).()) { |
| 58 | Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! timeoutcxx . . $ OnlineAccountsUi/InactivityTimer#timeout(49f6e7a06ebc5aa8).(); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | bool InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer#::allObjectsAreIdlecxx . . $ OnlineAccountsUi/InactivityTimer#allObjectsAreIdle(50ce9a9e25b4a850).() const |
| 63 | { |
| 64 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QObject *object, m_watchedObjects) { |
| 65 | if (!object->propertycxx . . $ QObject#property(950ff6813be46b58).("isIdle").toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).()) { |
| 66 | return false; |
| 67 | } |
| 68 | } |
| 69 | return true; |
| 70 | } |