File indexing completed on 2024-05-12 16:18:06

0001 /****************************************************************************************
0002  * Copyright (C) 2003-2010 Mark Kretschmann <kretschmann@kde.org>                       *
0003  * Copyright (C) 2008 Dan Meltzer <parallelgrapefruit@gmail.com>                        *
0004  * Copyright (C) 2008-2009 Jeff Mitchell <mitchell@kde.org>                             *
0005  * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz>                                      *
0006  *                                                                                      *
0007  * This program is free software; you can redistribute it and/or modify it under        *
0008  * the terms of the GNU General Public License as published by the Free Software        *
0009  * Foundation; either version 2 of the License, or (at your option) any later           *
0010  * version.                                                                             *
0011  *                                                                                      *
0012  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0013  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0014  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0015  *                                                                                      *
0016  * You should have received a copy of the GNU General Public License along with         *
0017  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0018  ****************************************************************************************/
0019 
0020 #ifndef COLLECTIONSCANNER_SCANNINGSTATE_H
0021 #define COLLECTIONSCANNER_SCANNINGSTATE_H
0022 
0023 #include "amarokshared_export.h"
0024 
0025 #include <QSharedMemory>
0026 #include <QString>
0027 #include <QStringList>
0028 
0029 namespace CollectionScanner
0030 {
0031 
0032 /** A class used to store the current scanning state in a shared memory segment.
0033     Storing the state of the scanner shouldn't cause a file access.
0034     We are using a shared memory that the amarok process holds open until the scanning
0035     is finished to store the state.
0036  */
0037 class AMAROKSHARED_EXPORT ScanningState
0038 {
0039     public:
0040         ScanningState();
0041         ~ScanningState();
0042 
0043         void setKey( const QString &key );
0044         bool isValid() const;
0045 
0046         QString lastDirectory() const;
0047         void setLastDirectory( const QString &dir );
0048 
0049         QStringList badFiles() const;
0050         void setBadFiles( const QStringList &badFiles );
0051 
0052         QString lastFile() const;
0053         void setLastFile( const QString &file );
0054 
0055         void readFull();
0056         void writeFull();
0057 
0058     private:
0059         QSharedMemory *m_sharedMemory;
0060 
0061         QString m_lastDirectory;
0062         QStringList m_badFiles;
0063         QString m_lastFile;
0064         qint64 m_lastFilePos;
0065 };
0066 
0067 }
0068 
0069 #endif // COLLECTIONSCANNER_SCANNINGSTATE_H