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
|
/*
* Copyright 2005-2010 Fabrice Colin
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SERVERTHREADS_HH
#define _SERVERTHREADS_HH
#include <string>
#include <vector>
#include <stack>
#include <sigc++/sigc++.h>
#include <glibmm/ustring.h>
#include "DocumentInfo.h"
#include "CrawlHistory.h"
#include "IndexInterface.h"
#ifdef HAVE_DBUS
#include "DBusIndex.h"
#endif
#include "MonitorInterface.h"
#include "MonitorHandler.h"
#include "QueryProperties.h"
#include "DaemonState.h"
#include "WorkerThreads.h"
class CrawlerThread : public DirectoryScannerThread
{
public:
CrawlerThread(const std::string &dirName, bool isSource,
MonitorInterface *pMonitor, MonitorHandler *pHandler,
bool inlineIndexing = false);
virtual ~CrawlerThread();
virtual std::string getType(void) const;
protected:
unsigned int m_sourceId;
MonitorInterface *m_pMonitor;
MonitorHandler *m_pHandler;
CrawlHistory m_crawlHistory;
std::map<std::string, CrawlItem> m_crawlCache;
std::stack<std::string> m_currentLinks;
std::stack<std::string> m_currentLinkReferrees;
virtual void recordCrawled(const std::string &location, time_t itemDate);
virtual bool isIndexable(const std::string &entryName) const;
virtual bool wasCrawled(const std::string &location, time_t &itemDate);
virtual void recordCrawling(const std::string &location, bool itemExists, time_t &itemDate);
virtual void recordError(const std::string &location, int errorCode);
virtual void recordSymlink(const std::string &location, time_t itemDate);
virtual bool monitorEntry(const std::string &entryName);
virtual void foundFile(const DocumentInfo &docInfo);
void flushUpdates(void);
virtual void doWork(void);
private:
CrawlerThread(const CrawlerThread &other);
CrawlerThread &operator=(const CrawlerThread &other);
};
#ifdef HAVE_DBUS
class DBusServletThread : public WorkerThread
{
public:
DBusServletThread(DaemonState *pServer, DBusServletInfo *pInfo);
virtual ~DBusServletThread();
static DBusGConnection *m_pSystemBus;
static DBusGConnection *m_pSessionBus;
static void flushIndexAndSignal(IndexInterface *pIndex);
virtual std::string getType(void) const;
DBusServletInfo *getServletInfo(void) const;
bool mustQuit(void) const;
protected:
DaemonState *m_pServer;
DBusServletInfo *m_pServletInfo;
bool m_mustQuit;
virtual void doWork(void);
private:
DBusServletThread(const DBusServletThread &other);
DBusServletThread &operator=(const DBusServletThread &other);
};
#endif
class RestoreMetaDataThread : public WorkerThread
{
public:
RestoreMetaDataThread();
virtual ~RestoreMetaDataThread();
virtual std::string getType(void) const;
protected:
virtual void doWork(void);
private:
RestoreMetaDataThread(const RestoreMetaDataThread &other);
RestoreMetaDataThread &operator=(const RestoreMetaDataThread &other);
};
#endif // _SERVERTHREADS_HH
|