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
|
/****************************************************************************
* copyright :(C) 2006 Roel Meeuws <r.j.meeuws+amarok@gmail.com> *
* (C) 2005 Jeff Mitchell <kde-dev@emailgoeshere.com> *
* (C) 2005 Seb Ruiz <me@sebruiz.net> *
* *
* With some code helpers from TDEIO_GENERIC *
* (c) 2004 Thomas Loeber <vfat@loeber1.de> *
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef AMAROK_GENERICMEDIADEVICE_H
#define AMAROK_GENERICMEDIADEVICE_H
#include "mediabrowser.h"
#include "transferdialog.h"
#include <kdirlister.h>
#include <kurl.h>
#include <tqptrlist.h>
class GenericMediaItem;
class GenericMediaFile;
class GenericMediaDeviceConfigDialog;
class PodcastEpisodeBundle;
class TQStringList;
typedef TQMap<TQString, GenericMediaFile*> MediaFileMap;
typedef TQMap<GenericMediaItem*, GenericMediaFile*> MediaItemMap;
class GenericMediaDevice : public MediaDevice
{
Q_OBJECT
friend class GenericMediaDeviceConfigDialog;
public:
GenericMediaDevice();
void init( MediaBrowser* parent );
virtual ~GenericMediaDevice();
bool isConnected() { return m_connected; }
void rmbPressed( TQListViewItem* qitem, const TQPoint& point, int );
TQStringList supportedFiletypes() { return m_supportedFileTypes; }
bool isPlayable( const MetaBundle& bundle );
bool isPreferredFormat( const MetaBundle &bundle );
bool needsManualConfig() { return false; }
void addConfigElements( TQWidget * parent );
void removeConfigElements( TQWidget * /* parent */);
void applyConfig();
void loadConfig();
MediaFileMap &getFileMap() { return m_mfm; }
MediaItemMap &getItemMap() { return m_mim; }
GenericMediaFile *getInitialFile() { return m_initialFile; }
protected:
bool openDevice( bool silent=false );
bool closeDevice();
MediaItem *copyTrackToDevice( const MetaBundle& bundle );
int deleteItemFromDevice( MediaItem *item, int flags=DeleteTrack );
MediaItem *newDirectory( const TQString &name, MediaItem *parent );
void addToDirectory( MediaItem *directory, TQPtrList<MediaItem> items );
bool getCapacity( TDEIO::filesize_t *total, TDEIO::filesize_t *available );
TQString fileName( const MetaBundle & );
//methods not implemented/needed
bool lockDevice( bool ) { return true; }
void unlockDevice() {}
void synchronizeDevice() {}
void addToPlaylist( MediaItem *, MediaItem *, TQPtrList<MediaItem> ) {}
MediaItem *newPlaylist( const TQString &, MediaItem *, TQPtrList<MediaItem> ) { return 0; }
signals:
void startTransfer();
protected slots:
void renameItem( TQListViewItem *item );
void expandItem( TQListViewItem *item );
void foundMountPoint( const TQString & mountPoint, unsigned long kBSize, unsigned long kBUsed, unsigned long kBAvail );
void refreshDir( const TQString &dir );
void newItems( const KFileItemList &items );
void dirListerCompleted();
void dirListerClear();
void dirListerClear( const KURL &url );
void dirListerDeleteItem( KFileItem *fileitem );
private:
enum Error { ERR_ACCESS_DENIED, ERR_CANNOT_RENAME, ERR_DISK_FULL, ERR_COULD_NOT_WRITE };
MediaItem *trackExists( const MetaBundle& );
TQString buildDestination( const TQString &format, const MetaBundle &mb );
TQString buildPodcastDestination( const PodcastEpisodeBundle *bundle );
void checkAndBuildLocation( const TQString& location );
KURL::List getSelectedItems();
void downloadSelectedItems();
void copyTrackSortHelper( const MetaBundle& bundle, TQString& sort, TQString& base );
void listDir( const TQString &dir );
int addTrackToList( int type, KURL name, int size=0 );
TQString cleanPath( const TQString &component );
GenericMediaFile *m_initialFile;
TDEIO::filesize_t m_kBSize;
TDEIO::filesize_t m_kBAvail;
KDirLister *m_dirLister;
bool m_actuallyVfat;
bool m_dirListerComplete;
bool m_connected;
KURL::List m_downloadList;
MediaFileMap m_mfm;
MediaItemMap m_mim;
TQStringList m_supportedFileTypes;
TQString m_songLocation;
TQString m_podcastLocation;
bool m_asciiTextOnly;
bool m_vfatTextOnly;
bool m_ignoreThePrefix;
GenericMediaDeviceConfigDialog *m_configDialog;
};
#endif /*AMAROK_GENERICMEDIADEVICE_H*/
|