summaryrefslogtreecommitdiffstats
path: root/src/nfc/android/androidmainnewintentlistener_p.h
blob: eb3c5217e6a039016a6d6357b4bfec61ee09630c (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
// Copyright (C) 2016 BasysKom GmbH
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef ANDROIDMAINNEWINTENTLISTENER_P_H_
#define ANDROIDMAINNEWINTENTLISTENER_P_H_

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtCore/private/qjnihelpers_p.h>

#include "qlist.h"
#include "qreadwritelock.h"

QT_BEGIN_NAMESPACE

class QJniObject;

class QAndroidNfcListenerInterface
{
public:
    virtual ~QAndroidNfcListenerInterface() = default;
    virtual void newIntent(QJniObject intent) = 0;
};

class QMainNfcNewIntentListener : public QtAndroidPrivate::NewIntentListener,
                                  QtAndroidPrivate::ResumePauseListener
{
public:
    QMainNfcNewIntentListener();
    ~QMainNfcNewIntentListener();

    //QtAndroidPrivate::NewIntentListener
    bool handleNewIntent(JNIEnv *env, jobject intent);

    bool registerListener(QAndroidNfcListenerInterface *listener);
    bool unregisterListener(QAndroidNfcListenerInterface *listener);

    //QtAndroidPrivate::ResumePauseListener
    void handleResume();
    void handlePause();

private:
    void updateReceiveState();

    QList<QAndroidNfcListenerInterface *> listeners;
    QReadWriteLock listenersLock;
    bool paused;
    bool receiving;
};

QT_END_NAMESPACE

#endif /* ANDROIDMAINNEWINTENTLISTENER_P_H_ */