1 /***************************************************************************
2 copyright : (C) 2006 by Andres Oton
3 email : andres.oton@gmail.com
5 copyright : (C) 2006 by T.R.Shashwath
6 email : trshash84@gmail.com
7 ***************************************************************************/
9 /***************************************************************************
10 * This library is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License version 2 as *
12 * published by the Free Software Foundation. *
14 * This library is distributed in the hope that it will be useful, but *
15 * WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
17 * Lesser General Public License for more details. *
19 * You should have received a copy of the GNU General Public License *
20 * along with this library; if not, write to the Free Software *
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
23 ***************************************************************************/
25 #ifndef NJBMEDIADEVICE_H
26 #define NJBMEDIADEVICE_H
28 #include <mediabrowser.h>
29 #include <transferdialog.h>
32 #include <q3ptrlist.h>
33 #include <q3listview.h>
40 #include <q3valuelist.h>
44 #include <kio/global.h>
45 #include <kio/slavebase.h>
48 This class is used to manipulate Nomad Creative Jukebox and others media player that works with the njb libraries.
50 You can find the njb libs at : http://libnjb.sourceforge.net
54 @author Andres Oton <andres.oton@gmail.com>
55 @author T.R.Shashwath <trshash84@gmail.com>
58 const int NJB_SUCCESS
= 0;
59 const int NJB_FAILURE
= -1;
62 extern trackValueList
* theTracks
;
64 class NjbMediaItem
: public MediaItem
67 explicit NjbMediaItem( Q3ListView
*parent
, Q3ListViewItem
*after
= 0 ) : MediaItem( parent
, after
)
70 explicit NjbMediaItem( Q3ListViewItem
*parent
, Q3ListViewItem
*after
= 0 ) : MediaItem( parent
, after
)
75 //m_track->removeItem(this);
78 void setTrack( NjbTrack
*track
) { m_track
= track
; m_track
->addItem(this); }
79 NjbTrack
*track() { return m_track
; }
80 QString
filename() { return m_track
->bundle()->url().path(); }
85 class NjbMediaDevice
: public MediaDevice
94 virtual bool isConnected();
95 virtual bool isPlayable(const MetaBundle
& bundle
);
96 virtual bool isPreferredFormat(const MetaBundle
& bundle
);
98 // virtual bool needsManualConfig();
100 virtual MediaItem
* newPlaylist(const QString
& name
, MediaItem
* parent
, Q3PtrList
< MediaItem
> items
);
102 // virtual MediaItem* tagsChanged(MediaItem* item, const MetaBundle& changed);
104 virtual QStringList
supportedFiletypes();
106 virtual bool hasTransferDialog() { return true; }
107 virtual TransferDialog
* getTransferDialog();
108 virtual void addConfigElements(QWidget
* arg1
);
109 virtual void addToDirectory(MediaItem
* directory
, Q3PtrList
< MediaItem
> items
) { Q_UNUSED(directory
) Q_UNUSED(items
) }
110 virtual void addToPlaylist(MediaItem
* playlist
, MediaItem
* after
, Q3PtrList
< MediaItem
> items
);
111 virtual void applyConfig();
112 virtual void init(MediaBrowser
* parent
);
113 virtual void loadConfig();
114 virtual void removeConfigElements(QWidget
* arg1
);
115 virtual void rmbPressed(Q3ListViewItem
* qitem
, const QPoint
& point
, int arg1
);
116 virtual void runTransferDialog();
117 virtual void customClicked();
119 void setDeviceType(const QString
& type
);
120 void setSpacesToUnderscores(bool yesno
);
121 static njb_t
*theNjb();
123 void expandItem( Q3ListViewItem
*item
);
127 virtual bool closeDevice();
128 virtual bool getCapacity(KIO::filesize_t
* total
, KIO::filesize_t
* available
);
130 // virtual bool isSpecialItem(MediaItem* item);
132 virtual bool lockDevice(bool tryOnly
);
133 virtual bool openDevice(bool silent
);
135 int deleteFromDevice(unsigned id
);
136 int deleteItemFromDevice(MediaItem
* item
, int flags
=DeleteTrack
);
137 int deleteTrack(NjbMediaItem
*trackItem
);
139 int downloadSelectedItems();
140 int downloadToCollection();
142 virtual MediaItem
* copyTrackToDevice(const MetaBundle
& bundle
);
143 virtual void copyTrackFromDevice(MediaItem
*item
);
145 virtual void cancelTransfer();
146 virtual void synchronizeDevice() {};
148 virtual void unlockDevice();
150 virtual void updateRootItems() {};
154 MediaItem
*trackExists( const MetaBundle
& );
155 // miscellaneous methods
156 static int progressCallback( u_int64_t sent
, u_int64_t total
, const char* /*buf*/, unsigned /*len*/, void* data
);
158 int readJukeboxMusic( void);
161 NjbMediaItem
*addTrackToView(NjbTrack
*track
, NjbMediaItem
*item
=0);
162 NjbMediaItem
* addAlbums( const QString
&artist
, NjbMediaItem
*item
);
163 NjbMediaItem
* addTracks( const QString
&artist
, const QString
&track
, NjbMediaItem
*item
);
164 NjbMediaItem
* addTrack( NjbTrack
*track
);
165 NjbMediaItem
* addArtist( NjbTrack
*track
);
166 TransferDialog
*m_td
;
168 Q3ListView
*listAmarokPlayLists
;
171 bool m_connected
; // Replaces m_captured from the original code.
173 njb_t njbs
[NJB_MAX_DEVICES
];
175 trackValueList trackList
;
179 unsigned m_progressStart
;
180 QString m_progressMessage
;
181 NjbMediaItem
*m_artistItem
;
182 NjbMediaItem
*m_albumItem
;
183 NjbMediaItem
*m_allTracksItem
;