This file is indexed.

/usr/include/x86_64-linux-gnu/qt5/UbuntuGestures/timer.h is in libubuntugestures5-gles-dev 1.3.1918+16.04.20160404-0ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * Copyright 2015 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef UBUNTUGESTURES_TIMER_H
#define UBUNTUGESTURES_TIMER_H

#include "ubuntugesturesglobal.h"
#include "timesource.h"

#include <QObject>
#include <QPointer>
#include <QTimer>

namespace UbuntuGestures {

/* Defines an interface for a Timer. */
class UBUNTUGESTURES_EXPORT AbstractTimer : public QObject
{
    Q_OBJECT
public:
    AbstractTimer(QObject *parent) : QObject(parent), m_isRunning(false) {}
    virtual int interval() const = 0;
    virtual void setInterval(int msecs) = 0;
    virtual void start() { m_isRunning = true; }
    virtual void stop() { m_isRunning = false; }
    bool isRunning() const { return m_isRunning; }
    virtual bool isSingleShot() const = 0;
    virtual void setSingleShot(bool value) = 0;
Q_SIGNALS:
    void timeout();
private:
    bool m_isRunning;
};

/* Essentially a QTimer wrapper */
class UBUNTUGESTURES_EXPORT Timer : public AbstractTimer
{
    Q_OBJECT
public:
    Timer(QObject *parent = nullptr);

    int interval() const override;
    void setInterval(int msecs) override;
    void start() override;
    void stop() override;
    bool isSingleShot() const override;
    void setSingleShot(bool value) override;
private:
    QTimer m_timer;
};

/* For tests */
class UBUNTUGESTURES_EXPORT FakeTimer : public AbstractTimer
{
    Q_OBJECT
public:
    FakeTimer(const SharedTimeSource &timeSource, QObject *parent = nullptr);

    void update();
    qint64 nextTimeoutTime() const { return m_nextTimeoutTime; }

    int interval() const override;
    void setInterval(int msecs) override;
    void start() override;
    bool isSingleShot() const override;
    void setSingleShot(bool value) override;
private:
    int m_interval;
    bool m_singleShot;
    SharedTimeSource m_timeSource;
    qint64 m_nextTimeoutTime;
};

class UBUNTUGESTURES_EXPORT AbstractTimerFactory
{
public:
    virtual ~AbstractTimerFactory() {}
    virtual AbstractTimer *createTimer(QObject *parent = nullptr) = 0;
};

class UBUNTUGESTURES_EXPORT TimerFactory : public AbstractTimerFactory
{
public:
    AbstractTimer *createTimer(QObject *parent = nullptr) override { return new Timer(parent); }
};

class UBUNTUGESTURES_EXPORT FakeTimerFactory : public AbstractTimerFactory
{
public:
    FakeTimerFactory();
    virtual ~FakeTimerFactory() {}

    void updateTime(qint64 msecsSinceReference);
    QSharedPointer<TimeSource> timeSource() { return m_timeSource; }

    AbstractTimer *createTimer(QObject *parent = nullptr) override;
    QList<QPointer<FakeTimer>> timers;
private:
    QSharedPointer<FakeTimeSource> m_timeSource;
};

} // namespace UbuntuGestures

#endif // UBUNTUGESTURES_TIMER_H