1 /***************************************************************************
2 * Copyright (C) 2003-2005 by The Amarok Developers *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef COLLECTIONSCANNER_H
21 #define COLLECTIONSCANNER_H
23 #include "metabundle.h"
25 #include <sys/types.h>
30 #include <QStringList>
33 #include <kapplication.h>
34 #include <amarok_collection_interface.h>
36 typedef QMap
<QString
, QString
> AttributeMap
;
40 * @class CollectionScanner
41 * @short Scans directories and builds the Collection
44 class CollectionScanner
: public KApplication
49 CollectionScanner( const QStringList
& folders
,
56 int newInstance() { return 0; }
62 void readDir( const QString
& dir
, QStringList
& entries
);
63 void scanFiles( const QStringList
& entries
);
66 * Read metadata tags of a given file.
67 * @mb MetaBundle for the file.
68 * @return QMap containing tags, or empty QMap on failure.
70 AttributeMap
readTags( const MetaBundle
& mb
);
73 * Helper method for writing XML elements to stdout.
74 * @name Name of the element.
75 * @attributes Key/value map of attributes.
77 void writeElement( const QString
& name
, const AttributeMap
& attributes
);
81 * @return the LOWERCASE file extension without the preceding '.', or "" if there is none
83 inline QString
extension( const QString
&fileName
)
85 return fileName
.contains( '.' ) ? fileName
.mid( fileName
.lastIndexOf( '.' ) + 1 ).toLower() : "";
89 * @return the last directory in @param fileName
91 inline QString
directory( const QString
&fileName
)
93 return fileName
.section( '/', 0, -2 );
97 const bool m_importPlaylists
;
98 QStringList m_folders
;
99 const bool m_recursively
;
100 const bool m_incremental
;
101 const bool m_restart
;
102 const QString m_logfile
;
103 QStringList m_scannedFolders
;
105 OrgKdeAmarokCollectionInterface
*amarokCollectionInterface
;
109 #endif // COLLECTIONSCANNER_H