netatalk  4.4.0dev
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
spotlight.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2012 Frank Lahm <[email protected]>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13*/
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif /* HAVE_CONFIG_H */
18
19#ifndef SPOTLIGHT_H
20#define SPOTLIGHT_H
21
22#include <stdint.h>
23#include <stdbool.h>
24
25#include <gio/gio.h>
26
27#ifdef HAVE_TRACKER3
28#include <tracker-sparql.h>
29#else
30#include <tinysparql.h>
31#endif
32
33#include <atalk/globals.h>
34#include <atalk/volume.h>
35#include <atalk/dalloc.h>
36
37/******************************************************************************
38 * Spotlight RPC and marshalling stuff
39 ******************************************************************************/
40
41/* FPSpotlightRPC subcommand codes */
42#define SPOTLIGHT_CMD_OPEN 1
43#define SPOTLIGHT_CMD_FLAGS 2
44#define SPOTLIGHT_CMD_RPC 3
45#define SPOTLIGHT_CMD_OPEN2 4
46
47/* Can be ored and used as flags */
48#define SL_ENC_LITTLE_ENDIAN 1
49#define SL_ENC_BIG_ENDIAN 2
50#define SL_ENC_UTF_16 4
51
52/* an array of elements */
54/* an array of key/value elements */
56/* contains one sl_array_t */
58/* a nil element */
59typedef int sl_nil_t;
60/* a boolean, we avoid bool_t */
61typedef bool sl_bool_t;
62typedef struct timeval sl_time_t;
63typedef struct {
64 /* a UUID */
65 char sl_uuid[16];
66} sl_uuid_t;
67typedef struct {
68 /* an array of CNIDs */
69 uint16_t ca_unkn1;
70 uint32_t ca_context;
73
74/******************************************************************************
75 * Some helper stuff dealing with queries
76 ******************************************************************************/
77
78/* query state */
79typedef enum {
80 /* Query received from client */
82 /* Query dispatched to Tracker */
84 /* Async Tracker query read */
86 /* result queue is full */
88 /* Got all results from Tracker */
90 /* a cancel op for the query is pending */
92 /* the query has been cancelled */
94 /* an error happended somewhere */
97
98/* Handle for query results */
104
105/* Internal query data structure */
106typedef struct _slq_t {
107 /* queries are stored in a list */
109 /* State */
111 /* global AFPObj handle */
113 /* volume handle */
114 const struct vol *slq_vol;
115 /* search scope */
117 /* timestamp received query */
118 time_t slq_time;
119 /* client context 1 */
120 uint64_t slq_ctx1;
121 /* client context 2 */
122 uint64_t slq_ctx2;
123 /* array with requested metadata */
125 /* the Spotlight query string */
126 const char *slq_qstring;
127 /* Pointer to array with CNIDs */
128 uint64_t *slq_cnids;
129 /* Size of slq_cnids array */
131 /* Tracker SPARQL cursor */
133 /* Whether to allow expressions */
135 /* Whether to LIMIT SPARQL results */
137 /* query results */
140
141struct sl_ctx {
142 TrackerSparqlConnection *tracker_con;
143 GCancellable *cancellable;
144 GMainLoop *mainloop;
145 /* list of active queries */
147};
148
149/******************************************************************************
150 * Function declarations
151 ******************************************************************************/
152
153extern int spotlight_init(AFPObj *obj);
154extern int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen _U_,
155 char *rbuf, size_t *rbuflen);
156extern int sl_pack(DALLOC_CTX *query, char *buf);
157extern int sl_unpack(DALLOC_CTX *query, const char *buf);
158extern void configure_spotlight_attributes(const char *attributes);
159
160#endif /* SPOTLIGHT_H */
static size_t rbuflen
Definition afpfunc_helpers.c:45
static char rbuf[rbufsize]
Definition afpfunc_helpers.c:44
static char buf[MAXPATHLEN+1]
Definition afppasswd.c:66
static struct cnid_dbd_rqst rqst _U_
Definition cmd_dbd_scanvol.c:63
static AFPObj obj
Definition netatalk.c:62
void configure_spotlight_attributes(const char *attributes)
Definition sparql_map.c:107
bool sl_bool_t
Definition spotlight.h:61
int spotlight_init(AFPObj *obj)
Definition spotlight.c:1309
int sl_pack(DALLOC_CTX *query, char *buf)
Definition spotlight_marshalling.c:852
DALLOC_CTX sl_array_t
Definition spotlight.h:53
int sl_nil_t
Definition spotlight.h:59
struct timeval sl_time_t
Definition spotlight.h:62
DALLOC_CTX sl_dict_t
Definition spotlight.h:55
struct _slq_t slq_t
int sl_unpack(DALLOC_CTX *query, const char *buf)
Definition spotlight_marshalling.c:880
DALLOC_CTX sl_filemeta_t
Definition spotlight.h:57
int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
Definition spotlight.c:1364
slq_state_t
Definition spotlight.h:79
@ SLQ_STATE_NEW
Definition spotlight.h:81
@ SLQ_STATE_RUNNING
Definition spotlight.h:83
@ SLQ_STATE_CANCELLED
Definition spotlight.h:93
@ SLQ_STATE_DONE
Definition spotlight.h:89
@ SLQ_STATE_CANCEL_PENDING
Definition spotlight.h:91
@ SLQ_STATE_RESULTS
Definition spotlight.h:85
@ SLQ_STATE_FULL
Definition spotlight.h:87
@ SLQ_STATE_ERROR
Definition spotlight.h:95
Definition spotlight.h:106
uint64_t slq_ctx1
Definition spotlight.h:120
AFPObj * slq_obj
Definition spotlight.h:112
sl_array_t * slq_reqinfo
Definition spotlight.h:124
bool slq_allow_expr
Definition spotlight.h:134
uint64_t * slq_cnids
Definition spotlight.h:128
const struct vol * slq_vol
Definition spotlight.h:114
char * slq_scope
Definition spotlight.h:116
struct sl_rslts * query_results
Definition spotlight.h:138
slq_state_t slq_state
Definition spotlight.h:110
time_t slq_time
Definition spotlight.h:118
uint64_t slq_ctx2
Definition spotlight.h:122
const char * slq_qstring
Definition spotlight.h:126
size_t slq_cnids_num
Definition spotlight.h:130
struct list_head slq_list
Definition spotlight.h:108
void * tracker_cursor
Definition spotlight.h:132
uint64_t slq_result_limit
Definition spotlight.h:136
Definition globals.h:154
Definition dalloc.h:25
Definition include/atalk/list.h:17
Definition spotlight.h:67
DALLOC_CTX * ca_cnids
Definition spotlight.h:71
uint32_t ca_context
Definition spotlight.h:70
uint16_t ca_unkn1
Definition spotlight.h:69
Definition spotlight.h:141
slq_t * query_list
Definition spotlight.h:146
GCancellable * cancellable
Definition spotlight.h:143
GMainLoop * mainloop
Definition spotlight.h:144
TrackerSparqlConnection * tracker_con
Definition spotlight.h:142
Definition spotlight.h:99
int num_results
Definition spotlight.h:100
sl_cnids_t * cnids
Definition spotlight.h:101
sl_array_t * fm_array
Definition spotlight.h:102
Definition spotlight.h:63
char sl_uuid[16]
Definition spotlight.h:65
Definition include/atalk/volume.h:32