/usr/include/dclib-0.3/dclib/csearchmanager.h is in libdc-dev 0.3.24~svn3121-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | /***************************************************************************
csearchmanager.h - description
-------------------
begin : Thu May 27 2004
copyright : (C) 2004 by Mathias Küster
email : mathen@users.berlios.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef CSEARCHMANAGER_H
#define CSEARCHMANAGER_H
/**
*@author Mathias Küster
*
* This whole class is mainly designed for automatically entering, doing
* the search, and leaving, hubs, from some list. I doubt any other
* client does this nor any hub would want this behaviour.
*
* What this class can not do is match search results to searches, nor can
* it manage a changing list of searches. Results are either sent to
* CDownloadManager for auto searches or via a single callback to one
* search window. There is a list of searches, but that can only be set
* when starting the search.
*
* Valknut may have been modified to allow more than one search window
* but it does not allow more than one search to be running at a time.
*/
#include <time.h>
#include <dclib/dcos.h>
#include <dclib/core/cstring.h>
#include <dclib/core/cconnection.h>
#include <dclib/core/csingleton.h>
#include <dclib/cclient.h>
#include <dclib/csearchsocket.h>
#include <dclib/core/cstringlist.h>
#include <dclib/core/ccallback.h>
/** */
class CSearchClient : public CClient {
public:
/** */
CSearchClient() {
m_bSearchRemove = false;
m_bSearchEnable = false;
m_pCurrentSearchObject = 0;
m_tSearchTimeout = 0;
};
/** */
virtual ~CSearchClient() {};
/** */
bool m_bSearchRemove;
/** */
bool m_bSearchEnable;
/** */
time_t m_tSearchTimeout;
/** */
CDCMessage * m_pCurrentSearchObject;
};
/** search modes */
enum eSearchMode {
esmCONNECTEDSINGLE = 0,
esmCONNECTEDALL,
esmPUBLIC,
esmBOOKMARK
};
enum eSearchState {
esNONE = 0,
esSEARCH,
esTIMEOUT,
esSTOP
};
/** */
enum eSearchError {
eseNONE = 0,
eseALREADYRUN
};
/** */
enum eSearchType {
estyNONE = 0,
estySINGLE,
estyMULTI,
estyEXTERNAL
};
/** */
class CSearchManager : public CSingleton<CSearchManager> {
public:
/** */
CSearchManager();
/** */
virtual ~CSearchManager();
/** */
int CallBackManager();
/** */
int CallBackClient( CClient * Client, CDCMessage * DCMessage );
/** */
int CallBackSearchSocket( CMessageSearchResult* );
/** */
eSearchError StartSearch( eSearchMode mode, eSearchType type, CList<CDCMessage> * querylist, CStringList<CString> * serverlist );
/** */
void StopSearch();
/** */
bool HandleSearch( CDCMessage * message );
/** */
enum eSearchType SearchType() { return m_eSearchType; }
/** */
long MaxClients() { return m_nMaxClients; }
/** */
void MaxClients( long n ) { m_nMaxClients = n; }
/** */
void EnableTag( bool b ) { m_bEnableTag = b; }
/** */
bool IsSearch() { return (m_eSearchType != estyNONE); }
/** */
eSearchState SearchState() { eSearchState e; m_Mutex.Lock(); e = m_eSearchState; m_Mutex.UnLock(); return e; }
/** */
void SearchState( eSearchState e ) { m_Mutex.Lock(); m_eSearchState = e; m_Mutex.UnLock(); }
/** */
void SetCallBackFunction( _CCallback1<CDCMessage*> * callback );
/** */
_CCallback1<CDCMessage*> * GetCallBackFunction();
/** */
time_t StartTime() { return m_tStartTime; };
/** */
long HubCount();
/** */
long HubIndex() { return m_nHubIndex; };
/** */
long HubError() { return m_nHubError; };
protected:
private:
/** */
bool AddClients();
/** */
bool AddClient();
/** */
void UpdateClients();
/** */
bool RemoveClients();
/** */
void DisconnectClients();
/** */
bool DoSearch( CSearchClient * HubSearchClient );
/** */
bool SendObject( CDCMessage * DCMessage );
/** manager callback */
_CCallback0 * m_pCallback;
/** */
CMutex m_Mutex;
/** client list */
CList<CSearchClient> * m_pClientList;
/** max simultan clients */
long m_nMaxClients;
/** current hub index */
long m_nHubIndex;
/** hub with errors */
long m_nHubError;
/** current hub */
CString * m_sCurrentHub;
/** hub list */
CStringList<CString> * m_pHubList;
/** */
CList<CDCMessage> * m_pSearchList;
/** only for passive searches */
CDCMessage * m_pCurrentSearchObject;
/** */
bool m_bEnableTag;
/** */
bool m_bHandleUserList;
/** */
CSearchSocket m_SearchSocket;
/** starttime */
time_t m_tStartTime;
/** timeout */
time_t m_tTimeoutTime;
/** search type */
enum eSearchType m_eSearchType;
/** search state */
enum eSearchState m_eSearchState;
/** search mode */
enum eSearchMode m_eSearchMode;
/** client mode */
enum eClientMode m_eClientMode;
/** callback function */
_CCallback1<CDCMessage*> * m_pParentCallback;
/** mutex for changing callback */
CMutex m_CallbackMutex;
};
/** */
inline void CSearchManager::SetCallBackFunction( _CCallback1<CDCMessage*> * callback )
{ m_CallbackMutex.Lock(); m_pParentCallback = callback; m_CallbackMutex.UnLock(); }
/** */
inline _CCallback1<CDCMessage*> * CSearchManager::GetCallBackFunction()
{ return m_pParentCallback; }
#endif
|