2018-02-27 18:06:05 +01:00
|
|
|
/* This file is part of Strawberry.
|
|
|
|
Copyright 2011, David Sansome <me@davidsansome.com>
|
2021-04-10 07:32:38 +02:00
|
|
|
Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
Strawberry 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TAGREADERWORKER_H
|
|
|
|
#define TAGREADERWORKER_H
|
|
|
|
|
|
|
|
#include "config.h"
|
2018-05-01 00:41:33 +02:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include "core/messagehandler.h"
|
2021-07-02 01:16:14 +02:00
|
|
|
#if defined(USE_TAGLIB)
|
|
|
|
# include "tagreadertaglib.h"
|
2022-08-01 00:41:12 -07:00
|
|
|
# include "tagreadergme.h"
|
2021-07-02 01:16:14 +02:00
|
|
|
#elif defined(USE_TAGPARSER)
|
|
|
|
# include "tagreadertagparser.h"
|
|
|
|
#endif
|
2022-08-01 00:41:12 -07:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
#include "tagreadermessages.pb.h"
|
|
|
|
|
2020-02-08 03:40:30 +01:00
|
|
|
class QIODevice;
|
|
|
|
|
2021-02-20 17:06:55 +01:00
|
|
|
class TagReaderWorker : public AbstractMessageHandler<spb::tagreader::Message> {
|
2021-06-20 19:04:08 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2020-11-19 18:22:57 +01:00
|
|
|
public:
|
2020-06-26 22:41:38 +02:00
|
|
|
explicit TagReaderWorker(QIODevice *socket, QObject *parent = nullptr);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-11-19 18:22:57 +01:00
|
|
|
protected:
|
2021-02-20 17:06:55 +01:00
|
|
|
void MessageArrived(const spb::tagreader::Message &message) override;
|
2020-06-26 23:01:57 +02:00
|
|
|
void DeviceClosed() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-11-19 18:22:57 +01:00
|
|
|
private:
|
2022-08-01 00:41:12 -07:00
|
|
|
// Handle message using specific TagReaderBase implementation. Returns true on successful message handle.
|
|
|
|
bool HandleMessage(const spb::tagreader::Message &message, spb::tagreader::Message &reply, TagReaderBase* reader);
|
|
|
|
|
2021-07-02 01:16:14 +02:00
|
|
|
#if defined(USE_TAGLIB)
|
|
|
|
TagReaderTagLib tag_reader_;
|
2022-08-01 00:41:12 -07:00
|
|
|
TagReaderGME tag_reader_gme_;
|
2021-07-02 01:16:14 +02:00
|
|
|
#elif defined(USE_TAGPARSER)
|
|
|
|
TagReaderTagParser tag_reader_;
|
|
|
|
#endif
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
2019-04-12 19:55:19 +02:00
|
|
|
#endif // TAGREADERWORKER_H
|