chenqiyang
2021-08-27 6a63c4281fbe7e17103115320cd276397d733081
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
/*
 * Copyright (c) 2012-2019 Belledonne Communications SARL.
 *
 * This file is part of belle-sip.
 *
 * 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 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
 
#ifndef belle_http_listener_h
#define belle_http_listener_h
 
struct belle_http_response_event{
    belle_sip_object_t *source;
    belle_http_request_t *request;
    belle_http_response_t *response;
};
 
typedef struct belle_http_response_event belle_http_response_event_t;
 
 
#define BELLE_HTTP_INTERFACE_FUNCS(argT) \
    void (*process_response_headers)(argT *user_ctx, const belle_http_response_event_t *event); \
    void (*process_response)(argT *user_ctx, const belle_http_response_event_t *event); \
    void (*process_io_error)(argT *user_ctx, const belle_sip_io_error_event_t *event); \
    void (*process_timeout)(argT *user_ctx, const belle_sip_timeout_event_t *event); \
    void (*process_auth_requested)(argT *user_ctx, belle_sip_auth_event_t *event);
 
BELLE_SIP_DECLARE_INTERFACE_BEGIN(belle_http_request_listener_t)
    BELLE_HTTP_INTERFACE_FUNCS(belle_http_request_listener_t)
BELLE_SIP_DECLARE_INTERFACE_END
 
struct belle_http_request_listener_callbacks{
    BELLE_HTTP_INTERFACE_FUNCS(void)
    void (*listener_destroyed)(void *user_ctx);
};
 
typedef struct belle_http_request_listener_callbacks belle_http_request_listener_callbacks_t;
 
#define BELLE_HTTP_REQUEST_LISTENER(obj) BELLE_SIP_INTERFACE_CAST(obj,belle_http_request_listener_t)
 
BELLE_SIP_BEGIN_DECLS
/**
 * Creates an object implementing the belle_http_request_listener_t interface.
 * This object passes the events to the callbacks, providing also the user context.
**/
BELLESIP_EXPORT belle_http_request_listener_t *belle_http_request_listener_create_from_callbacks(const belle_http_request_listener_callbacks_t *callbacks, void *user_ctx);
 
BELLE_SIP_END_DECLS
 
#endif