--- app_meetme.c.orig	2004-07-03 12:41:02.000000000 -0400
+++ app_meetme.c	2004-07-03 13:33:28.000000000 -0400
@@ -66,11 +66,11 @@
 "      'v' -- video mode\n"
 "      'q' -- quiet mode (don't play enter/leave sounds)\n"
 "      'M' -- enable music on hold when the conference has a single caller\n"
-"      'x' -- exit the conference if the last marked user left\n"
-"      'w' -- wait until a marked user has entered the conference\n"
+"      'x' -- exit the conference if the last admin user left\n"
+"      'w' -- wait until a admin user has entered the conference\n"
 "      'b' -- run AGI script specified in ${MEETME_AGI_BACKGROUND}\n"
 "         Default: conf-background.agi\n"
-"        (Note: This does not work with non-Zap channels in the same conference)\n"
+"         (Note: This does not work with non-Zap channels in the same conference)\n"
 "      's' -- Present menu (user or admin) when '*' is received ('send' to menu)\n"
 "      'a' -- set admin mode\n";
 
@@ -100,7 +100,7 @@
 	int fd;				/* Announcements fd */
 	int zapconf;			/* Zaptel Conf # */
 	int users;			/* Number of active users */
-	int markedusers;		  /* Number of marked users */
+	int admins;		  	/* Number of admin users */
 	struct ast_conf_user *firstuser;  /* Pointer to the first user struct */
 	struct ast_conf_user *lastuser;   /* Pointer to the last user struct */
 	time_t start;			/* Start time (s) */
@@ -136,6 +136,7 @@
 #define LEAVE	1
 
 #define CONF_SIZE 320
+#define MAXRETRY 3
 
 #define CONFFLAG_ADMIN	(1 << 1)	/* If set the user has admin access on the conference */
 #define CONFFLAG_MONITOR (1 << 2)	/* If set the user can only receive audio from the conference */
@@ -146,8 +147,8 @@
 #define CONFFLAG_VIDEO (1 << 7)		/* Set to enable video mode */
 #define CONFFLAG_AGI (1 << 8)		/* Set to run AGI Script in Background */
 #define CONFFLAG_MOH (1 << 9)		/* Set to have music on hold when user is alone in conference */
-#define CONFFLAG_ADMINEXIT (1 << 10)    /* If set the MeetMe will return if all marked with this flag left */
-#define CONFFLAG_WAITMARKED (1 << 11)		/* If set, the MeetMe will wait until a marked user enters */
+#define CONFFLAG_ADMINEXIT (1 << 10)    /* If set the MeetMe will return if all admin with this flag left */
+#define CONFFLAG_WAITADMIN (1 << 11)		/* If set, the MeetMe will wait until a admin user enters */
 
 
 static int careful_write(int fd, unsigned char *data, int len)
@@ -213,7 +214,7 @@
 			memset(cnf, 0, sizeof(struct ast_conference));
 			strncpy(cnf->confno, confno, sizeof(cnf->confno) - 1);
 			strncpy(cnf->pin, pin, sizeof(cnf->pin) - 1);
-			cnf->markedusers = -1;
+			cnf->admins = -1;
 			cnf->chan = ast_request("zap", AST_FORMAT_ULAW, "pseudo");
 			if (cnf->chan) {
 				cnf->fd = cnf->chan->fds[0];	/* for use by conf_play() */
@@ -273,7 +274,7 @@
 static struct ast_cli_entry cli_show_confs = {
 	{ "show", "conferences", NULL }, confs_show,
 	"Show status of conferences", show_confs_usage, NULL };
-	
+
 static int conf_cmd(int fd, int argc, char **argv) {
 	/* Process the command */
 	struct ast_conference *cnf;
@@ -294,18 +295,20 @@
 	}
 	if (argc == 1) {
 		/* 'MeetMe': List all the conferences */	
-	now = time(NULL);
+		now = time(NULL);
 		cnf = confs;
 		if (!cnf) {
-		ast_cli(fd, "No active MeetMe conferences.\n");
-		return RESULT_SUCCESS;
-	}
-	ast_cli(fd, header_format, "Conf Num", "Parties", "Marked", "Activity", "Creation");
+			ast_cli(fd, "No active MeetMe conferences.\n");
+			return RESULT_SUCCESS;
+		}
+
+		ast_cli(fd, header_format, "Conf Num", "Parties", "Marked", "Activity", "Creation");
+
 		while(cnf) {
-			if (cnf->markedusers < 0)
+			if (cnf->admins < 0)
 				strcpy(cmdline, "N/A ");
 			else 
-				snprintf(cmdline, sizeof(cmdline), "%4.4d", cnf->markedusers);
+				snprintf(cmdline, sizeof(cmdline), "%4.4d", cnf->admins);
 			hr = (now - cnf->start) / 3600;
 			min = ((now - cnf->start) % 3600) / 60;
 			sec = (now - cnf->start) % 60;
@@ -320,6 +323,7 @@
 	}
 	if (argc < 3)
 		return RESULT_SHOWUSAGE;
+
 	strncpy(cmdline, argv[2], 100);	/* Argv 2: conference number */
 	if (strstr(argv[1], "lock")) {	
 		if (strcmp(argv[1], "lock") == 0) {
@@ -471,7 +475,7 @@
 	struct ast_conference *conf = ptr;
 	int res;
 	ast_mutex_lock(&conflock);
-	res = (conf->markedusers < 0);
+	res = (conf->admins < 0);
 	ast_mutex_unlock(&conflock);
 	return res;
 }
@@ -518,11 +522,11 @@
 		goto outrun;
 	}
 	conf->users++;
-	if (confflags & CONFFLAG_ADMINEXIT) {
-		if (conf->markedusers == -1) {
-			conf->markedusers = 1;
+	if (confflags & CONFFLAG_ADMIN) {
+		if (conf->admins == -1) {
+			conf->admins = 1;
 		} else {
-			conf->markedusers++;
+			conf->admins++;
 		}
 	}
       
@@ -554,12 +558,12 @@
 	user->adminflags = 0;
 	ast_mutex_unlock(&conflock);
 	origquiet = confflags & CONFFLAG_QUIET;
-	while((confflags & CONFFLAG_WAITMARKED) && (conf->markedusers < 0)) {
+	while((confflags & CONFFLAG_WAITADMIN) && (conf->admins < 0)) {
 		confflags &= ~CONFFLAG_QUIET;
 		confflags |= origquiet;
 		/* XXX Announce that we're waiting on the conference lead to join */
 		if (!(confflags & CONFFLAG_QUIET)) {
-			res = ast_streamfile(chan, "vm-dialout", chan->language);
+			res = ast_streamfile(chan, "conf-waitforchairman", chan->language);
 			if (!res)
 				res = ast_waitstream(chan, "");
 		} else
@@ -576,7 +580,16 @@
 			goto outrun;
 		}
 	}
-	
+	/* XXX Announce that we're being put into the conference as the lead has join  */
+	if (confflags & CONFFLAG_WAITADMIN) {
+		if (!(confflags & CONFFLAG_QUIET)) {
+			res = ast_streamfile(chan, "conf-placeintoconf", chan->language);
+			if (!res)
+				 res = ast_waitstream(chan, "");
+		}
+		
+	}
+	/* WHY ?? if there is 1 user and QUIET is on, skip the linear mode write and read settings and the rest, I hate goto */	
 	if (!(confflags & CONFFLAG_QUIET) && conf->users == 1) {
 		if (!ast_streamfile(chan, "conf-onlyperson", chan->language)) {
 			if (ast_waitstream(chan, "") < 0)
@@ -744,8 +757,13 @@
 				}
 			}
 			
-			/* Leave if the last marked user left */
-			if (conf->markedusers == 0) {
+			/* Leave if the last admin user left */
+			if (confflags & CONFFLAG_ADMINEXIT && conf->admins == 0) {
+				if (!(confflags & CONFFLAG_QUIET)) {
+					res = ast_streamfile(chan, "conf-adminhasleft", chan->language);
+					if (!res)
+						res = ast_waitstream(chan, "");
+				}
 				ret = -1;
 				break;
 			}
@@ -954,8 +972,8 @@
 			chan->name, chan->uniqueid, conf->confno);
 		prev = NULL;
 		conf->users--;
-		if (confflags & CONFFLAG_ADMINEXIT) 
-			conf->markedusers--;
+		if (confflags & CONFFLAG_ADMIN) 
+			conf->admins--;
 		cur = confs;
 		if (!conf->users) {
 			/* No more users -- close this one out */
@@ -1122,6 +1140,7 @@
 	int res=-1;
 	struct localuser *u;
 	char confno[AST_MAX_EXTENSION] = "";
+	char originconfno[AST_MAX_EXTENSION] = "";
 	int allowretry = 0;
 	int retrycnt = 0;
 	struct ast_conference *cnf;
@@ -1147,6 +1166,8 @@
 		strncpy(confno, tmp, sizeof(confno));
 		if (ast_strlen_zero(confno)) {
 			allowretry = 1;
+		} else {
+			strncpy(originconfno,confno,sizeof(confno));
 		}
 	}
 	if (info)
@@ -1176,7 +1197,7 @@
 		if (strchr(inflags, 'b'))
 			confflags |= CONFFLAG_AGI;
 		if (strchr(inflags, 'w'))
-			confflags |= CONFFLAG_WAITMARKED;
+			confflags |= CONFFLAG_WAITADMIN;
 		if (strchr(inflags, 'd'))
 			dynamic = 1;
 		if (strchr(inflags, 'D')) {
@@ -1194,7 +1215,7 @@
 	}
 
 	do {
-		if (retrycnt > 3)
+		if (retrycnt > MAXRETRY)
 			allowretry = 0;
 		if (empty) {
 			int i, map[1024];
@@ -1296,7 +1317,7 @@
 				}
 			}
 		}
-		while (allowretry && (ast_strlen_zero(confno)) && (++retrycnt < 4)) {
+		while (allowretry && (ast_strlen_zero(confno)) && (++retrycnt <= MAXRETRY)) {
 			/* Prompt user for conference number */
 			res = ast_app_getdata(chan, "conf-getconfno", confno, sizeof(confno) - 1, 0);
 			if (res < 0) {
@@ -1325,7 +1346,9 @@
 						res = 0;
 					} else {
 						/* Prompt user for pin if pin is required */
-						res = ast_app_getdata(chan, "conf-getpin", pin, sizeof(pin) - 1, 0);
+						if (++retrycnt <= MAXRETRY)
+							res = ast_app_getdata(chan, "conf-getpin", pin, sizeof(pin) - 1, 0);
+
 					}
 					if (res >= 0) {
 						if (!strcasecmp(pin, cnf->pin)) {
@@ -1339,7 +1362,7 @@
 							if (!res)
 								ast_waitstream(chan, "");
 							res = -1;
-							if (allowretry)
+							if (allowretry  && sizeof(originconfno) == 0)
 								strcpy(confno, "");
 						}
 					} else {
