1
/***************************************************************************
2
* Copyright (C) 2005 - 2007 by *
3
* Last.fm Ltd <client@last.fm> *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
24
#include "TrackInfo.h"
25
#include <QSqlDatabase>
27
typedef struct _Itdb_iTunesDB Itdb_iTunesDB;
28
typedef struct _Itdb_Track Itdb_Track;
29
typedef struct _Itdb_Playlist Itdb_Playlist;
33
* Currently all MediaDevice plugins are instantiated on startup.
34
* In the future it would be better that we only create them as needed
36
class MyMediaDeviceInterface : public QObject
46
/** if you need a persistent sqlite store, use this db
47
* ensure your table name is unique eg ClassNameTracks */
48
QSqlDatabase database() const;
50
/** this must be set or you're going to get database table conflicts among
52
QString const uniqueId() const { return m_uid; }
53
// because we suck currently, can't be in ctor due to QPlugin restriction but must be set
54
void setUniqueId( const QString& uid ) { m_uid = uid; }
56
/** should be controlled by higher object */
57
void setMountPath( const QString& path ) { m_mountPath = path; }
59
/** return tracks that should be scrobbled, next time this is called you
60
* should return tracks played since then, so you are expected to commit
61
* to the database (or whatever storage solution you choose) before you
63
* set m_error if there was an unrecoverable error */
64
virtual QList<TrackInfo> tracksToScrobble() = 0;
66
/** a suggested unique table name */
67
QString tableName() const { return "a" + m_uid; }
69
/** the controlling code will check this if you return an empty track list
70
* above. If the track list is empty and there is no error it will say
71
* "nothing to scrobble", else it will show the error message */
72
QString error() const { return m_error; }
75
Q_DECLARE_INTERFACE( MyMediaDeviceInterface, "fm.last.MyMediaDevice/1.0" );
78
/** NOTE this means a manually synced ipod */
79
class IpodDevice : public MyMediaDeviceInterface
82
Q_INTERFACES( MyMediaDeviceInterface );
88
virtual QList<TrackInfo> tracksToScrobble();
91
QDateTime previousPlayTime( Itdb_Track* ) const;
92
uint previousPlayCount( Itdb_Track* ) const;
94
/** to the database */
95
void commit( const TrackInfo& );
97
/** opens the db, allocates a LOT of memory, call after setting m_mountPath */
101
Itdb_iTunesDB* m_itdb;
102
Itdb_Playlist* m_mpl;