summaryrefslogtreecommitdiff
path: root/src/libtracker-sparql/remote/tracker-http.h
blob: 15e3498c0cd42a3331df547108a4dadc9b746efd (plain)
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
/*
 * Copyright (C) 2022, Red Hat Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 * Author: Carlos Garnacho <carlosg@gnome.org>
 */

#ifndef TRACKER_HTTP_H
#define TRACKER_HTTP_H

#include <gio/gio.h>

#ifndef MODULE
#include <libtracker-sparql/tracker-enums-private.h>
#endif

typedef struct _TrackerHttpRequest TrackerHttpRequest;

#define TRACKER_TYPE_HTTP_SERVER (tracker_http_server_get_type ())
G_DECLARE_DERIVABLE_TYPE (TrackerHttpServer,
                          tracker_http_server,
                          TRACKER, HTTP_SERVER,
                          GObject)

struct _TrackerHttpServerClass {
	GObjectClass parent_class;

	void (* response) (TrackerHttpServer       *server,
	                   TrackerHttpRequest      *request,
	                   TrackerSerializerFormat  format,
	                   GInputStream            *content);
	void (* error) (TrackerHttpServer  *server,
	                TrackerHttpRequest *request,
	                gint                code,
	                const gchar        *message);
};

TrackerHttpServer * tracker_http_server_new (guint             port,
                                             GTlsCertificate  *certificate,
                                             GCancellable     *cancellable,
                                             GError          **error);

void tracker_http_server_response (TrackerHttpServer       *server,
                                   TrackerHttpRequest      *request,
                                   TrackerSerializerFormat  format,
                                   GInputStream            *content);

void tracker_http_server_error (TrackerHttpServer       *server,
                                TrackerHttpRequest      *request,
                                gint                     code,
                                const gchar             *message);

#define TRACKER_TYPE_HTTP_CLIENT (tracker_http_client_get_type ())
G_DECLARE_DERIVABLE_TYPE (TrackerHttpClient,
                          tracker_http_client,
                          TRACKER, HTTP_CLIENT,
                          GObject)

struct _TrackerHttpClientClass {
	GObjectClass parent_class;

	void (* send_message_async) (TrackerHttpClient   *client,
	                             const gchar         *uri,
	                             const gchar         *query,
	                             guint                formats,
	                             GCancellable        *cancellable,
	                             GAsyncReadyCallback  callback,
	                             gpointer             user_data);
	GInputStream * (* send_message_finish) (TrackerHttpClient        *client,
	                                        GAsyncResult             *res,
	                                        TrackerSerializerFormat  *format,
	                                        GError                  **error);
	GInputStream * (* send_message) (TrackerHttpClient        *client,
	                                 const gchar              *uri,
	                                 const gchar              *query,
	                                 guint                     formats,
	                                 GCancellable             *cancellable,
	                                 TrackerSerializerFormat  *format,
	                                 GError                  **error);
};

TrackerHttpClient * tracker_http_client_new (void);

GInputStream *
tracker_http_client_send_message (TrackerHttpClient        *client,
                                  const gchar              *uri,
                                  const gchar              *query,
                                  guint                     formats,
                                  GCancellable             *cancellable,
                                  TrackerSerializerFormat  *format,
                                  GError                  **error);

void
tracker_http_client_send_message_async (TrackerHttpClient   *client,
                                        const gchar         *uri,
                                        const gchar         *query,
                                        guint                formats,
                                        GCancellable        *cancellable,
                                        GAsyncReadyCallback  callback,
                                        gpointer             user_data);

GInputStream *
tracker_http_client_send_message_finish (TrackerHttpClient        *client,
                                         GAsyncResult             *res,
                                         TrackerSerializerFormat  *format,
                                         GError                  **error);

#endif /* TRACKER_HTTP_H */