summaryrefslogtreecommitdiffstats
path: root/src/sub_refer.h
blob: 67747791090396c01eb8973d83a8db8b944e7d00 (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
/*
    Copyright (C) 2005-2009  Michel de Boer <michel@twinklephone.com>

    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 2 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, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// RFC 3515
// Refer event package

#ifndef _SUB_REFER_H
#define _SUB_REFER_H

#include "subscription.h"
#include "dialog.h"

// State of reference as seen by the referrer
enum t_sub_refer_result {
	SRR_INPROG,	// Referee is referring call
	SRR_FAILED,	// Refer failed
	SRR_SUCCEEDED,	// Refer succeeded
};

class t_sub_refer : public t_subscription {
private:
	// Result of the reference as seen by the referrer.
	t_sub_refer_result	sr_result;

	// Last response received from the refer-target
	t_response		*last_response;

	// Current substate of the notification
	string			current_substate;
	
	t_dialog *get_dialog(void) const;

public:
	t_sub_refer(t_dialog *_dialog, t_subscription_role _role);
	t_sub_refer(t_dialog *_dialog, t_subscription_role _role,
		const string &_event_id);
	virtual ~t_sub_refer();

	// Send a NOTIFY with the status line of the response as body
	// substate indicates the subscription state of refer
	// A reason should be given if substate == TERMINATED
	void send_notify(t_response *r, const string &substate,
		const string reason = "");

	bool recv_notify(t_request *r, t_tuid tuid, t_tid tid);
	bool recv_subscribe(t_request *r, t_tuid tuid, t_tid tid);

	bool timeout(t_subscribe_timer timer);

	t_sub_refer_result get_sr_result(void) const;
};

#endif