00001 /* 00002 00003 Copyright (C) 2005-2007 by Peter Dimov. 00004 00005 This file is part of Calitko (http://www.calitko.org). 00006 00007 Calitko is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 Calitko is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Calitko; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 */ 00022 00023 #ifndef FILE_INDEXER_H 00024 #define FILE_INDEXER_H 00025 00026 // Open containing namespaces: 00027 namespace Gnutella { 00028 namespace Searching { 00030 00031 class FileInfo; 00032 00033 class FileIndexer : public QObject 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 FileIndexer(/*QueryRoutingFilter *queryRoutingFilter*/); 00039 ~FileIndexer(); 00040 00041 bool indexFolder (QString folderPath); 00042 bool removeFolder (QString folderPath); 00043 QList<FileInfo*> match (QString searchCriteria) const; 00044 00045 protected: 00046 void indexFile (QString filePath); 00047 void indexFile (FileInfo *fileInfo); 00048 void removeFolderFiles (QString folderPath); 00049 void removeFileFromWord (uint fileIndex, QString &word); 00050 void removeFile (FileInfo *fileInfo); 00051 void checkForAddedFolder(); 00052 QDataStream& readFileWords (QDataStream &stream); 00053 00054 protected slots: 00055 void refreshIndex(); 00056 protected: 00057 class CheckIndexThread : public QThread 00058 { 00059 public: 00060 CheckIndexThread (FileIndexer *fileInd); 00061 void run(); 00062 00063 private: 00064 REFERENCE_OBJECT (CheckIndexThread) 00065 FileIndexer *fileIndexer; 00066 }; 00067 00068 private: 00069 struct Private { 00070 QMap<QString, FileInfo*> fileWords; 00071 QMap<uint, FileInfo*> files; 00072 QList<QDir> sharedFolders; 00073 QTimer *refreshTimer; 00074 //QueryRoutingFilter *queryRoutingFilter; 00075 CheckIndexThread *checkThread; 00076 00077 Private() : fileWords(), files(), sharedFolders(), 00078 refreshTimer (0), checkThread (0) 00079 {} 00080 00081 private: 00082 REFERENCE_OBJECT (Private) 00083 } p; 00084 }; 00085 00086 // Close containing namespaces: 00087 } // namespace Searching 00088 } // namespace Gnutella 00090 00091 #endif // FILE_INDEXER_H