http-listener.h 2.32 KB
Newer Older
Simon Morlat's avatar
Simon Morlat committed
1 2 3 4 5 6 7

/*
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2010  Belledonne Communications SARL

    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
8
    the Free Software Foundation, either version 2 of the License, or
Simon Morlat's avatar
Simon Morlat committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
    (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{
25
	belle_sip_object_t *source;
Simon Morlat's avatar
Simon Morlat committed
26 27 28 29 30 31 32 33
	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) \
34
	void (*process_response_headers)(argT *user_ctx, const belle_http_response_event_t *event); \
35
	void (*process_response)(argT *user_ctx, const belle_http_response_event_t *event); \
36 37
	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); \
Simon Morlat's avatar
Simon Morlat committed
38 39 40 41 42 43 44
	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{
45
	BELLE_HTTP_INTERFACE_FUNCS(void)
Simon Morlat's avatar
Simon Morlat committed
46
	void (*listener_destroyed)(void *user_ctx);
Simon Morlat's avatar
Simon Morlat committed
47 48 49 50
};

typedef struct belle_http_request_listener_callbacks belle_http_request_listener_callbacks_t;

Simon Morlat's avatar
Simon Morlat committed
51 52
#define BELLE_HTTP_REQUEST_LISTENER(obj) BELLE_SIP_INTERFACE_CAST(obj,belle_http_request_listener_t)

Simon Morlat's avatar
Simon Morlat committed
53 54 55 56 57 58 59 60 61 62
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