/* This Work is under GPL provided with this work. This work is based on the java implementation of the Kademlia protocol. Kademlia: Peer-to-peer routing based on the XOR metric Copyright (C) 2002 Petar Maymounkov [petar@post.harvard.edu] http://kademlia.scs.cs.nyu.edu and This work is bassed on translation from Barry Dunne to C++ Copyright (C)2003 Barry Dunne (http://www.emule-project.net) */ #ifndef cSearchManager_h #define cSearchManager_h #include #include #include "cygwin.h" #include "cHash.h" #include "cPeer.h" #include "cBucket.h" #include "cSearch.h" class TagList; class CTag; class cSearch; typedef std::map SearchMap; class WordList; class cSearchManager { friend class cZone; // friend class CTimer; public: static void stopSearch(size_t searchID); static void stopAllSearches(void); // Will return unique search id, returns zero if already searching for this file. // static uint32 findFile(SEARCH_ID_CALLBACK callback, const CUInt128 &id); // Search for a particular file // Pass a list of keywords and restrictions. // eg: uint32 searchID = findFile(MyCallback, 2, "Britney", SEARCH_IMAGE); // Will return unique search id, returns zero if already searching for this keyword. // static uint32 findKeywords(SEARCH_KEYWORD_CALLBACK callback, uint32 numParams, LPCSTR keyword, ...); static void processResponse (const uint8_t *target, uint32_t fromIP, uint16_t fromPort, cPeerList *results); static void processResult (const uint8_t *target, uint32_t fromIP, uint16_t fromPort, const uint8_t *answer, TagList *info); static void getWords (const char *str, WordList *words); static SearchMap m_searches; static size_t findFile (const uint8_t *id); static void jumpStart (void); static bool alreadySearchingFor (const uint8_t *target); static bool isKeywordSearch (const uint8_t *id); void getWords (const char *str, cWordList *words); size_t findKeywords (const char *text); private: static void findNode (const uint8_t *id); static size_t m_nextID; // static CCriticalSection m_critical; }; #endif