1/* This file is part of Strigi Desktop Search
2 *
3 * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20#ifndef SOCKETCLIENT_H
21#define SOCKETCLIENT_H
22
23#include <strigi/strigiconfig.h>
24#include <strigi/clientinterface.h>
25
26class SEARCHCLIENT_EXPORT SocketClient : public ClientInterface {
27private:
28 std::string socketpath;
29 std::string error;
30 std::vector<std::string> request;
31 std::vector<std::string> response;
32
33 int open();
34 bool readResponse(int sd);
35 bool sendRequest(int sd);
36public:
37 SocketClient() :ClientInterface(0) {}
38 const std::string& getError() const { return error; }
39 void setSocketName(const std::string& socketname);
40 int32_t countHits(const std::string &query);
41 Hits getHits(const std::string &query, uint32_t max, uint32_t off);
42 std::map<std::string, std::string> getStatus();
43 std::string stopDaemon();
44 std::string startIndexing();
45 std::string stopIndexing();
46 std::set<std::string> getIndexedDirectories();
47 std::string setIndexedDirectories(std::set<std::string>);
48 void setFilters(const std::vector<std::pair<bool,std::string> >& rules);
49 std::vector<std::pair<bool,std::string> > getFilters();
50 std::set<std::string> getIndexedFiles();
51 void indexFile(const std::string &path, uint64_t mtime,
52 const std::vector<char>&);
53 std::vector<std::string> getFieldNames();
54 std::vector<std::pair<std::string, uint32_t> > getHistogram(
55 const std::string& query, const std::string& field,
56 const std::string& labeltype);
57 std::vector<std::string> getBackEnds();
58 int countKeywords(const std::string& keywordmatch,
59 const std::vector<std::string>& fieldnames);
60 std::vector<std::string> getKeywords(const std::string& keywordmatch,
61 const std::vector<std::string>& fieldnames,
62 uint32_t max, uint32_t offset);
63};
64
65#endif
66