2012-01-02 18:21:07 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2011, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TAGREADERCLIENT_H
|
|
|
|
#define TAGREADERCLIENT_H
|
|
|
|
|
|
|
|
#include "song.h"
|
|
|
|
#include "tagreadermessages.pb.h"
|
2012-01-06 00:22:51 +01:00
|
|
|
#include "core/messagehandler.h"
|
|
|
|
#include "core/workerpool.h"
|
2012-01-02 18:21:07 +01:00
|
|
|
|
2012-01-06 00:22:51 +01:00
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
class QLocalServer;
|
2012-01-02 18:21:07 +01:00
|
|
|
class QProcess;
|
|
|
|
|
|
|
|
class TagReaderClient : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
TagReaderClient(QObject* parent = 0);
|
|
|
|
|
|
|
|
typedef AbstractMessageHandler<pb::tagreader::Message> HandlerType;
|
2012-01-08 00:26:27 +01:00
|
|
|
typedef HandlerType::ReplyType ReplyType;
|
2012-01-02 18:21:07 +01:00
|
|
|
|
2012-01-06 00:22:51 +01:00
|
|
|
static const char* kWorkerExecutableName;
|
|
|
|
|
2012-01-02 18:21:07 +01:00
|
|
|
void Start();
|
|
|
|
|
|
|
|
ReplyType* ReadFile(const QString& filename);
|
|
|
|
ReplyType* SaveFile(const QString& filename, const Song& metadata);
|
|
|
|
ReplyType* IsMediaFile(const QString& filename);
|
|
|
|
ReplyType* LoadEmbeddedArt(const QString& filename);
|
2012-07-28 20:35:12 +02:00
|
|
|
ReplyType* ReadGoogleDrive(const QUrl& download_url,
|
|
|
|
const QString& title,
|
|
|
|
int size,
|
2012-07-31 11:57:04 +02:00
|
|
|
const QString& mime_type,
|
2012-11-28 14:43:03 +01:00
|
|
|
const QString& authorisation_header);
|
2012-01-02 18:21:07 +01:00
|
|
|
|
2012-01-06 22:27:02 +01:00
|
|
|
// Convenience functions that call the above functions and wait for a
|
|
|
|
// response. These block the calling thread with a semaphore, and must NOT
|
|
|
|
// be called from the TagReaderClient's thread.
|
|
|
|
void ReadFileBlocking(const QString& filename, Song* song);
|
|
|
|
bool SaveFileBlocking(const QString& filename, const Song& metadata);
|
|
|
|
bool IsMediaFileBlocking(const QString& filename);
|
|
|
|
QImage LoadEmbeddedArtBlocking(const QString& filename);
|
|
|
|
|
|
|
|
// TODO: Make this not a singleton
|
|
|
|
static TagReaderClient* Instance() { return sInstance; }
|
2012-01-06 00:22:51 +01:00
|
|
|
|
2012-01-07 23:58:30 +01:00
|
|
|
private slots:
|
|
|
|
void WorkerFailedToStart();
|
|
|
|
|
2012-01-06 00:22:51 +01:00
|
|
|
private:
|
2012-01-06 22:27:02 +01:00
|
|
|
static TagReaderClient* sInstance;
|
|
|
|
|
2012-01-06 00:22:51 +01:00
|
|
|
WorkerPool<HandlerType>* worker_pool_;
|
|
|
|
QList<pb::tagreader::Message> message_queue_;
|
2012-01-02 18:21:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef TagReaderClient::ReplyType TagReaderReply;
|
|
|
|
|
|
|
|
#endif // TAGREADERCLIENT_H
|