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
177
|
/***************************************************************************
copyright : (C) 2005, 2006 by Martin Aumueller
email : aumuell@reserv.at
copyright : (C) 2004 by Christian Muehlhaeuser
email : chris@chris.de
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 as *
* published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#ifndef AMAROK_IPODMEDIADEVICE_H
#define AMAROK_IPODMEDIADEVICE_H
extern "C" {
#include <gpod/itdb.h>
}
#include "mediabrowser.h"
#include <tqmutex.h>
#include <tqptrlist.h>
#include <tqdict.h>
#include <tdeio/job.h>
class TQCheckBox;
class TQLabel;
class TQLineEdit;
class TQFile;
class TDEAction;
class IpodMediaItem;
class PodcastInfo;
class IpodMediaDevice : public MediaDevice
{
friend class IpodMediaItem;
Q_OBJECT
public:
IpodMediaDevice();
void init( MediaBrowser* parent );
virtual ~IpodMediaDevice();
virtual bool autoConnect() { return m_autoConnect; }
virtual bool asynchronousTransfer() { return false; /* kernel buffer flushes freeze Amarok */ }
TQStringList supportedFiletypes();
bool isConnected();
virtual void addConfigElements( TQWidget *parent );
virtual void removeConfigElements( TQWidget *parent );
virtual void applyConfig();
virtual void loadConfig();
virtual MediaItem*tagsChanged( MediaItem *item, const MetaBundle &bundle );
virtual TDEAction *customAction() { return m_customAction; }
protected:
MediaItem *trackExists( const MetaBundle& bundle );
bool openDevice( bool silent=false );
bool closeDevice();
bool lockDevice(bool tryLock=false ) { if( tryLock ) { return m_mutex.tryLock(); } else { m_mutex.lock(); return true; } }
void unlockDevice() { m_mutex.unlock(); }
void initView();
void detectModel();
virtual MediaItem *copyTrackToDevice( const MetaBundle& bundle );
/**
* Insert track already located on media device into the device's database
* @param pathname Location of file on the device to add to the database
* @param bundle MetaBundle of track
* @param podcastInfo PodcastInfo of track if it is a podcast, 0 otherwise
* @return If successful, the created MediaItem in the media device view, else 0
*/
virtual MediaItem *insertTrackIntoDB( const TQString &pathname,
const MetaBundle &metaBundle, const MetaBundle &propertiesBundle,
const PodcastInfo *podcastInfo );
virtual MediaItem *updateTrackInDB( IpodMediaItem *item, const TQString &pathname,
const MetaBundle &metaBundle, const MetaBundle &propertiesBundle,
const PodcastInfo *podcastInfo );
/**
* Determine the url for which a track should be uploaded to on the device
* @param bundle MetaBundle of track to base pathname creation on
* @return the url to upload the track to
*/
virtual KURL determineURLOnDevice( const MetaBundle& bundle );
void synchronizeDevice();
int deleteItemFromDevice( MediaItem *item, int flags=DeleteTrack );
virtual void deleteFile( const KURL &url );
void addToPlaylist( MediaItem *list, MediaItem *after, TQPtrList<MediaItem> items );
MediaItem *newPlaylist( const TQString &name, MediaItem *list, TQPtrList<MediaItem> items );
bool getCapacity( TDEIO::filesize_t *total, TDEIO::filesize_t *available );
void rmbPressed( TQListViewItem* qitem, const TQPoint& point, int );
bool checkIntegrity();
void updateArtwork();
protected slots:
void renameItem( TQListViewItem *item );
virtual void fileDeleted( TDEIO::Job *job );
private:
bool initializeIpod();
bool writeITunesDB( bool threaded=true );
bool createLockFile( bool silent );
IpodMediaItem *addTrackToView( Itdb_Track *track, IpodMediaItem *item = 0,
bool checkIntegrity = false, bool batchmode = false );
void addPlaylistToView( Itdb_Playlist *playlist );
void playlistFromItem( IpodMediaItem *item );
TQString itunesDir( const TQString &path = TQString() ) const;
TQString realPath( const char *ipodPath );
TQString ipodPath( const TQString &realPath );
bool pathExists( const TQString &ipodPath, TQString *realPath=0 );
// ipod database
Itdb_iTunesDB *m_itdb;
Itdb_Playlist *m_masterPlaylist;
TQDict<Itdb_Track> m_files;
// podcasts
Itdb_Playlist* m_podcastPlaylist;
bool m_isShuffle;
bool m_isMobile;
bool m_isIPhone;
bool m_supportsArtwork;
bool m_supportsVideo;
bool m_rockboxFirmware;
bool m_needsFirewireGuid;
bool m_autoConnect;
IpodMediaItem *getArtist( const TQString &artist );
IpodMediaItem *getAlbum( const TQString &artist, const TQString &album );
IpodMediaItem *getTrack( const TQString &artist, const TQString &album,
const TQString &title,
int discNumber = -1, int trackNumber = -1,
const PodcastEpisodeBundle *peb = 0 );
IpodMediaItem *getTrack( const Itdb_Track *itrack );
bool removeDBTrack( Itdb_Track *track );
bool m_dbChanged;
TQCheckBox *m_syncStatsCheck;
TQCheckBox *m_autoDeletePodcastsCheck;
TQFile *m_lockFile;
TQMutex m_mutex;
TDEAction *m_customAction;
enum { CHECK_INTEGRITY, UPDATE_ARTWORK, SET_IPOD_MODEL };
private slots:
void slotIpodAction( int );
};
#endif
|