2010-07-04 22:52:45 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-07-04 22:52:45 +02:00
|
|
|
|
|
|
|
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 GPODDEVICE_H
|
|
|
|
#define GPODDEVICE_H
|
|
|
|
|
|
|
|
#include "connecteddevice.h"
|
2010-07-19 21:56:29 +02:00
|
|
|
#include "core/musicstorage.h"
|
2010-07-04 22:52:45 +02:00
|
|
|
|
2010-07-24 18:58:14 +02:00
|
|
|
#include <QMutex>
|
2010-07-24 19:41:18 +02:00
|
|
|
#include <QWaitCondition>
|
2010-07-24 18:58:14 +02:00
|
|
|
|
2010-07-24 19:53:40 +02:00
|
|
|
#include <gpod/itdb.h>
|
|
|
|
|
2010-07-04 22:52:45 +02:00
|
|
|
class GPodLoader;
|
|
|
|
|
2010-07-25 11:52:29 +02:00
|
|
|
class GPodDevice : public ConnectedDevice, public virtual MusicStorage {
|
2010-07-04 22:52:45 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2010-07-17 16:22:07 +02:00
|
|
|
Q_INVOKABLE GPodDevice(
|
|
|
|
const QUrl& url, DeviceLister* lister,
|
|
|
|
const QString& unique_id, DeviceManager* manager,
|
|
|
|
int database_id, bool first_time);
|
2010-07-04 22:52:45 +02:00
|
|
|
~GPodDevice();
|
|
|
|
|
2010-08-08 19:41:06 +02:00
|
|
|
void Init();
|
|
|
|
|
2010-07-17 16:22:07 +02:00
|
|
|
static QStringList url_schemes() { return QStringList() << "ipod"; }
|
|
|
|
|
2010-08-30 14:22:15 +02:00
|
|
|
bool GetSupportedFiletypes(QList<Song::FileType>* ret);
|
2010-08-29 16:49:54 +02:00
|
|
|
|
2010-08-30 14:22:15 +02:00
|
|
|
bool StartCopy(QList<Song::FileType>* supported_types);
|
2010-08-28 23:55:30 +02:00
|
|
|
bool CopyToStorage(const CopyJob& job);
|
2010-08-10 21:42:43 +02:00
|
|
|
void FinishCopy(bool success);
|
2010-07-19 21:56:29 +02:00
|
|
|
|
2010-07-31 18:12:16 +02:00
|
|
|
void StartDelete();
|
2010-08-28 23:55:30 +02:00
|
|
|
bool DeleteFromStorage(const DeleteJob& job);
|
2010-08-10 21:42:43 +02:00
|
|
|
void FinishDelete(bool success);
|
2010-07-31 18:12:16 +02:00
|
|
|
|
2010-08-08 19:41:06 +02:00
|
|
|
protected slots:
|
2010-07-24 19:41:18 +02:00
|
|
|
void LoadFinished(Itdb_iTunesDB* db);
|
|
|
|
|
2010-08-08 19:41:06 +02:00
|
|
|
protected:
|
|
|
|
Itdb_Track* AddTrackToITunesDb(const Song& metadata);
|
|
|
|
void AddTrackToModel(Itdb_Track* track, const QString& prefix);
|
2010-08-14 12:32:47 +02:00
|
|
|
bool RemoveTrackFromITunesDb(const QString& path,
|
|
|
|
const QString& relative_to = QString());
|
2010-08-08 19:41:06 +02:00
|
|
|
virtual void FinaliseDatabase() {}
|
|
|
|
|
2010-08-11 20:47:53 +02:00
|
|
|
private:
|
|
|
|
void WriteDatabase(bool success);
|
|
|
|
|
2010-08-08 19:41:06 +02:00
|
|
|
protected:
|
2010-07-04 22:52:45 +02:00
|
|
|
QThread* loader_thread_;
|
|
|
|
GPodLoader* loader_;
|
2010-07-24 18:58:14 +02:00
|
|
|
|
2010-07-24 19:41:18 +02:00
|
|
|
QWaitCondition db_wait_cond_;
|
|
|
|
QMutex db_mutex_;
|
|
|
|
Itdb_iTunesDB* db_;
|
|
|
|
|
2010-07-31 18:12:16 +02:00
|
|
|
QMutex db_busy_;
|
2010-07-24 22:43:51 +02:00
|
|
|
SongList songs_to_add_;
|
2010-08-01 13:01:07 +02:00
|
|
|
SongList songs_to_remove_;
|
2010-07-04 22:52:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GPODDEVICE_H
|