listener.h 4.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
	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
    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_sip_listener_h
#define belle_sip_listener_h

Simon Morlat's avatar
Simon Morlat committed
23 24 25 26 27 28
typedef struct belle_sip_dialog_terminated_event belle_sip_dialog_terminated_event_t;
typedef struct belle_sip_io_error_event belle_sip_io_error_event_t;
typedef struct belle_sip_request_event belle_sip_request_event_t;
typedef struct belle_sip_response_event belle_sip_response_event_t;
typedef struct belle_sip_timeout_event belle_sip_timeout_event_t;
typedef struct belle_sip_transaction_terminated_event belle_sip_transaction_terminated_event_t;
29 30
typedef struct belle_sip_auth_event belle_sip_auth_event_t;

Simon Morlat's avatar
Simon Morlat committed
31 32 33 34 35 36 37 38

BELLE_SIP_DECLARE_INTERFACE_BEGIN(belle_sip_listener_t)
	void (*process_dialog_terminated)(belle_sip_listener_t *user_ctx, const belle_sip_dialog_terminated_event_t *event);
	void (*process_io_error)(belle_sip_listener_t *user_ctx, const belle_sip_io_error_event_t *event);
	void (*process_request_event)(belle_sip_listener_t *user_ctx, const belle_sip_request_event_t *event);
	void (*process_response_event)(belle_sip_listener_t *user_ctx, const belle_sip_response_event_t *event);
	void (*process_timeout)(belle_sip_listener_t *user_ctx, const belle_sip_timeout_event_t *event);
	void (*process_transaction_terminated)(belle_sip_listener_t *user_ctx, const belle_sip_transaction_terminated_event_t *event);
39
	void (*process_auth_requested)(belle_sip_listener_t *user_ctx, belle_sip_auth_event_t *event);
Simon Morlat's avatar
Simon Morlat committed
40 41 42
BELLE_SIP_DECLARE_INTERFACE_END

#define BELLE_SIP_LISTENER(obj) BELLE_SIP_INTERFACE_CAST(obj,belle_sip_listener_t)
43

44
/*Response event*/
jehan's avatar
jehan committed
45
belle_sip_response_t* belle_sip_response_event_get_response(const belle_sip_response_event_t* event);
46
belle_sip_client_transaction_t *belle_sip_response_event_get_client_transaction(const belle_sip_response_event_t* event);
Simon Morlat's avatar
Simon Morlat committed
47
belle_sip_dialog_t *belle_sip_response_event_get_dialog(const belle_sip_response_event_t* event);
48

49
/*Request event*/
Simon Morlat's avatar
Simon Morlat committed
50 51 52
belle_sip_request_t* belle_sip_request_event_get_request(const belle_sip_request_event_t* event);
belle_sip_server_transaction_t *belle_sip_request_event_get_server_transaction(const belle_sip_request_event_t* event);
belle_sip_dialog_t *belle_sip_request_event_get_dialog(const belle_sip_request_event_t* event);
53

54 55 56
/*Dialog terminated event*/
belle_sip_dialog_t* belle_sip_dialog_terminated_get_dialog(const belle_sip_dialog_terminated_event_t *event);

57
/*auth event*/
58
void belle_sip_auth_event_destroy(belle_sip_auth_event_t* event);
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
const char* belle_sip_auth_event_get_username(const belle_sip_auth_event_t* event);
void belle_sip_auth_event_set_username(belle_sip_auth_event_t* event, const char* value);

const char* belle_sip_auth_event_get_userid(const belle_sip_auth_event_t* event);
void belle_sip_auth_event_set_userid(belle_sip_auth_event_t* event, const char* value);

const char* belle_sip_auth_event_get_realm(const belle_sip_auth_event_t* event);
void belle_sip_auth_event_set_realm(belle_sip_auth_event_t* event, const char* value);

const char* belle_sip_auth_event_get_passwd(const belle_sip_auth_event_t* event);
void belle_sip_auth_event_set_passwd(belle_sip_auth_event_t* event, const char* value);

const char* belle_sip_auth_event_get_ha1(const belle_sip_auth_event_t* event);
void belle_sip_auth_event_set_ha1(belle_sip_auth_event_t* event, const char* value);

74

75 76 77 78 79 80 81
struct belle_sip_listener_callbacks{
	void (*process_dialog_terminated)(void *user_ctx, const belle_sip_dialog_terminated_event_t *event);
	void (*process_io_error)(void *user_ctx, const belle_sip_io_error_event_t *event);
	void (*process_request_event)(void *user_ctx, const belle_sip_request_event_t *event);
	void (*process_response_event)(void *user_ctx, const belle_sip_response_event_t *event);
	void (*process_timeout)(void *user_ctx, const belle_sip_timeout_event_t *event);
	void (*process_transaction_terminated)(void *user_ctx, const belle_sip_transaction_terminated_event_t *event);
82
	void (*process_auth_requested)(void *user_ctx, belle_sip_auth_event_t *auth_event);
83 84 85 86 87 88 89 90 91 92
};

typedef struct belle_sip_listener_callbacks belle_sip_listener_callbacks_t;

/**
 * Creates an object implementing the belle_sip_listener_t interface.
 * This object passes the events to the callbacks, providing also the user context.
**/
belle_sip_listener_t *belle_sip_listener_create_from_callbacks(const belle_sip_listener_callbacks_t *callbacks, void *user_ctx);

93 94
#endif