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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
// ****************************************************************************
// Project: GUYMAGER
// ****************************************************************************
// Programmer: Guy Voncken
// Police Grand-Ducale
// Service de Police Judiciaire
// Section Nouvelles Technologies
// ****************************************************************************
// Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
// 2018, 2019, 2020
// Guy Voncken
//
// This file is part of Guymager.
//
// Guymager is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Guymager 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Guymager. If not, see <http://www.gnu.org/licenses/>.
#ifndef THREADSCAN_H
#define THREADSCAN_H
#include <QObject> //lint !e537 Repeated include
#include "thread.h"
#ifndef DEVICE_H
#include "device.h"
#endif
#ifndef COMMON_H
#include "common.h"
#endif
class t_ThreadScan;
class t_ThreadScanWorker: public QObject
{
Q_OBJECT
public:
t_ThreadScanWorker (t_ThreadScan *pThreadScan);
public slots:
virtual void SlotRescan (void) = 0;
signals:
void SignalScanFinished (t_pDeviceList);
void SignalScanStarted (void);
protected:
t_ThreadScan *poThreadScan;
};
class t_ThreadScanWorkerPartedLocal;
class t_ThreadScanWorkerParted: public t_ThreadScanWorker
{
Q_OBJECT
public:
t_ThreadScanWorkerParted (t_ThreadScan *pThreadScan, APIRET &rc);
~t_ThreadScanWorkerParted (void);
public slots:
void SlotRescan (void);
private:
t_ThreadScanWorkerPartedLocal *pOwn;
};
class t_ThreadScanWorkerUdevLocal;
class t_ThreadScanWorkerUdev: public t_ThreadScanWorker
{
Q_OBJECT
public:
t_ThreadScanWorkerUdev (t_ThreadScan *pThreadScan, APIRET &rc);
~t_ThreadScanWorkerUdev (void);
public slots:
void SlotRescan (void);
private:
t_ThreadScanWorkerUdevLocal *pOwn;
};
class t_ThreadScanWorkerHALLocal;
class t_ThreadScanWorkerHAL: public t_ThreadScanWorker
{
Q_OBJECT
public:
t_ThreadScanWorkerHAL (t_ThreadScan *pThreadScan, APIRET &rc);
~t_ThreadScanWorkerHAL (void);
private:
QList<QVariant> CallMethod (const QString &Device, const QString &Method, const QString &Argument);
QVariant CallMethodSingle (const QString &Device, const QString &Method, const QString &Argument);
APIRET GetProperty (const QString &Device, const QString &Property, QList<QVariant> &VarList);
APIRET GetPropertySingle (const QString &Device, const QString &Property, QVariant &Var );
bool PropertyContains (const QString &Device, const QString &Property, const QString &Str );
public slots:
void SlotRescan (void);
private:
t_ThreadScanWorkerHALLocal *pOwn;
};
class t_ThreadScanWorkerDevKitLocal;
class t_ThreadScanWorkerDevKit: public t_ThreadScanWorker
{
Q_OBJECT
public:
t_ThreadScanWorkerDevKit (t_ThreadScan *pThreadScan, APIRET &rc);
~t_ThreadScanWorkerDevKit (void);
private:
QList<QVariant> CallMethod (const QString &Device, const QString &Method, const QString &Argument);
APIRET GetProperty (const QString &Device, const QString &Property, QVariant &Var);
public slots:
void SlotRescan (void);
private:
t_ThreadScanWorkerDevKitLocal *pOwn;
};
class t_ThreadScan: public t_Thread
{
Q_OBJECT
public:
t_ThreadScan (void);
APIRET Start (t_ThreadScanWorker **ppWorker); // Return ptr to worker, so calling fn may emit signals to it
APIRET Stop ();
protected:
void run (void);
private:
t_ThreadScanWorker **ppoWorker;
APIRET oWorkerRc;
};
enum
{
ERROR_THREADSCAN_NOT_STARTED = ERROR_BASE_THREADSCAN,
ERROR_THREADSCAN_NOT_STOPPED,
ERROR_THREADSCAN_EXITCODE_NONZERO,
ERROR_THREADSCAN_PROCESS_NOTSTARTED,
ERROR_THREADSCAN_PROCESS_NOTFINISHED,
ERROR_THREADSCAN_LIBPARTED_NOTWORKING,
ERROR_THREADSCAN_LIBUDEV_NOTWORKING,
ERROR_THREADSCAN_DBUSHAL_NOTWORKING,
ERROR_THREADSCAN_DBUSDEVKIT_NOTWORKING,
ERROR_THREADSCAN_PROPERTY_NONEXISTENT,
ERROR_THREADSCAN_CALLED_FROM_WRONG_THREAD,
ERROR_THREADSCAN_INVALID_SCAN_METHOD,
ERROR_THREADSCAN_UDEV_FAILURE
};
#endif
|