aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk-audio-konf/0001-add-n-flag-to-prevent-dynamic-create-of-conference.patch
blob: 115c42fa2854d626563c1feb00350342d760b027 (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
From 2040c4ebe42ed6a222b87f0148c0c08701afc2fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Mon, 7 Jun 2010 14:20:42 +0300
Subject: [PATCH] add 'n' flag to prevent dynamic create of conference

---
 konference/Dialplan.txt |    2 ++
 konference/conference.c |   27 ++++++++++++++++++---------
 konference/conference.h |    2 +-
 konference/member.c     |   12 +++++++-----
 konference/member.h     |    3 +++
 5 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/konference/Dialplan.txt b/konference/Dialplan.txt
index 455703d..17287dd 100644
--- a/konference/Dialplan.txt
+++ b/konference/Dialplan.txt
@@ -45,6 +45,8 @@ exten => <ext>,<pri>,Konference(<confname>,<flags>,<optional args>,<more optiona
 	'r' : record the conference.  it will be recorded to KONFERENCE_RECORDINGFILE with the format KONFERENCE_RECORDINGFORMAT
 		default for KONFERENCE_RECORDINGFILE is: konference-{conference-name}-{member-uniqueid}
 		default for KONFERENCE_RECORDINGFORMAT is: wav
+	'n' : do not create new conference, only join existing ones.
+		if conference does not exist KONFERENCE is set to NOTFOUND
 
 	Future development (these are not implemented yet):
 	?
diff --git a/konference/conference.c b/konference/conference.c
index 9790d2e..98fed28 100644
--- a/konference/conference.c
+++ b/konference/conference.c
@@ -620,7 +620,7 @@ void init_conference( void )
 	argument_delimiter = ( !strcmp(PACKAGE_VERSION,"1.4") ? "|" : "," ) ;
 }
 
-struct ast_conference* join_conference( struct ast_conf_member* member, char* max_users_flag, const char* recfile, const char *recformat )
+struct ast_conference* join_conference( struct ast_conf_member* member, const char* recfile, const char *recformat )
 {
 	struct ast_conference* conf = NULL ;
 
@@ -634,15 +634,25 @@ struct ast_conference* join_conference( struct ast_conf_member* member, char* ma
 	// unable to find an existing conference, try to create one
 	if ( conf == NULL )
 	{
-		// create a new conference
-		DEBUG("attempting to create requested conference\n") ;
+		if ( member->no_create_flag )
+		{
+			DEBUG("conference not found, and create of new conference not allowed\n") ;
+			pbx_builtin_setvar_helper(member->chan, "KONFERENCE", "NOTFOUND");
+		}
+		else
+		{
+			// create a new conference
+			DEBUG("attempting to create requested conference\n") ;
 
-		// create the new conference with one member
-		conf = create_conf( member->conf_name, member ) ;
+			// create the new conference with one member
+			conf = create_conf( member->conf_name, member ) ;
 
-		// return an error if create_conf() failed
-		if ( conf == NULL )
-			ast_log( LOG_ERROR, "unable to find or create requested conference\n" ) ;
+			// return an error if create_conf() failed
+			if ( conf == NULL ) {
+				ast_log( LOG_ERROR, "unable to find or create requested conference\n" ) ;
+				pbx_builtin_setvar_helper(member->chan, "KONFERENCE", "NORESOURCES");
+			}
+		}
 	}
 	else
 	{
@@ -656,7 +666,6 @@ struct ast_conference* join_conference( struct ast_conf_member* member, char* ma
 			add_member( member, conf ) ;
 		} else {
 			pbx_builtin_setvar_helper(member->chan, "KONFERENCE", "MAXUSERS");
-			*max_users_flag = 1;
 			conf = NULL;
 		}
 	}
diff --git a/konference/conference.h b/konference/conference.h
index 3322f3f..e8da836 100644
--- a/konference/conference.h
+++ b/konference/conference.h
@@ -157,7 +157,7 @@ int hash( const char *channel_name ) ;
 
 int count_exec( struct ast_channel* chan, void* data ) ;
 
-struct ast_conference* join_conference( struct ast_conf_member* member, char* max_users_flag, const char* recfile, const char* recformat ) ;
+struct ast_conference* join_conference( struct ast_conf_member* member, const char* recfile, const char* recformat ) ;
 
 int end_conference( const char *name, int hangup ) ;
 
diff --git a/konference/member.c b/konference/member.c
index c18fcdc..ff93b36 100644
--- a/konference/member.c
+++ b/konference/member.c
@@ -758,14 +758,13 @@ int member_exec( struct ast_channel* chan, void* data )
 	// setup a conference for the new member
 	//
 
-	char max_users_flag = 0 ;
-	conf = join_conference( member, &max_users_flag, recfile, recformat ) ;
+	conf = join_conference( member, recfile, recformat ) ;
 
 	if ( conf == NULL )
 	{
-		ast_log( LOG_NOTICE, "unable to setup member conference %s: max_users_flag is %d\n", member->conf_name, max_users_flag ) ;
+		ast_log( LOG_NOTICE, "unable to setup member conference %s\n", member->conf_name) ;
 		delete_member( member) ;
-		return (max_users_flag ? 0 : -1 ) ;
+		return -1;
 	}
 
 	//
@@ -1349,7 +1348,7 @@ struct ast_conf_member* create_member( struct ast_channel *chan, const char* dat
 		else
 #endif
 		{
-			// allowed flags are C, c, L, l, V, D, A, C, X, r, R, T, t, M, S, z, o, F, H
+			// allowed flags are C, c, L, l, V, D, A, C, X, r, R, T, t, M, S, z, o, F, H, n
 			// mute/no_recv options
 			switch ( flags[i] )
 			{
@@ -1405,6 +1404,9 @@ struct ast_conf_member* create_member( struct ast_channel *chan, const char* dat
 			case 'M':
 				member->ismoderator = 1;
 				break;
+			case 'n':
+				member->no_create_flag = 1;
+				break;
 #ifdef	VIDEO
 			case 'N':
 				member->no_camera = 1;
diff --git a/konference/member.h b/konference/member.h
index 0f9005b..28eff6b 100644
--- a/konference/member.h
+++ b/konference/member.h
@@ -105,6 +105,9 @@ struct ast_conf_member
 	// wait option flag
 	char wait_for_moderator_flag;
 
+	// creation of new conference not allowed
+	char no_create_flag;
+
 	// temp flag for when star is pressed
 	char star_pressed;
 
-- 
1.7.0.4